Skip to content

test(mimo): assert the MiMo contracts that #171 shipped - #211

Merged
Gajesh2007 merged 1 commit into
mainfrom
test/mimo-stale-contract-assertions
Oct 2, 2026
Merged

Gajesh2007 merged 1 commit into
mainfrom
test/mimo-stale-contract-assertions

Conversation

@davidtai

Copy link
Copy Markdown

Proposed changes

Fixes two of the six tests that fail in the whole-package pass of Fork Tests on main (run 36741368847, run 36769006274 on 0871943):

  • MiMoV26CBv2Tests.testNativeContiguousAdapter
  • MiMoV26MTPEngineTests.testRequestIsolationMeasuredOwnershipAndRelease

Kind of fix: wrong test assumption. No production change. #171 added the tests and the production code together. Three assertions disagree with contracts that #171 itself shipped and that other tests assert:

Test (file:line) Error Production fact Evidence
MiMoV26CBv2Tests.swift:143-145 cache capability widened MiMoV26ContiguousLayerCache conforms to CBv2MTPRectangularSerializing (MiMoV26CBv2.swift:181-182), so bank.supportsMTPRectangularVerification is true MiMoV26RectangularVerifyTests.swift:274-275 asserts it is true. EngineV2.swift:329-333 reads it only when supportsMTP is true, and the test already asserts supportsMTP is false.
MiMoV26CBv2Tests.swift:266-268 intermediate constructed vocabulary logits .evaluationOnly returns hidden.sum(axes: [1, 2]).reshaped(-1, 1), shape [1, 1] (MiMoV26CBv2.swift:1176-1181) The contract is [B, 1] (EngineLoopV2.swift:3560, and the generic path returns logits[0..., -1, 0 ..< 1]). The lm_head spy check still passes: no vocabulary projection.
MiMoV26MTPEngineTests.swift:345 XCTAssertFalse failed MiMoV26MTPAssistant conforms to CBv2HistoricalMTPPrefixCheckpointCoding (MiMoV26MTPPrefixCheckpoint.swift:48), which refines CBv2MTPPrefixCheckpointDrafter MiMoV26MTPPrefixCheckpointTests (prefixCheckpointTensorDescriptors) and MiMoV26NativePrefixProducerTests (prefixCheckpointCodecID) use this conformance.

The changes keep each check and assert the shipped contract: packed-prefill and span capabilities must stay off, rectangular serialization must stay on, the intermediate handle must be [1, 1] with no readout, and the assistant must use the priced historical prefix checkpoint codec.

Why these tests fail only since #178

The tests were added in #171. On #171 (run 36617213525, fe71e37) the whole-package pass stopped early: the xctest process crashed in CBv2AsymmetricPagedStorageTests with Fatal error: process charge retirement refused. That suite runs before CBv2PagedAttentionWorkReservationTests and the MiMo* suites, so those suites never ran. #178 fixed that crash, and from eeba2af on the pass reaches these suites for the first time. The failures are not from #178 or #188. They also fail the same way on an M5 laptop, so the hosted runner (M1, 7 GiB, 3 cores) is not the cause.

Evidence

Local run (M5, MLX_ENABLE_TF32=0, staged full metallib): on origin/main the same three errors as CI; with this change MiMoV26CBv2Tests and MiMoV26MTPEngineTests have 0 failures (the native-lane tests in MiMoV26MTPEngineTests are separate; #192 handles them).

Checklist

  • I have read the CONTRIBUTING document
  • I have run swift format on the changed files
  • I have added tests that prove my fix is effective or that my feature works (the fix is in the tests)
  • I have updated the necessary documentation (if needed) (not needed; fork.yaml already covers the files, check_forkdiff.py passes)

🤖 Generated with Claude Code

Three assertions in the MiMo tests disagree with the code that the same
PR (#171) added:

- The MiMo cache conforms to CBv2MTPRectangularSerializing, and
  MiMoV26RectangularVerifyTests asserts that the bank supports
  rectangular MTP verification. The test asserted the opposite.
- CBv2PrefillRequirement.evaluationOnly returns a [B, 1] handle
  (EngineLoopV2.prefillOutput). The test expected shape [1].
- MiMoV26MTPAssistant conforms to
  CBv2HistoricalMTPPrefixCheckpointCoding (MiMoV26MTPPrefixCheckpoint).
  The test asserted that it is not a prefix checkpoint drafter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Gajesh2007
Gajesh2007 merged commit 5e9d268 into main Oct 2, 2026
5 of 6 checks passed
@davidtai
davidtai deleted the test/mimo-stale-contract-assertions branch October 4, 2026 21:58
Gajesh2007 added a commit that referenced this pull request Oct 4, 2026
#289)

* fix(cache): preserve demanded fork checkpoints and bound short capture

* test: let expected paged work refusals reach the caller (#209)

PagedWorkFixture.prepare wrapped prepareAttentionWork in XCTUnwrap.
XCTUnwrap records a test failure when its expression throws, also
when the caller expects the throw with XCTAssertThrowsError. Three
tests expect prepare to refuse, so each expected refusal was recorded
as a failure. prepare now throws the refusal to the caller and fails
only when prepareAttentionWork returns nil.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit b7bbdc2)

* fix(paged): write a full destination for broadcast direct KV (#210)

Materialize broadcast retained KV into a complete contiguous destination while preserving bit values, ownership validation, and reservation bounds. Focused differential paging, lifetime, and bit-exact validation completed during review.

(cherry picked from commit 3799b11)

* test(mimo): skip native-lane tests on machines without the lane (#192)

Since eeba2af (#178), 31 XCTest cases in five MiMo suites throw
nativeLaneRequired on the hosted CI runner, so every run of Fork Tests
on main fails. The tests need the exclusive native GPU lane, which the
runner does not have.

This change turns each of those throws into an XCTSkipUnless on the
same environment variables. The tests now skip, with the reason, on a
machine without the lane, and run as before where the variables are
set. The unused nativeLaneRequired enum case is removed from each
suite.

Tests only. No production code change.

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
(cherry picked from commit c288f53)

* test(mimo): assert the MiMo contracts that #171 shipped (#211)

Three assertions in the MiMo tests disagree with the code that the same
PR (#171) added:

- The MiMo cache conforms to CBv2MTPRectangularSerializing, and
  MiMoV26RectangularVerifyTests asserts that the bank supports
  rectangular MTP verification. The test asserted the opposite.
- CBv2PrefillRequirement.evaluationOnly returns a [B, 1] handle
  (EngineLoopV2.prefillOutput). The test expected shape [1].
- MiMoV26MTPAssistant conforms to
  CBv2HistoricalMTPPrefixCheckpointCoding (MiMoV26MTPPrefixCheckpoint).
  The test asserted that it is not a prefix checkpoint drafter.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 5e9d268)

* test: run bit-exact reference tests only on reference hardware (#174)

* style: format DiffusionGemmaVisionOracleTests.swift

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* style: format DiffusionGemmaFactoryTests.swift

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test: run bit-exact reference tests only on reference hardware

Nine DiffusionGemma tests compare float bits with frozen references.
On the hosted macos-26 runner (Apple M1 VM) they differ in the low bits,
with no change in shape, dtype or sign. Add a `.referenceHardware`
Swift Testing trait that runs a test only when MLX_REFERENCE_HARDWARE=1,
and mark the nine tests with it. Elsewhere they report as skipped with
the reason. No assertion, tolerance or reference changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test: gate only the bit comparisons of mixed DiffusionGemma tests

Three gated tests also held checks that pass on any hardware. Split them
so only the bit-for-bit comparison is gated:

- prefixIdentityTokensOwnerAndEmptyStateFailClosed() runs its
  fail-closed probes on all hardware. The donor-logits bit comparison
  moves to failClosedProbesLeaveDonorLogitsBitExact().
- nativeFactoryLoadsExactStateAndReleasesItsModel() keeps the load and
  model-release checks on all hardware. The logits bit comparison moves
  to nativeFactoryDenoiseMatchesReferenceBits().
- The two parameterized vision tests run their bf16 case on all
  hardware. The fp32 case moves to a separate gated test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test: gate only the reference comparisons of three more DiffusionGemma tests

Split the three tests that were still gated whole, so their checks that
pass on any hardware run everywhere:

- chunkedSessionBoundsPrefillAndCanCancelAfterPrefill() keeps the
  prefill bounds, the complete flag, the counters, cancel, the emitted
  checkpoint and the released cache for widths 1, 3 and 7. The KV and
  logits bit comparisons move to chunkedSessionMatchesIndependentNativeReference().
- sharedWeightsConditioningKeepsCommittedCacheState() keeps the fixture
  checks, both cache positions and the unchanged encoder KV after the
  provisional canvas. The reference comparisons stay in
  sharedWeightsConditioningAndCommittedCacheMatchReference().
- committedPrefixRestoreKeepsPositionsAfterDonorRetirement() keeps the
  token count, retained bytes, donor release and both positions. The
  reference comparisons stay in
  committedPrefixRestoreIsExactAfterDonorAppendAndRetirement().

Each pair shares one helper. The fixture reference, case-count and
parameter-count checks of the block and fp32 vision fixtures also run
everywhere now, in blockOracleFixtureIsPinned() and fp32FixtureIsPinned().
CONTRIBUTING.md says which comparisons the gate covers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit a046367)

* docs: describe demanded checkpoints and their shared fixture

* fix(cache): honor request participation in short checkpoint scheduling

* Preserve demanded checkpoint eligibility through preemption and packing

* test: size the slot-cap request from what the ledger accepts

slotCapLeavesRoomForServing() sized its request from bytesReserved.
bytesReserved includes the paged pool's physical-floor overhead, which a
request's target KV replaces when it reserves. The overhead depends on
the buffer sizes the MLX allocator returns: a 36,864-byte segment gets a
49,152-byte buffer, or a 65,536-byte buffer reused from the process-wide
cache. When earlier work left 64 KiB buffers in the cache, the capped
arm left more than 5.5 windows of real slack instead of half a window,
and the uncapped arm's reservation fit.

Find the largest request the ledger accepts beside the capped set with
trial reservations, then take half a window off it. The assertions do
not change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 06224a8)

* Retain demanded native frontiers and preserve observed prefill endpoints

* Document current SDK parameters and generation links

* Disambiguate the task generation documentation link

---------

Co-authored-by: David Tai <dtaipublic@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants