Repository navigation
chore(release): v0.6.9 — Gemma 4 batched-attention NaN fix - #354
Conversation
- Advance libs/mlx-swift-lm to ee2a921 (mlx-swift-lm#38): NaN-guard fully-masked query rows in gemma4AttentionFallback. When continuous batching co-prefills requests of different lengths, short rows are left-padded and their padding queries become fully masked; the manual batched-attention fallback softmaxed those all-`-inf` rows to NaN and `0 * NaN` in the value matmul propagated NaN into every row -> all-NaN logits -> token-salad / repetition on some responses under concurrent load. Decode path and solo/uniform batches were unaffected. - Bump provider version 0.6.8 -> 0.6.9.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
ethenotethan
left a comment
There was a problem hiding this comment.
Automated Code Review — Layr-Labs/d-inference#
Verdict: COMMENT
Security — ✅ No issues found
Performance — ✅ No issues found
Type_diligence — ✅ No issues found
Additive_complexity — ✅ No issues found
✅ All four passes clean. No issues found.
🤖 Automated review by Centaur · DAR-186
|
No directly modeled files changed; two files fall outside current threat model coverage — review recommended before merge. Trust boundaries touchedNone of the changed files are listed under Threat coverage
New attack surface not covered by an existing threat
Threat model update recommendedThe following additions should be made to keep the threat model current: # Add to T-027, T-028, T-007 affected_files:
- libs/mlx-swift-lm
# Add to T-013, T-014, T-015, T-034 affected_files:
- provider-swift/Sources/ProviderCore/ProviderCore.swiftNo existing SEC-* findings are resolved by this PR. No existing mitigations appear to be weakened based on the file paths alone, but the 🔐 Threat model: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 48163349f6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // propagated into every row -> token-salad/repetition under concurrent load. | ||
| // Fixed in mlx-swift-lm#38 (gemma4AttentionFallback NaN-guard); submodule | ||
| // pin advanced to ee2a921. | ||
| public static let version = "0.6.9" |
There was a problem hiding this comment.
Bump the coordinator fallback version with the provider release
This version bump leaves coordinator/api/server.go hardcoded at LatestProviderVersion = "0.6.4", and handleVersion uses that value whenever no release record is registered. In dev/in-memory coordinators, an installed 0.6.8 provider will therefore be told the latest version is still 0.6.4 and will not auto-update to this 0.6.9 NaN fix, so concurrent Gemma 4 experiments can keep running on the buggy submodule. Please update the fallback alongside this provider version bump.
Useful? React with 👍 / 👎.
…SDK main) Pins libs/mlx-swift-lm to Layr-Labs/mlx-swift-lm#356's head efd38585: #342 + #354 + #353 + #355 merged with SDK main 755bdf67, which carries #339 (upstream sync 2026-10-22), #349 and #348. The SDK pins mlx-swift 6c31f9f1 (#349: compiled traces keyed by the task's default stream), so libs/mlx-swift moves 67dc7528 -> 6c31f9f1 (nested mlx 83dbdb04, mlx-c cb19abf6) and libs/mlx moves ad4745a2 -> 83dbdb04 in lockstep; the provider links the local mlx-swift, and scripts/fetch-metallib.sh builds the metallib from its nested mlx (ca34a2e8..., was 156f2624...). provider-swift/Package.resolved is unchanged. API adaptations, each the minimal change to the upstream API: - MLXLLM.Gemma4AssistantDraftModel: upstream added an MLXVLM type of the same name; the provider keeps the fork's MLXLLM drafter it always used (EngineV2MTPAssistant, ProviderBenchmark BackendParityHarness and MTPProductionSession). - LanguageModel.prepare(_:cache:state:prefill:) replaces prepare(_:cache:windowSize:): GLM5NextProtectedModel forwards the new arguments to its root (no provider caller; serving runs through the native steppable), and 25 test stubs take the new signature. - newCache(parameters:) throws: GLM5NextProtectedModel forwards with try; ThroughputSweep's default caches use try? (nil parameters cannot fail validation, as the SDK's own probes do). - UserInput.Image and UserInput.Video are structs with a source enum: MediaIngest's realized-extent check and the MiMo encoded-media ingress match on .source; 9 test patterns likewise. - Qwen35Model.sanitize(weights:) throws: EngineV2VLMTextExtraction. reKeyedQwenTargetWeights propagates it (its caller already throws). - Generation gained .rejectedToolCall: ModelBenchmark ignores it, as it ignores .toolCall. - GatedDeltaPrefill moved from MLXLLM to MLXLMCommon: the LaunchAgent passthrough test imports MLXLMCommon @testable; LaunchAgent's comment names the new module; four docs cite Libraries/MLXLMCommon/GatedDelta.swift (docs-check follows the pin).
Summary
Cuts v0.6.9, advancing the `libs/mlx-swift-lm` submodule to ee2a921 (mlx-swift-lm#38) and bumping the provider version 0.6.8 → 0.6.9.
The bug it fixes
`gemma-4-26b` produced token-salad / repetition garbage on some responses under concurrent load — e.g. "I's a marathon, but I's a marathon, just a marathon…" or collapsing into a repeated token. Reproduced on the live fleet (targeted at a busy provider) and isolated to batched decoding: it survives greedy, top-k/top-p, and repetition_penalty because the logits are NaN before sampling.
Root cause: continuous batching co-prefills requests of different prompt lengths in one forward pass; the cache left-pads the short rows and the attention mask blocks their padding slots, making those rows' padding-position queries fully masked. The hand-rolled `gemma4AttentionFallback` softmaxed an all-`-inf` row to NaN, and `0 * NaN = NaN` in the value matmul propagated NaN into every row of the batch → all-NaN logits → garbage. Measured: a left-padded row's prefill logits were 1024/1024 NaN before, 0 after.
The submodule PR maps post-softmax NaN→0 (matching `MLXFast.scaledDotProductAttention`, used by the decode path and mlx-lm). No behavior change for solo / uniform-length batches.
Verification (in mlx-swift-lm#38)
Notes
Release: after merge, tag `v0.6.9` on master to trigger the Swift release workflow.
🤖 Generated with Claude Code
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.