Skip to content

Preserve MiMo paged histories through rollback and phase transfer - #344

Closed
jonathan308 wants to merge 3 commits into
fix/cluster-independent-history-batchingfrom
fix/cluster-mimo-paged-history
Closed

jonathan308 wants to merge 3 commits into
fix/cluster-independent-history-batchingfrom
fix/cluster-mimo-paged-history

Conversation

@jonathan308

@jonathan308 jonathan308 commented Oct 23, 2026 •

Copy link
Copy Markdown

MiMo cluster paging previously covered plain target decode only. This draft gives the model-owned target cache a checked rollback/transfer contract and makes the trained assistant history policy explicit, so speculative and phase execution can retain paged storage without changing standalone defaults.

The target cache preserves physical full/sliding storage, write index and absolute offset. A rollback must remove a valid suffix of the last complete append. Transfer validates every incoming layer before installing fresh recipient owners. Assistant copies and accepted-prefix compaction detach actual page roots; the contiguous prefix checkpoint codec rejects paged state. Tests exercise unequal K/V widths, wrapped sliding histories, subsequent drafts and ownership release.

Depends on SDK #343, targeting its immediate branch fix/cluster-independent-history-batching. The provider integration is a separate child of d-inference #1567.

Before

flowchart TD
  A["MiMo speculative or transferred history"] --> B["Contiguous assistant and target assumptions"]
  B --> C["Paged rollback and physical transfer unavailable"]
  classDef default fill:#e8f0fe,stroke:#174ea6,color:#102a43,stroke-width:2px;
  classDef guard fill:#fff4ce,stroke:#8a6100,color:#332500,stroke-width:2px;
  classDef success fill:#d7f0df,stroke:#176b39,color:#103b23,stroke-width:2px;
  classDef failure fill:#fde2e2,stroke:#9b1c1c,color:#571111,stroke-width:2px;
  class C failure;
Loading

After

flowchart TD
  A["Explicit history policy"] --> B["Validate complete append or transfer"]
  B --> C["Retain physical order and absolute offset"]
  C --> D["Fresh page owners and accepted-prefix compaction"]
  D --> E["Continue original model arithmetic"]
  classDef default fill:#e8f0fe,stroke:#174ea6,color:#102a43,stroke-width:2px;
  classDef guard fill:#fff4ce,stroke:#8a6100,color:#332500,stroke-width:2px;
  classDef success fill:#d7f0df,stroke:#176b39,color:#103b23,stroke-width:2px;
  classDef failure fill:#fde2e2,stroke:#9b1c1c,color:#571111,stroke-width:2px;
  class B guard;
  class D,E success;
Loading

Validation: 10 actual SDK CPU tests in three suites passed. The combined provider test closure passed 11 Runtime CPU tests in four suites, including actual four-layer BF16 affine8/MXFP4 target continuation and phase handoff. SDK, Runtime, fresh VLM, Worker and Qualification modules compiled. Two older unquantized BF16 routed-target cases were excluded from CPU because the pinned GatherMM CPU implementation lacks that operation; no GPU pass is inferred.

Canonical targeted suites include MiMoV26IndependentHistoryTests and MiMoV26MTPPagedHistoryTests under Tests/MLXLMTests/Integration/MiMo/; the SDK test-layout checker passes. The recorded checks used isolated compiled closures with an explicit CPU device, not a claim that ordinary swift test avoids Metal. Reproduction entry point on a configured Mac:

scripts/check-unit-test-files.sh
swift test -c release --filter 'MiMoV26IndependentHistoryTests|MiMoV26MTPPagedHistoryTests'

Two reciprocal independent reviews cover the initial implementation and the other author's completion changes. They found and fixed an underpriced verification-window allowance in the provider integration and leave no unresolved source/refactor finding. Frozen SDK patch SHA-256: a0812d6cd82350f5108f9df9cf31d3c5a580e75c4eb4919b2338e451a3fa61d2.

Draft limitation: this is source/CPU validation. The complete 173GB artifact, installed c06 worker, both-host GPU execution, JACCL phase handoff, retirement observations and useful throughput remain unqualified. Numeric comparisons, standalone SDK defaults and GLM-specific code are unchanged; shared compatibility is not inferred from excluded-model testing.

Publication follow-up: signed head ebdc2d49258bfd5e267034db0b33d8c81f538f03 merges the formatted parent and retains all six reviewed MiMo file postimages transformed only by the SDK formatter. GitHub formatting and fork checks pass; full build/test and full-artifact hardware gates remain separate.

javiech1 pushed a commit to javiech1/mlx-swift-lm that referenced this pull request Oct 24, 2026
… Gemma3 / Qwen2VL / LFM2VL / Pixtral / Mistral3) (Layr-Labs#344)

Honor windowSize for chunked prefill in 6 MLXVLM models

Single-pass prefill allocates transient buffers proportional to prompt
length; chunking to windowSize=512 reduces peak memory from ~17.7 GB to
~5.1 GB on an 8k-token Gemma4 prompt (Layr-Labs#336).

Extends the Gemma4/Layr-Labs#337 loop pattern to remaining single-pass models:
- FastVLM, Gemma3, Qwen2VL, LFM2VL: embed-only path
- Pixtral, Mistral3: inputIds + inputsEmbeds path

Deferred (need non-trivial tensor slicing): Qwen25VL, GlmOcr, Qwen35,
Qwen3VL, Paligemma.
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.

1 participant