Skip to content

fix: restore Gemma 4 31B MTP exactness - #1987

Merged
inureyes merged 2 commits into
mainfrom
fix/issue-1983-gemma4-mtp-exactness
Sep 26, 2026
Merged

inureyes merged 2 commits into
mainfrom
fix/issue-1983-gemma4-mtp-exactness

Conversation

@inureyes

@inureyes inureyes commented Sep 26, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Restore Gemma 4 31B QAT/non-QAT singleton linear MTP exactness by matching classic attention key order, mask dispatch and prefill chunks. Preserve ring metadata across rollback and parking; decline unsupported batch/tree layouts and buffered prompt-cache donation.
  • Add failure-only layer/sub-operation localization, a 31B long buffered startup probe, and once-per-process short-mask warnings. Other Gemma geometries retain their original startup draws.
  • Replace historical unconditional speedup guidance with measured results and correct Qwen text-only MTP documentation.

Test plan

  • Full local make verify, plus the explicitly ignored buffered-donation regression: pass. Final 12B startup also passes its retained short gate after the automatic narrow retry.
  • Both 31B targets: three 256-token greedy comparisons match classic; 1,536-token-prefix teacher traces at width 4 give 0/256 top-1 disagreements and zero sampled logit deltas. Decided-position disagreements at gap >=2 are 0/79 QAT and 0/161 non-QAT. Non-QAT startup widths 2/3/4 pass without an inexact override.
  • Recreated QAT long workload: 6,449 input / 513 output tokens match classic; acceptance improves 35.86%→40.11%, emitted tokens per verification 2.073→2.197.
  • Gemma 3/Qwen 2.5 classic outputs match before/after. Qwen 3.8 MTP before/after/classic all match for 256 tokens; acceptance remains 164/274.

Measurements and reproduction: benchmark report. Test-fast throughput varies by prompt and host state; no unchanged-throughput claim. GB10/CUDA and Qwen 3.6 MTP remain unvalidated (host inaccessible / no compatible local drafter). The experimental 12B long-context mismatch is tracked separately in #1986.

Maintainer approved merging with the three GB10-only CI jobs (cargo-clippy, OpenXLA feature compile, WebUI installed artifact) still queued and unvalidated. All other active checks passed; the full local Metal gate passed.

Closes #1983

Closes #1279

Gemma 4 31B MTP compared multi-token verification with single-token decode using different full-attention, sliding-ring, and long-prefill arithmetic, causing the exactness gate to decline QAT and non-QAT checkpoints.

Reproduce decode attention per query row for the measured 31B geometry, preserve reference-ring metadata across cache lifecycle operations, match scheduler prefill chunks, and localize failed probes. Add focused regressions and M5 Max evidence for both 31B checkpoints, shared-cache consumers, and Qwen 3.8 MTP.

Validation:
- Formatting, staged diff checks, and measurement-harness syntax checks passed.
- M5 Max QAT/non-QAT parity, Gemma 3 and Qwen 2.5 classic smoke checks, and Qwen 3.8 MTP regression checks passed.
- CUDA validation was unavailable because the GB10 host could not be accessed.

Refs #1983, #1279
@inureyes inureyes added status:review Under review type:bug Bug fixes, error corrections, or issue resolutions priority:medium Medium priority area:inference Generation, sampling, decoding (incl. speculative, DRY) platform:macos macOS (Apple Silicon) specific labels Sep 26, 2026
Record the Gemma 4 31B exactness decisions, validation evidence, performance limits, and open backend and model follow-ups in English and Korean. Add the final Unified 12B short-probe pass to the benchmark report and machine-readable evidence.

Validation:
- JSON parsing and diff checks passed.
- Full make verify and the direct buffered-cache donation regression passed before report generation.

Refs #1987, #1983, #1279, #1986
@inureyes inureyes added status:done Completed and removed status:review Under review labels Sep 26, 2026
@inureyes
inureyes merged commit 144750e into main Sep 26, 2026
17 of 20 checks passed
@inureyes
inureyes deleted the fix/issue-1983-gemma4-mtp-exactness branch September 26, 2026 14:20
inureyes added a commit that referenced this pull request Sep 26, 2026
## Summary

A plain macOS Cargo build enabled MLX Metal but compiled the runtime QMV setter as a no-op because its bridge used the optional Cargo feature instead of the actual backend setting. This explains the reported automatic-retry failure despite a fresh `MLXCEL_QMV_WIDE=0` process passing.

- Resolve Metal once for CMake and both bridge controls, preserving explicit Metal-OFF and native non-macOS behavior.
- Preserve initial and retry verdicts in warnings and cached decline reasons, including operator-pinned and unavailable-backend cases.
- Document the old-binary workaround and add build-policy tests plus a real runtime-control probe.

## Test plan

- Full local `make verify`: passed; after the final test-only adjustment, the affected 16-test suite passed with QMV unset, pinned to 0, and pinned to 1.
- Release build without `--features metal,accelerate`: real QMV false/true and command-buffer control assertions pass.
- Gemma 31B QAT: automatic retry and fresh narrow startup pass; 64 generated tokens match each other and the explicit-Metal release baseline. Acceptance is 33/84 in both fixed arms.
- Qwen 3.8 MTP: both startup modes pass at block 3; 64 generated tokens and acceptance 35/52 match.

Runtime validation used M5 Max. The user's original failure and fresh-narrow pass were on M5 Ultra; the corrected binary has not been run there. Cross-host compilation and physical Metal-OFF/CUDA execution remain unvalidated. This changes build wiring and diagnostics, not attention arithmetic.

GB10-only CI remains unverified because its runner is unavailable; merge follows the user-approved exception for this investigation.

Closes #1988

Refs #1987.
@inureyes inureyes added this to the 0.8 milestone Nov 30, 2026
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) platform:macos macOS (Apple Silicon) specific priority:medium Medium priority status:done Completed type:bug Bug fixes, error corrections, or issue resolutions

Projects

None yet

1 participant