Repository navigation
test(granitemoehybrid): validate the MoE mode on granite-4.0-h-tiny against mlx-lm - #3744
Open
Jaeyeong-CHOI wants to merge 1 commit into
Open
Jaeyeong-CHOI wants to merge 1 commit into
Jaeyeong-CHOI wants to merge 1 commit into
Conversation
…gainst mlx-lm Teacher-force mlx-lm's 64-token greedy continuations of a 26-token and a 494-token prompt on mlx-community/granite-4.0-h-tiny-4bit and require the reference token at or near mlxcel's maximum logit at every step. Replace the docs sentence that said the MoE mode awaited a public checkpoint.
This branch has not been deployed
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.
Summary
Closes #3742.
Validates the Granite 4 hybrid MoE mode (
granitemoehybridwithblock_sparse_moe+shared_mlp) against mlx-lm on the publicmlx-community/granite-4.0-h-tiny-4bit, pins it with a real-checkpoint test, and replaces the stale sentence indocs/supported-models.mdthat said the mode "awaits a public MLX checkpoint to validate". No defect was found, so there is no runtime code change.What changed
tests/granitemoehybrid_moe_parity.rs(new): loadsgranite-4.0-h-tiny-4bit(revision02c8783d: 40 layers, 4 of them attention, 64 experts, top-6,shared_intermediate_size1024), asserts it is the MoE + shared-MLP variant, then teacher-forces mlx-lm's 64-token greedy continuation of a 26-token and a 494-token chat prompt (the long one carries the Mamba2 state across a whole prefill before decode). At every step the mlx-lm token must sit at most 1.0 below mlxcel's maximum logit, and it must be the argmax at 90% of the steps or more. Skipped when the checkpoint is absent, a failure underMLXCEL_REQUIRE_MODELS=1;MLXCEL_TEST_GRANITE4_MOE_DIRnames the directory explicitly.docs/supported-models.md: the Granite 4 entry names the validation checkpoint and the test instead of saying the mode awaits one, and states the result with its scope: argmax at every step with the default fused MoE kernel on CUDA, 63/64 on the long prompt withMLXCEL_FUSED_MOE=0, Metal not measured against mlx-lm. Thegranitemoehybrid.rsmodule doc names the MoE checkpoint next to the dense one.Why teacher forcing rather than a free-running greedy comparison
A free run against mlx-lm parts at near-ties, and one flip there changes every later token, which measures rounding rather than the model. On
main:MLXCEL_FUSED_MOE=0)With the fused single-token MoE kernel (the default) the 494-token free run matches all 64 tokens; the 26-token one parts at the same step 43.
Verification (NVIDIA GB10, sm_121, CUDA 13; mlx-lm 0.32.2, mlx 0.32.5; Rust 1.97.1)
Reference ids: mlx-lm greedy decode on the same checkpoint from the same prompt ids (a prefill, then single-token argmax steps, no EOS stop), via
mlx_lm.loadand the model's own prompt cache.New test, on this branch (
MLX_ENABLE_TF32=0 MLXCEL_REQUIRE_MODELS=1 MLXCEL_TEST_GRANITE4_MOE_DIR=... cargo test --profile test-fast --features cuda --test granitemoehybrid_moe_parity -- --test-threads=1 --nocapture):MLXCEL_FUSED_MOE=0Without the checkpoint and without
MLXCEL_REQUIRE_MODELSboth tests skip and pass.The test is not vacuous. With the
shared_mlpterm dropped from the MoE feed-forward (FeedForward::Moereturning the routed experts' output alone; a local edit, not part of this PR) and the test rebuilt, both cases fail: on the 494-token prompt mlx-lm's token is mlxcel's argmax at 21 of 64 steps and the largest deficit is 16.5 (step 0); on the 26-token prompt it is 24 of 64 and 14.35 (step 45).Teacher-forced logit traces over
docs/architecture.md(scripts/mlx_lm_logit_trace.pyvs thelogit_traceexample, compared withscripts/compare_logit_traces.py), onmain:MLXCEL_FUSED_MOE=0Every disagreement is at a position where mlx-lm's own top two are within 0.5.
Gates on this branch. They ran on the tree before the last revision of this PR, which changed only the Granite 4 sentence of
docs/supported-models.md(the scope of the result, above); no code or test differs from the gated tree.cargo fmt --all -- --check: clean.cargo clippy --locked --workspace --all-targets --features cuda -- -D warnings: clean.make verify-test-cudasuite (cargo test --workspace --profile test-fast --features cuda --no-fail-fast -- --test-threads=1), run one test target at a time with the same profile, features and flags (themlxcelandmlxcel-corelib targets split into groups by top-level module,--exact), totals summed from libtest's per-target summaries: 200 targets, 18,888 passed, 2 failed, 568 ignored (19,458, the number of listed tests); doctests 3 passed, 10 ignored. The new test file runs (and skips, without the checkpoint) inside that suite.tests/mlx_test_guard_coverage.rs::mlx_evaluating_lib_tests_take_mlx_test_guard(it flagssrc/vision/encoders/nemotron_h_nano_omni_tests.rs:276) andtests/step3p7_parity.rs::text_decode_delegates_sequence_local_native_batching(assertion failed: !wrapper.supports_padded_prefill()). Both fail identically on unmodifiedmain(9402cf8); they are the two stale tests test: fix two stale tests that keep make verify-test red #3720 fixes.python3 scripts/ci/check_used_by.pyandbash scripts/ci/check_used_by_test.sh: pass. The otherscripts/ci/check_*.pyandscripts/ci/*_test.shpass exceptcheck_helm_chart.pyandhelm_chart_package_test.sh, which need ahelmbinary the test machine does not have.git merge-tree --write-tree origin/main <branch>: clean against 9402cf8.Limits
granite-4.0-h-small, 8-bit exports and Metal were not compared with mlx-lm. The existing Metal M5 vs ROCm h-tiny traces (test(rocm): complete the #1809 matrix rows with Metal M5 traces #2083) compare two mlxcel backends, not mlxcel with mlx-lm.docs/supported-models.md; whichever lands second needs a trivial rebase. No CHANGELOG entry: that is written at release time.