Skip to content

test(provider): evaluate the Qwen4 paging fixture's weights (release shard SIGBUS root cause) - #1753

Merged
davidtai merged 1 commit into
devfrom
fix/qwen4-test-lazy-weights
Nov 3, 2026
Merged

davidtai merged 1 commit into
devfrom
fix/qwen4-test-lazy-weights

Conversation

@davidtai

@davidtai davidtai commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes the cause of the dev release qualification crash. #1750 unblocked the release by restoring the old placement; this PR removes the crash itself.

Qwen4PagingPrefixIntegrationTests now evaluates its tiny model's random weights right after construction. The same change is already in Qwen4LayerSubmissionStateProbeTests and NemotronPagingPrefixIntegrationTests.

Root cause

  • The crash. Release shard 2 on dev b4800a5 and 70b2f6d died with signal 10 in "Balanced Flash-Next keeps indexer/recurrent state and uses packed complete attention". The lldb backtrace (bisect DO NOT MERGE: bisect release shard-2 SIGBUS (Qwen4 paging suite) #1751, run 41715223565) shows a stack overflow:
    • EXC_BAD_ACCESS (code=2, address=0x1700bfff8) on the Swift Testing cooperative thread. That address is the stack guard page, just below the live frames. macOS reports a guard-page fault as SIGBUS.
    • The thread is deep inside mlx::core::detail::compile_dfs recursion.
  • Why compile goes so deep.
    • The test model's first forward runs Qwen4Exp's compiled hyper-connection decode closure (compile(inputs: [], outputs: []) around projectCanonical). That closure captures the module weights as constants.
    • compile_dfs (mlx/compile.cpp) recurses through std::function into the inputs of every unevaluated array.
    • Unevaluated random-init weights lead into MLXRandom.globalState. Each RandomState.next() replaces the key with a lazy split and nothing evaluates it, so the key is a chain that grows with every unevaluated random draw in the process.
  • Why only after certain neighbors. The NemotronSuperManagedSlotTests fixtures build random-init models and then replace their weights, so the chain grows long. CI: Blacksmith-only macOS jobs, PR cache saves only on a cold restore, eight provider shards #1733's shard weights put that suite before the Qwen4 suite in release shard 2. The bisect showed this pair alone is enough:
Selection (release SDK 27 build, dev 70b2f6d) Result
Qwen4 suite alone pass
NemotronSuperManagedSlotTests, then the Qwen4 suite SIGBUS
Each Nemotron wedge test alone, then the Qwen4 suite pass
Both wedge tests, or the Nemotron suite without them, then the Qwen4 suite SIGBUS

The effect is cumulative. The crash always comes 3–6 ms after affineQmm first-miss, at the first forward.

  • Production. No production path is known to be affected. Loaded weights are evaluated arrays, and MLX eval is iterative (an explicit std::stack), so evaluating a long key chain cannot overflow. The global key chain is still unbounded lazy state in any process that discards random-init weights. That is a candidate hardening for mlx-swift-lm or the fixtures, not part of this PR.

Before

  1. Earlier suites build random-init models and then replace their weights. Each unevaluated random draw makes the global key chain in MLXRandom.globalState longer.
  2. The Qwen4 paging fixture builds a Qwen4ExpTextModel and leaves its weights unevaluated.
  3. The first forward runs the compiled hyper-connection closure. compile_dfs recurses through the captured weights into the whole key chain.
  4. The recursion overflows the cooperative thread's stack. The test process dies with signal 10.

After

  1. Earlier suites still make the global key chain longer. This PR does not change that.
  2. The Qwen4 paging fixture calls eval(model) after construction. The iterative eval computes the weights and detaches their graph.
  3. The first forward runs the compiled closure. compile_dfs stops at the evaluated weights.
  4. The test runs the same way in any process order.

Validation

Refactor pass

An independent refactor subagent reviewed the change and made no changes. Its notes: the change is the smallest behavior-preserving fix, it matches the existing eval(model) pattern, it compiles with the file's current imports, and the comment is accurate.

Limitations

  • Test-only change. There is no changelog fragment, because nothing user-visible changes.
  • The process-global lazy random key chain is left as is (see Production above).

🤖 Generated with Claude Code

The tiny Qwen4ExpTextModel in Qwen4PagingPrefixIntegrationTests kept its
random initial weights unevaluated. Its first forward runs the compiled
hyper-connection decode closure, which captures those weights as constants,
and MLX's compile_dfs recurses through every unevaluated input. Each random
weight's graph reaches the process-global MLXRandom key, a lazy split chain
that every earlier unevaluated draw in the test process lengthens.

After the managed Nemotron Super slot tests (whose fixtures build random-init
models and then replace the weights), the chain is deep enough that the
recursion overflows the Swift Testing cooperative thread's stack. The guard
page fault is EXC_BAD_ACCESS code=2, reported as signal 10, in release
qualification shard 2 of dev b4800a5 and 70b2f6d.

Evaluate the model after construction, as a loaded model's weights are and
as the other tiny-model tests (Qwen4LayerSubmissionStateProbeTests,
NemotronPagingPrefixIntegrationTests) already do. MLX eval is iterative, so
evaluating the chain is safe and detaches it from the weights.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
d-inference Error Error Nov 3, 2026 9:06pm UTC
d-inference-console-ui-dev Error Error Nov 3, 2026 9:06pm UTC
d-inference-landing Ready Ready Preview Nov 3, 2026 9:06pm UTC
darkbloom-status Ready Ready Preview Nov 3, 2026 9:06pm UTC
eigen-homepages-darkbloom Ready Ready Preview Nov 3, 2026 9:06pm UTC

Request Review

@davidtai

davidtai commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator Author

Verification run 41716846257 passed. It used this commit cherry-picked onto failing dev 70b2f6d, with the release SDK 27 qualification build:

Selection Before (dev 70b2f6d) With this commit
NemotronSuperManagedSlotTests + Qwen4PagingPrefixIntegrationTests SIGBUS (run 41712473631) pass: 51 tests in 2 suites
Full release shard-2 selection of run 41704012078 SIGBUS (run 41710910832) pass: 1143 tests in 168 suites

In the full selection, NemotronSuperManagedSlotTests ran first (25.4 s), then the Qwen4 suite (15.6 s), in the same process.

This branch had an error being deployed

2 failed and 3 active deployments
Preview – d-inference-console-ui-dev — 918f3fe8 Deployed Nov 3, 2026 by vercel[bot]
Preview – eigen-homepages-darkbloom — 918f3fe8 Deployed Nov 3, 2026 by vercel[bot]
Preview – d-inference-landing — 918f3fe8 Deployed Nov 3, 2026 by vercel[bot]
Preview – d-inference — 918f3fe8 Deployed Nov 3, 2026 by vercel[bot]
Preview – darkbloom-status — 918f3fe8 Deployed Nov 3, 2026 by vercel[bot]
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