test(mlx-fused): refresh stale fused-loop test fakes and expectations#147
Merged
FluffyAIcode merged 1 commit intoJun 17, 2026
Merged
Conversation
…ainst current behavior The control-flow tests in test_fused_specdecode.py were stale against the current fused_specdecode_generate loop, failing on origin/main: - _FakeAdapter lacked last_aux_torch_slice, which the loop now calls (aux is captured lazily in MX and bridged on demand) -> AttributeError. Add it. - Full acceptance no longer appends a correction token (it reuses block_logits[-1] as the next distribution), so the committed token sequence shifted: test_fused_loop_full_acceptance appends == [104] (not [103,105]); test_fused_loop_stops_on_eos reaches EOS as block-2's bonus -> blocks == 2. - test_adapter_prefill_forward_commit: forward_block now leaves _last_aux None and exposes the bridged aux via last_aux_torch_slice(); assert accordingly. - Add test_fused_loop_greedy_fallback_on_low_acceptance to cover the low-acceptance greedy-fallback branch (previously untested). All 14 tests pass; no production code changed. Co-authored-by: FluffyAIcode <FluffyAIcode@users.noreply.github.com>
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
Fixes 4 pre-existing failing tests in⚠️ pre-existing failures" noted in PR #146.)
tests/backends/mlx/test_fused_specdecode.pythat had gone stale against the currentfused_specdecode_generateloop. Test-only change — no production code touched. (Surfaced as the "Why they were failing (verified red on
origin/main)The fused loop evolved but its unit-test fakes/expectations did not:
adapter.last_aux_torch_slice(...)(aux hidden states are captured lazily in MX and bridged to torch on demand), but_FakeAdapterlacked it →AttributeErrorin all 3test_fused_loop_*tests.block_logits[-1]as the next distribution instead of forwarding a correction token, so committed sequences shifted:test_fused_loop_full_acceptance:appends == [104](was[103, 105]).test_fused_loop_stops_on_eos: the EOS token now arrives as block 2's bonus →blocks == 2(was1);tokensunchanged ([100,101,102,103]).forward_blocknow leaves_last_aux = Noneand exposes the bridged aux vialast_aux_torch_slice();test_adapter_prefill_forward_commitnow asserts that contract.Changes
last_aux_torch_sliceto_FakeAdapter(mirrorsMLXRestoredIncrementalVerifier).appends/blocksfor the 3 loop tests against current behavior (full traces in the test comments).test_adapter_prefill_forward_committo the lazy-aux contract (_last_aux is None; bridged vialast_aux_torch_slice()).test_fused_loop_greedy_fallback_on_low_acceptancecovering the low-acceptance → greedy-fallback branch (previously untested).Testing
pytest tests/backends/mlx/test_fused_specdecode.py→ 14 passed (was 9 passed / 4 failed onmain)inference_engine.backends.mlx.*is enforced on the Mac integration run (the MLX-real paths can't import on the Linux CI host, per.coveragerc); this PR raises the Linux-exercisable loop coverage and fixes the red tests.