Conversation
1 of 5 tasks
Collaborator
|
@MdSadiqMd This is a great solution! Approved. There were some conflicts with other merged PRs, so I am waiting on the CI rerun after those resolutions to complete the merge |
jlarson4
approved these changes
Sep 28, 2026
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.
Description
A fit in the sparse-probing sweep runs LBFGS then damped Newton refinement and is accepted only when the Newton decrement is at most
decrement_tolerance(the acceptance rule that landed in #1774). A fit that misses it raises, andsweep_sparse_probehad no partial-result path, so a single rejected fit discarded everything already computed — including the main probes, which are the expensive part and typically fine. On the sweep path most fits are controls, so this "lose everything" failure was overwhelmingly triggered by an auxiliary control repeat.Since the refinement landed this no longer fires at shipped defaults, so it's robustness rather than routine loss — but the failure mode is still "lose everything" for a control that stopped short. Related:
stop_reason,newton_decrement, andrefinement_stepsare onSparseProbeResultbut not on controls, and there was no way to tell from a result which control fits were rejected or why.This PR:
RuntimeErrorrecords the fit and is skipped rather than aborting the sweep. Completed main probes and other controls survive. Each control's rows now cover only the repeats that converged (the row count can be below the requested repeat count).SparseProbeRejection(arm, k, repeat, support, reason)dataclass;SparseProbeSweepgainsrejections: tuple[SparseProbeRejection, ...] = ()(defaulted, so existing construction is unaffected). Exported fromtransformer_lens.tools.analysis.fit_sparse_probeand main-probe fits raising. Only the sweep's control fits are made resilient. Main fits stay 1:1 withksand still raise on non-convergence, andfit_sparse_probeis untouched — a hard failure on the primary output stays loud.SparseProbeControlor saying plainly that it doesn't; this takes the documentation route.SparseProbeControl's docstring and the sparse-probing guide now state that controls carry raw metrics only (no per-fit convergence diagnostics), and that rejected control fits are collected insweep.rejections.Acceptance, all verified:
resultspresent for everyk, other controls intact.test_sweep_records_rejected_controls_and_keeps_completed_fits), which fails on the pre-fix code (the sweep raised) and passes now; plus a clean-path test assertingrejections == ()when every control converges.make unit-testpasses (6695 passed, 56 skipped, 6 xfailed).uv run mypy .passes (385 files).Fixes #1815
Type of change
Please delete options that are not relevant.
Screenshots
N/A
Checklist: