Commit b3b9934
Fix FactoredMatrix indexing returning empty result for -1 index (#1340)
* Fix type of HookedTransformerConfig.device (#1230)
* Fix type of HookedTransformerConfig.device
This is typed as `Optional[str]` but sometimes returns `torch.device`.
Updated the code to just return the `str` instead of wrapping with a
device.
I'm not confident that every function which takes a device will
always be passed a string, so I didn't change functions like
warn_if_mps.
Found while working on #1219
* more cleanup
* 3.0 CI Bugs (#1261)
* Fixing `utils` imports
* skip gated notebooks on PR from forks
* Updating notebooks
* Ensure LLaMA only runs when HF_TOKEN is available
---------
Co-authored-by: jlarson4 <jonahalarson@comcast.net>
* Fix TransformerBridge backward hook cleanup (#1324)
* Fix TransformerBridge backward hook cleanup
* Preserve backward hooks in run_with_cache
* Fix FactoredMatrix indexing returning empty result for -1 index
FactoredMatrix.__getitem__ converts an integer index `v` into the matrix
(ldim/rdim) dimensions to `slice(v, v + 1)`. For `v == -1` this becomes
`slice(-1, 0)`, which is an empty slice, so indexing the last row/column
with a negative index silently returns a (0, ...) tensor instead of the
requested element. Other negative indices (-2, -3, ...) are unaffected
because `v + 1` stays negative.
Use `None` as the slice stop when `v == -1` so the final element is kept.
Adds regression tests covering negative indices on each matrix dimension.
---------
Co-authored-by: Brendan Long <self@brendanlong.com>
Co-authored-by: jlarson4 <jonahalarson@comcast.net>
Co-authored-by: Samuele_Punzo <90847990+SamuelePunzo@users.noreply.github.com>1 parent f676d8a commit b3b9934
6 files changed
Lines changed: 95 additions & 14 deletions
File tree
- tests
- acceptance/model_bridge/compatibility
- unit/factored_matrix
- transformer_lens
- model_bridge
- generalized_components
Lines changed: 39 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
54 | 73 | | |
55 | 74 | | |
56 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
288 | 288 | | |
289 | 289 | | |
290 | 290 | | |
291 | | - | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
292 | 297 | | |
293 | 298 | | |
294 | 299 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2114 | 2114 | | |
2115 | 2115 | | |
2116 | 2116 | | |
2117 | | - | |
| 2117 | + | |
2118 | 2118 | | |
2119 | 2119 | | |
2120 | 2120 | | |
| |||
2181 | 2181 | | |
2182 | 2182 | | |
2183 | 2183 | | |
2184 | | - | |
| 2184 | + | |
2185 | 2185 | | |
2186 | 2186 | | |
2187 | 2187 | | |
| |||
2207 | 2207 | | |
2208 | 2208 | | |
2209 | 2209 | | |
2210 | | - | |
| 2210 | + | |
2211 | 2211 | | |
2212 | 2212 | | |
2213 | 2213 | | |
| |||
2276 | 2276 | | |
2277 | 2277 | | |
2278 | 2278 | | |
2279 | | - | |
2280 | | - | |
| 2279 | + | |
| 2280 | + | |
2281 | 2281 | | |
2282 | 2282 | | |
2283 | 2283 | | |
| |||
3452 | 3452 | | |
3453 | 3453 | | |
3454 | 3454 | | |
3455 | | - | |
| 3455 | + | |
3456 | 3456 | | |
3457 | 3457 | | |
3458 | 3458 | | |
| |||
3468 | 3468 | | |
3469 | 3469 | | |
3470 | 3470 | | |
3471 | | - | |
| 3471 | + | |
3472 | 3472 | | |
3473 | 3473 | | |
3474 | 3474 | | |
| |||
3501 | 3501 | | |
3502 | 3502 | | |
3503 | 3503 | | |
3504 | | - | |
3505 | | - | |
| 3504 | + | |
| 3505 | + | |
3506 | 3506 | | |
3507 | 3507 | | |
3508 | 3508 | | |
| |||
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
191 | | - | |
192 | | - | |
| 191 | + | |
| 192 | + | |
193 | 193 | | |
194 | | - | |
| 194 | + | |
195 | 195 | | |
196 | | - | |
| 196 | + | |
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
| |||
0 commit comments