Skip to content

fix: restore Kimi Linear CUDA inference - #2296

Merged
inureyes merged 8 commits into
mainfrom
fix/issue-2292-kimi-cuda-inference
Oct 14, 2026
Merged

inureyes merged 8 commits into
mainfrom
fix/issue-2292-kimi-cuda-inference

Conversation

@inureyes

@inureyes inureyes commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Kimi Linear used the additive causal mask as a boolean condition, reversing key visibility and making the final prefill row entirely negative infinity. Softmax produced NaNs and greedy decoding repeatedly emitted token ID 0. Cast the mask to the MLA score dtype and add it to the scores; add exact mask-value and loaded-prefill finite-output regressions.

Integrate main c0ae26b2, including the mlxcelverse migration, MLX pin 243bdf09, and rustls security update. Bilingual reports preserve the original failure evidence and the fresh final-source validation.

Validation:

  • All ten Kimi CUDA tests, CUDA Clippy (--lib --tests, warnings denied), formatting, and diff checks pass. Earlier negative-control testing of the former mask semantics failed both new MLA regressions as intended.
  • Actual NVIDIA GB10 inference with mlx-community/Kimi-Linear-48B-A3B-Instruct-4bit, revision 919175d75427f1c10cfc17e7254b53295edddf72: five exact-answer controls pass. The 21-token prompt returns 4; the 3,411-token prompt returns AMBER-RAVEN-7429 with default and single-chunk prefill. Ordinary SDPA also passes the short and long cases.
  • Ordinary-SDPA generation produces 58 tokens in two coherent sentences explaining blue daytime skies and reddish sunsets. No token-0 collapse or repetition occurs.
  • Validated production source tree: 2e4f5211f42b21973d097a00ed60a7768d7f05ba; CLI SHA-256: 45753012854036e8b44d1adc622a6eba8bc9d15b601e098d340769581cb1a064. Subsequent changes add validation reports only. Earlier shared contracts passed 123 Python and 49 WebUI checks.

Review found no remaining blocking implementation, security, or performance issue. No performance claim is made from these correctness runs.

Closes #2292

Kimi Linear receives causal masks as additive 0/-infinity arrays. Interpreting those values as booleans reversed visibility and made the final prefill query softmax an entirely masked row, propagating NaNs into logits and recurrent decode state.

Cast each mask to the positional-score dtype and add it to the scores. Cover the exact mask rows and a real three-token MLA prefill whose final output must remain finite.
Document the additive-mask root cause, the controlled old-mask failures, and the pinned checkpoint's before-and-after token outputs in English and Korean.

Record the final source and binary identities, exact CUDA build graph, focused regressions, required chunk settings, and ordinary SDPA validation.
@inureyes inureyes added status:review Under review type:bug Bug fixes, error corrections, or issue resolutions priority:medium Medium priority area:models Model architectures, weights, loading, metadata area:inference Generation, sampling, decoding (incl. speculative, DRY) platform:linux Linux (CUDA / packaging) specific labels Oct 13, 2026
Add the completed shared contract gate to the bilingual report after all Python and WebUI checks pass.
Bring the Kimi causal-mask repair onto main’s new MLX pin and rebased CUDA, Metal, and ROCm overlays without changing the proven model source.

The existing model evidence remains tied to tested source 7c3f697 and binary b2cb19e0; the refreshed dependency graph requires a rebuild and checkpoint validation.
inureyes added a commit that referenced this pull request Oct 14, 2026
Record final CUDA route, combined-tree Kimi inference, and production-source Metal validation for PR #2304. Preserve source and binary provenance, independent #2296 attribution, and unavailable ROCm/M5 and deferred integration coverage.
inureyes added a commit that referenced this pull request Oct 14, 2026
## Summary

Advance MLX from `59d600b5` to captured upstream main `243bdf09` (111 commits, 312 files). Reconcile whole-file overlays to retain mlxcel's numerical behavior and runtime controls without overwriting upstream fixes.

- Rebase 11 CPU/CUDA/Metal overlays, retain 17 unchanged upstream-backed files and two helpers, and retire two overlays covered by upstream #4514 and #4554. Preserve CUDA chunking, gathered GEMM, dtype controls, and the #1599 Metal `B * M` correction; use upstream #4594 for Xcode 27.
- Retarget ROCm while preserving fork `75915908`. Adapt move-only allocation ownership, borrowed-storage donation safety, compiled callbacks, SDPA sinks, gated-delta fallback, floor division, and odd inverse FFT. Add actual-header host ownership regressions; these do not prove HIP completion ordering.
- Fix the new CUDA RHS route's device argument and add aligned MXFP4/MXFP8 reference coverage. Retain reviewed macOS filesystem test portability fixes from #2138.

## Validation

- Pin/parser (27), overlay tooling (29), ownership, provenance, contract gates, Python tooling (123), and formatting pass.
- Earlier CUDA compilation and 94 focused numerical executions pass. After the final overlay retirement, 45 numerical executions and two forced RHS runs pass; fresh PTX proves f16/bf16 × MXFP4/MXFP8 route execution.
- [Earlier Metal CI on production source `3aeccc2b`](https://github.com/lablup/mlxcel/actions/runs/38492190049): fmt/Clippy pass; 12,285 tests pass, 390 ignored; 51 FFmpeg video tests pass.
- Actual GB10 Kimi 48B-A3B 4-bit inference passes three focused tests, five exact short/long controls, and a coherent 58-token explanation. This uses combined source `53473340` = production `3aeccc2b` + independent #2296 mask fix `1fec677b`; that model fix is not included here. CLI SHA-256: `b52d70388e0420582c4f60f3341d570c2afd736685b37e2c0c6e50ed9eaf5fae`.

ROCm compilation/runtime and M5-specific execution remain unavailable. Ordinary PR CI is tracked separately; queued checks are not passes. The requested whole-batch CUDA/Clippy and fresh main Metal integration gate remains deferred until the expanded follow-ups are ready. This PR does not independently close #1599, #2158, or #1986. English/Korean technical reports record provenance and remaining limits.

Latest main `59974283` is integrated, including the mlxcelverse layout migration. Resolve three rename/delete or relocation conflicts, update ownership-test paths and ROCm record numbering, and preserve main's ROCm/MoE improvements. Post-merge CUDA compilation, contract/ownership/provenance gates, Python tests, and 112 focused test executions pass, including directly forced RHS kernels. CUDA library suites on the merged production source pass 11,247 tests (170 ignored); full CUDA workspace/all-targets Clippy and CPU-only linking pass on final `4befdbc7`. The CUDA block-float archive audit and six quantization tests pass. Upgrade rustls from 0.23.45 to 0.23.46 to resolve RUSTSEC-2026-0346 through 0349; local and hosted cargo-deny pass. [Final Metal CI at `4befdbc7`](https://github.com/lablup/mlxcel/actions/runs/38583586205) passes fmt, Clippy, 12,315 workspace tests (390 ignored), and 51 FFmpeg video tests. Earlier actual Kimi results retain their original source attribution.

Closes #2303
Merge current main and preserve the additive MLA mask correction through the mlxcelverse migration. Record fresh final-source validation rather than relying on the earlier combined-build evidence.

Ten Kimi CUDA regressions and six actual 48B checkpoint inference controls pass, including long-context recall and coherent ordinary-SDPA text generation. Formatting and diff checks pass.

Refs #2292
Merge main c0ae26b after its report-only update. Production source remains identical to the Kimi inference and CUDA regression artifacts already validated.

Refs #2292
@inureyes
inureyes merged commit d3cf28a into main Oct 14, 2026
27 checks passed
@inureyes
inureyes deleted the fix/issue-2292-kimi-cuda-inference branch October 30, 2026 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:inference Generation, sampling, decoding (incl. speculative, DRY) area:models Model architectures, weights, loading, metadata platform:linux Linux (CUDA / packaging) specific priority:medium Medium priority status:review Under review type:bug Bug fixes, error corrections, or issue resolutions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(kimi_linear): diagnose CUDA token-zero degeneration

1 participant