Skip to content

Prep for release v4.2.0 – Contribution follow ups - #1875

Merged
jlarson4 merged 4 commits into
devfrom
feat/v420-review-followups
Oct 9, 2026
Merged

jlarson4 merged 4 commits into
devfrom
feat/v420-review-followups

Conversation

@jlarson4

@jlarson4 jlarson4 commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

Description

Ensuring any edge cases introduced by new contributions are addressed. Primarily adding additional layers of testing trying to ensure components are properly covered.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • This change requires a documentation update

Checklist:

  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have not rewritten tests relating to key interfaces which would affect backward compatibility

@jlarson4
jlarson4 merged commit a8bc19e into dev Oct 9, 2026
53 of 54 checks passed
abhishekcpp007 added a commit to abhishekcpp007/TransformerLens that referenced this pull request Nov 4, 2026
…_results

stack_neuron_results got a guard in TransformerLensOrg#1875: with incl_remainder=True, a
layer below 0 raises, because range(layer) is empty and the remainder
reads resid_post[layer - 1], which __getitem__ wraps to a late layer.
stack_head_results has the same code path and never got the guard.

On a 4-layer model stack_head_results(-2, incl_remainder=True) returns
one component labelled "remainder" that is resid_post[1], with no error.
On a 2-layer model the same call fails with a KeyError on
blocks.-1.hook_resid_post instead of the sibling's ValueError.

Raise the same ValueError as the neuron stack. layer=0 stays valid and
still returns the whole final residual stream, and incl_remainder=False
is unchanged.
jlarson4 added a commit that referenced this pull request Nov 6, 2026
…_results (#1976)

* fixing slow tests (#1877)

* fix(ActivationCache): reject a negative remainder layer in stack_head_results

stack_neuron_results got a guard in #1875: with incl_remainder=True, a
layer below 0 raises, because range(layer) is empty and the remainder
reads resid_post[layer - 1], which __getitem__ wraps to a late layer.
stack_head_results has the same code path and never got the guard.

On a 4-layer model stack_head_results(-2, incl_remainder=True) returns
one component labelled "remainder" that is resid_post[1], with no error.
On a 2-layer model the same call fails with a KeyError on
blocks.-1.hook_resid_post instead of the sibling's ValueError.

Raise the same ValueError as the neuron stack. layer=0 stays valid and
still returns the whole final residual stream, and incl_remainder=False
is unchanged.

---------

Co-authored-by: Jonah Larson <jonahalarson@comcast.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant