Relax tolerance in Qwen Scope loader test to fix flaky CI#706
Merged
chanind merged 1 commit intoJun 16, 2026
Merged
Conversation
test_qwen_scope_sae_huggingface_loader_with_mocked_download compares two mathematically equal matmuls: the loader stores W_enc/W_dec as `.T.contiguous()`, while the reference multiplies a transposed view. Over the 2048- and 32768-dim reductions these layouts can accumulate float32 in a different order depending on the BLAS backend, so the results differ by small rounding noise that intermittently exceeds the default rtol=1e-5/atol=1e-8 and fails CI. Compare with rtol=1e-3/atol=1e-2, which absorbs the rounding while still catching any real loader regression. Fixes decoderesearch#688
chanind
approved these changes
Jun 16, 2026
chanind
left a comment
Collaborator
There was a problem hiding this comment.
Looks good, thanks for this!
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
test_qwen_scope_sae_huggingface_loader_with_mocked_downloadintermittentlyfails in CI (e.g. the two runs linked in #688). It compares two mathematically
equal matmuls: the loader stores
W_enc/W_decas.T.contiguous(), while thereference in the test multiplies a transposed view (
raw_W_enc.T). Over the2048- and 32768-dim reductions, a contiguous tensor and a transposed view can
accumulate float32 in a different order depending on the BLAS backend, so the
two results agree only up to rounding. The default
assert_closetolerance(
rtol=1e-5,atol=1e-8) is too tight to absorb that, which is whatdanradiagnosed on the issue.
This compares with
rtol=1e-3, atol=1e-2, matching the existing precedent for amatmul comparison elsewhere in this file. The tolerance is generous enough to
absorb the accumulation noise but still catches a real loader regression, which
would be orders of magnitude off (verified locally: a 1% weight-scale error and
a wrong-bias error are both still rejected).
Note: the failure is BLAS/threading-dependent and reproduces on CI but not on
local arm64 macOS (where the two layouts produce bit-identical results), so this
is verified by the linked CI logs plus the regression check above rather than a
local repro.
Fixes #688
Type of change
Checklist:
You have tested formatting, typing and tests