Repository navigation
MiMo V2.6 Flash: native runtime, embedded MTP and qualification - #171
Conversation
Split the expert-reduction fixture expression so CI can compile it. Verify the immutable public artifact using pinned per-file checksums instead of a private manifest, and bind portable-state tests to the current source-matched Metal library. Validated: test bundle build; 11 focused artifact/expert tests; full-artifact portable-state live test with exact encoder and denoiser state after reload.
|
@codex review this |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 20a60e6f64
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| guard low.rounded(.towardZero) == low, high.rounded(.towardZero) == high, | ||
| low < Double(Int.max), high < Double(Int.max), samplesPerSecond > 0 else { throw Failure.invalidVideo } |
There was a problem hiding this comment.
Reject inverted video sampling bounds
Reject configurations whose effective even minimumFrames exceeds maximumFrames. Both this configuration path and the public initializer currently accept such bounds; indices then applies max(..., minimum) followed by min(..., maximum), so values such as minimumFrames: 10, maximumFrames: 8 silently return 8 frames and violate the declared minimum. Even equal odd bounds such as 9/9 become an effective 10/8 pair after rounding, so validation should compare the rounded bounds before sampling.
Useful? React with 👍 / 👎.
| public struct Limits: Sendable { | ||
| public let maximumPixels, maximumWorkingBytes, maximumSourceFrames, maximumSampledFrames: Int | ||
| public init(maximumPixels: Int, maximumWorkingBytes: Int, | ||
| maximumSourceFrames: Int, maximumSampledFrames: Int) { | ||
| self.maximumPixels = maximumPixels; self.maximumWorkingBytes = maximumWorkingBytes | ||
| self.maximumSourceFrames = maximumSourceFrames; self.maximumSampledFrames = maximumSampledFrames |
There was a problem hiding this comment.
Bound encoded visual payloads before decoding
Add an encoded-byte ceiling to the visual limits and enforce it before invoking the platform decoders. For user-controlled images, image passes the entire Data to ImageIO before any resource check, while the later maximumWorkingBytes calculation covers only raster and Float buffers; a tiny-dimensional file padded with huge metadata or ancillary chunks can therefore force unbounded parsing and retained input bytes while still satisfying every current limit. The video inspection path similarly opens and scans its complete memory-backed owner before its later decode working-bound check.
Useful? React with 👍 / 👎.
Reconcile the latest SDK main while preserving native MiMo state ownership, serial MTP verification, encoded-media bounds and startup rollback controls. Import the reviewed release candidate tree without private staging history.
Apply the exact changed-PR-file procedure from Lint run 36516169667, job 109238811421, over base 7167841 and head 4776926. CI Xcode 26.6 reports swift-format 6.3.0; use the same formatter version from the local CLT without changing xcode-select. Of 237 scoped Swift paths, 226 require formatting. All 226 formatted blob prefixes match the afterimages emitted by CI. A repeated same-tool pass is idempotent and git diff --check passes. Normalized token skeletons match across all changed files after the enabled style-rule rewrites; import sets and production quoted segments/multiline string payloads remain unchanged. No manual production policy or test assertion edits. Formatting-only CPU validation; no compiler, model, native test or runtime qualification executed. Existing runtime evidence and remaining qualification gates are unchanged.
Gajesh2007
left a comment
There was a problem hiding this comment.
Reviewed for regressions to existing models at c300cc9.
Local validation on Apple M4 Max / Swift 6.3.3: 478 tests across 66 explicitly selected suites passed, with zero failures and zero skips. Built the unchanged PR head and rebuilt/staged the full Metal library from pinned MLX source 3fa8f25e6451174d7b06be372c3a24272b77d88e. Each suite ran in a fresh process through scripts/run-nested-suite.sh with an exact suite filter and --no-parallel.
Coverage includes Gemma attention/shared vision/MTP, Qwen construction/positioning/paged execution/checkpoints, shared MTP parity and mixed requests, KV dtype/allocation, prefix reuse, checkpoint retention, and windowed-row retirement. No existing-model regression was found in this scope.
Approval is scoped to existing-model regression risk. MiMo-only correctness issues are accepted for follow-up by the maintainer. This run does not clear the existing full-suite CI failures or establish full-model/performance qualification.
This is a measurement branch. Do not merge it. origin/main decodes an input_audio content part as .inputAudio since #171. The test of #181 still expected .unsupported, so the run had one failure. This commit expects the audio part, and checks .unsupported with input_file. PR #181 needs the same change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since #171, main decodes an input_audio content part as .inputAudio. The test still expected .unsupported. Assert the .inputAudio value and keep the unsupported-type check with input_file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
…ormat (#181) * 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> * style: format HistoricalWindowCheckpointTests.swift Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * 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> * test: add test types and a unit test step without the Metal library Add the Swift Testing tags unit, kernel, integration and reference in Tests/MLXLMTests/TestTypeTags.swift, and the UnitTests parent suite that gives the unit tag to the suites under Tests/MLXLMTests/Unit. Fork Tests runs the unit tests before it builds the Metal library. swift test cannot select tests by tag, so the step selects the UnitTests suite by name. CONTRIBUTING.md describes the four types. Add two example unit suites for JSONValue and ToolCall.execute. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: select the UnitTests suite of every test target Other test targets, such as MLXLMServerTests, can then add unit tests with their own TestTypeTags.swift and no change to the workflow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: add unit tests for the MLXLMServer CLI, protocol and response format Add TestTypeTags.swift with the UnitTests suite to MLXLMServerTests, and unit suites for: CLI argument and environment parsing, the model folder or id decision, OpenAI message, tool, tool choice, completion and embedding decoding, response shaping (usage, chunks, completions, models, SSE frames, error descriptions), server metrics with fixed dates, and the response_format instruction and JSON schema checks. No test loads a model or uses MLX arrays or the network. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: apply review fixes to the test type convention - Delete every cached *.metallib, not only mlx.metallib, before the build and before the cache is saved, so the unit step guard sees the same set of files. - The guard prints the found libraries, then one ::error:: line. - Add scripts/check-unit-test-files.sh: it fails when a Swift file under Tests/<Target>/Unit/ has no extension UnitTests. The unit step runs it, and scripts/test-run-nested-suite.sh proves it red on a bad file. - CONTRIBUTING.md: folders for each test target, the sentence on files without a type tag, and the section Xcode integration tests. - fork.yaml: unit tests are under Tests/<Target>/Unit/ for each test target; describe the new script. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: fail when the tag declarations of two test targets differ MLXLMServerTests has its own copy of TestTypeTags.swift. scripts/check-unit-test-files.sh now compares the tag and UnitTests declarations of each copy with Tests/MLXLMTests/TestTypeTags.swift. scripts/test-run-nested-suite.sh proves the check red on a copy with another tag. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: expect input_audio to decode as .inputAudio Since #171, main decodes an input_audio content part as .inputAudio. The test still expected .unsupported. Assert the .inputAudio value and keep the unsupported-type check with input_file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Gajesh Naik <26431906+Gajesh2007@users.noreply.github.com>
#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>
Ready for code review: native
mimo_v2support. Ordinary full-model loading is confirmed on both tested Macs. Known reasoning-off framing and remaining qualification items below are retained for follow-up; review-ready does not mean every deployment gate passed.Changes
verify: .allchecks are unchanged.Before
After
Blue: owned work; green: confirmed completion; amber: retained failure.
Validation and remaining gates
Earlier component evidence: 114 passed, 0 failed, 0 skipped; 147 discovered, 33 unselected. The exact historical scope is not the full SDK/provider suite or final-composition qualification.
The updated optimized production provider CLI build passed on M5 with the SDK integration. A provider build does not compile the SDK's own four test targets; SDK whole-target compilation/execution remains a separate gate.
The prior full-artifact load failure was
MLXNN.UpdateError.incompatibleItemsatencoder.down_sample_layer: checkpoint array versus wrapper module. The indexed-array fix is included; two new real-array loader regressions passed, zero failures/skips, including exact transpose values and strict malformed-weight refusals. Corrected ordinary full-model loading, listener startup and actual AUTO serial-MTP activity succeeded on both tested Macs.The separately labelled clarified eight-case M5 smoke is 1 passed, 1 failed, 6 unrun. The failed reasoning-off arithmetic response exposes an implicit
</think>boundary. Its OFF prompt/control mapping is correct; this is not a cleared API gate. The remaining tool/image cases were not executed by that stop-on-failure run. Parser follow-up and the full local OpenRouter-compatible matrix remain separate work.The corrected production provider build passed; all four candidate SDK Debug test targets compiled. This is not a full SDK-suite execution. No model weights, numerical settings or MTP defaults changed.
The companion provider fixes MiMo's incorrect Qwen-only footprint recheck and preload → listener startup without replacing healthy owners. Seven focused provider regressions passed, zero failures/skips, including actual native publication, listener start and retirement. This is not a full-model API or full SDK-suite pass.
Earlier full-model OFF/serial-MTP output IDs agreed, but serial MTP was slower. Complete target/head/cache state and rollback remain open; the retained rectangular mismatch begins at output token 38.
Performance research is paused. No completed current M3 full-model benchmark, optimized-reference parity or speedup is claimed.
Source attribution/license notices and scoped historical evidence retained.
SDK test-only compilation corrections included, without a production-kernel change.
Full four-target SDK compilation and suites, provider suites and applicable native opt-ins on final sources.
Seven focused companion-provider startup/load regressions passed.
Final ordinary production-default validation.
Complete full-model greedy/state/rollback/continuation and paging/cache composition.
All 146 authenticated text/tool/reasoning API cases; separate media/audio, persistence, concurrency and lifecycle coverage.
Final independent review, settled CI and all required end-to-end release gates.
Artifact and dependencies
The unchanged public MiMo V2.6 Flash MOPD artifact remains at
bb37ffc73180a94d2f903ae2c794665135e38d83, with the existing R2/CDN manifest. Availability is not a runtime or quality result; no weights or precision changed.Companion provider: d-inference #1234. MLX Swift
0f4fe403bef6899e8a72882bc6d4036a7a62ae31, MLX3fa8f25e6451174d7b06be372c3a24272b77d88eand mlx-c02cf6f4d099023e4e0c0357248b8b3f83110e29dremain unchanged. No catalog, pricing, minimum-memory-tier or deployment activation is requested by this SDK diff.Rollback
Explicitly disable MTP or use its process kill switch; restart with the documented attention/grouping controls set to
0to restore the prefill fallback. Keep unqualified experiments disabled. Revert provider integration and its SDK pin together before removing support; do not reuse stale prompt-contract metadata.