fix(sparse_probing): add std_floor to standardization - #1827
Merged
jlarson4 merged 4 commits intoSep 28, 2026
Merged
Conversation
Near-constant columns were being divided by their own tiny std, blowing noise up to unit scale. The scale now has a floor (default 1e-3, same as the reference). Zero-variance columns still get scale 1, and std_floor=0 keeps the old behavior. Also document the max_eval budget in the max_iter docstrings.
1 of 5 tasks
jlarson4
reviewed
Sep 28, 2026
jlarson4
left a comment
Collaborator
There was a problem hiding this comment.
Welcome to working on TransformerLens @VictorAraujopy! Thanks for putting this solution together. A couple small feedback items below before we get this merged
Test that sweep_sparse_probe passes std_floor to its main and control fits, fix the zero-variance guard comment, and note that the line search can go one evaluation past the max_eval budget.
Author
Collaborator
|
Thank you for resolving those for me @VictorAraujopy! Looks great, approved and merging now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1816
Under
preprocess="standardize", only an exactly-zero std was guarded, so a near-constant column was divided by its own tiny std and reached the fit as noise at unit scale. This adds astd_floorparameter tofit_sparse_probeandsweep_sparse_probe(default1e-3, matching the reference): each non-constant column's scale is nowmax(std, std_floor).std_floor=0. This is the one remaining divergence from the reference, and it's noted in the guide's Reference section.std_floor=0disables the floor and reproduces the previous behavior.std_flooris validated (finite, non-negative, not bool) and recorded onSparseProbeResult.max_iterdocstrings and the guide now state the LBFGS evaluation budget,max_iter * 5 // 4(equal tomax_iterwhenmax_iter <= 3); the line search can go one evaluation past it.Note: with the new default,
preprocess="standardize"results change for columns whose training std is below1e-3.make unit-testanduv run mypy .pass locally. Happy to change the constant-column handling if you'd prefer it to follow the reference exactly.Type of change
Checklist: