Repository navigation
adjustments for running tests on NAX/TF32 hardware - #649
Merged
Merged
Conversation
nwh
approved these changes
Sep 30, 2026
nwh
left a comment
Collaborator
There was a problem hiding this comment.
looks good, some minor comments
| } | ||
| return text | ||
| } | ||
|
|
Collaborator
There was a problem hiding this comment.
maybe mention in PR description that this fix is unrelated to TF32
| } else { | ||
| XCTAssertGreaterThan( | ||
| diff, 1e-3, | ||
| diff, MatmulPrecision.splitTolerance, |
Collaborator
There was a problem hiding this comment.
I don't have M5, so can't verify this. Claude thinks TF32 noise might trigger a failure here:
- When
expectsIsolation == false(Qwen2VL), the test assertsdiff > splitTolerance. So on TF32
the required divergence rose from 1e-3 to 2e-2. - On M4 (float32), the real cross-image effect in
Qwen25VLContinuationTestsmeasures
0.0468. That leaves only about 2.3× headroom over 2e-2, and TF32 noise can movediffeither
way. - Tightening is the right direction: at 1e-3, TF32 noise (~3e-3) could satisfy the check by
itself. But the cutoff here should be "clearly above noise", not "the equality tolerance". - Suggestions:
- Use a dedicated lower bound, e.g.
tolerance(float32: 1e-3, reduced: 1e-2). - Or, better, compare against a measured noise floor, as
assertWarmTextContinuationalready does. - At minimum, add the measured value to the failure message.
- Use a dedicated lower bound, e.g.
Member
Author
There was a problem hiding this comment.
FWIW the tests do pass on both M4 and M5. The value shouldn't need to be added to the message -- the assert output will already include that.
Co-authored-by: Nick Henderson <525247+nwh@users.noreply.github.com>
wballard
added a commit
to swissarmyhammer/mlx-swift-lm-old
that referenced
this pull request
Oct 3, 2026
Apply the upstream commits ee673d6..55db721 as a 3-way patch. CLAUDE.md is excluded. - c043fb3 pick up mlx-swift 0.32.2 (ml-explore#646) - 0493daf Named image attachments in MLXLMCommon and the Foundation Models adapter (ml-explore#535) - 0dcfe2f Convert the booleans in tool parameter schemas to Swift Bool values (ml-explore#653) - 37dab60 be able to trigger workflows on main. notes about upcoming releases. (ml-explore#647) - 390c5fd require mlx-swift-0.32.3 for SDK issue (ml-explore#657) - 3b339ad adjustments for running tests on NAX/TF32 hardware (ml-explore#649) - ac6f565 update documentation and skills (ml-explore#489) - ce3950e Drop MTP weights from converted Qwen 3.5 VLM checkpoints (ml-explore#642) - 9112fae Synchronize cross-SIMD WHT reads before shared-memory writes (ml-explore#650) - 7e4024e NemotronH: MoE keys are optional, so dense checkpoints load (ml-explore#635) - 1830ae4 Declare the fused GDN projection as compile state so it frees with the model (ml-explore#631) - 6e0a0b2 Synchronize Metal before checking cached buffer memory (ml-explore#667) - 9afc3b5 Recommend upToNextMinor in installation instructions (ml-explore#668) - 55db721 Reduce Qwen3 reranking memory by projecting final tokens only (ml-explore#621) Conflict resolutions: - MLXLanguageModel.swift: keep the drain coordinator and runRespond of stable, and keep historyMessages. Add the upstream attachment label validation before resolveConfiguration. historyMessages now throws, because TranscriptConverter.mlxMessages now throws. - TranscriptConverter.swift: keep the mlxMessages(for:replayReasoning:) and convert(entry:) form of stable. Apply the upstream changes in convert(entry:): it throws, an instructions entry drops its images, and extractImages(from:in:) applies the orientation and rejects content that is not an image. - Chat.swift: keep the doc comments of stable, and add the upstream MessageContentLayout and contentParts(for:layout:). - TurboQuantKernels.swift: keep stable. Stable already fixed the same cross-SIMD WHT race with two barriers per stage. - KVCacheTests.swift: take the upstream file (upstream changed it to a suite). Delete the upstream ArraysCache.advance test, because in this fork advance(_:) also moves offset. Add the fork tests for advance and the trim-then-continue test at file scope. - Qwen35FusedGDNProjectionTests.swift: keep the deletion of the opt-in benchmark (it skips unless an environment variable is set). Add the new upstream memory test. - model-container.md: take upstream (llama3_2_3B_4bit and the macros are the real API). - TranscriptConverterTests.swift: the replayReasoning calls now use try. Tests: MLXGuidedGenerationTests 70, MLXFoundationModelsTests 349, CXGrammarTests 7, MLXHuggingFaceMacrosTests 5 pass. MLXLMTests: 1287 Swift Testing tests pass, and 699 of 700 XCTest tests pass. The failure is the wall-clock limit of EvalTests testVarianceNormalizedKVCache32KIngestAndDecodePeakMetalMemorySmoke (0.29 s, limit 0.25 s) in the full run. The test passes alone two times, and this merge does not change EvalTests.swift. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 of 5 tasks
saurabhav88
added a commit
to saurabhav88/mlx-swift-lm
that referenced
this pull request
Nov 10, 2026
…l-explore#649) Backport ml-explore/mlx-swift-lm commit 3b339ad "adjustments for running tests on NAX/TF32 hardware", tests only, with one declared adaptation. On hardware with neural accelerators MLX runs some float32 matmuls as TF32. Tests that compute one result two ways then disagree by about 1e-3 instead of 1e-7, so bounds sized for IEEE float32 fail for reasons unrelated to the code under test. At this fork's base that left 26 continuation cases, the SSM test and both GDN speculative-checkpoint tests failing on an M5, which would hide a real regression. MatmulPrecision measures the precision and each call site states a strict and a reduced bound. The router tests now compare assembled response text. Adaptation (not upstream): MatmulPrecision.relativeMatmulError is the larger of two shapes. With the MLX core this fork pins (0.31.1) the upstream [64, 512] x [512, 64] product is dispatched to the split-K kernel, which stays IEEE float32 when TF32 is on, so the upstream probe read 7.8e-7 on an M5 and kept the strict bounds. A [64, 64] x [64, 64] product takes the regular kernel and reads about 9e-4 there, 0 with MLX_ENABLE_TF32=0. Revalidate the probe shapes whenever the mlx-swift pin changes. Tests: the full suite passes in default mode and with MLX_ENABLE_TF32=0 (650 XCTest tests with 2 skipped; Swift Testing bundles of 863, 154, 70 and 7 tests), including the new probe self-test.
3 of 5 tasks
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.
Proposed changes
adjustments for running tests on NAX/TF32 hardware.
I have been relying on CI machines for test runs -- the runners are M4 and do not have NAX/TF32. When I ran it locally (M5) I found some assertion failures in tolerance. Running with
MLX_ENABLE_TF32=0eliminated the errors, so that strongly suggests they are NAX/TF32 related.In mlx-swift we have a dedicated integration test target that forces that to be set, but all of the tests in there are built with a python tool that ensures the results match mlx (python). The tool is able to ensure that all code passes through a handler that sets MLX_ENABLE_TF32. Not really feasible here.
The approach I took is to detect NAX and pick an appropriate threshold based on that.
Also some changes (not necessarily TF32 related) in AllowedToolOutputRouterTests.swift to handle text split across tokens.
Checklist
Put an
xin the boxes that apply.pre-commit run --all-filesto format my code / installed pre-commit prior to committing changesAI usage
accurately describes the code changes.