Skip to content

Fix MiMo media memory reservations with bounded native execution - #205

Merged
Gajesh2007 merged 2 commits into
mainfrom
fix/mimo-vision-working-set
Sep 30, 2026
Merged

Gajesh2007 merged 2 commits into
mainfrom
fix/mimo-vision-working-set

Conversation

@Gajesh2007

@Gajesh2007 Gajesh2007 commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Summary

Fix MiMo image/video admission by bounding actual vision execution before reducing its reservation. The production OpenRouter 1280×851 JPEG was charged about 344 GiB of extra vision memory; video graph charges reached 959–1014 GiB. The quote retained every layer/frame's worst-case graph simultaneously.

  • Add forwardBounded: synchronously complete each temporal grid and each transformer block using the existing native-work owner and checked evaluation.
  • Match the vision quote to the validated 64-wide fused Metal path; retain the full-score bound on CPU/custom streams or unqualified geometry. Keep retained input, patch backing, output features, FP32 and allocator allowances.
  • Complete each owned audio encoder block and RVQ codebook step; price the actual quantizer tile and retain the separate codec-load and final audio-patch charges.
  • Retire completed scratch-array registrations after checked evaluation, keeping the preparation owner/loan and retaining all required roots on failure.
  • Keep native completion failure ownership and quarantine intact.
  • Add the exact OpenRouter JPEG/MP4/MOV fixtures, mandatory decode/geometry/numerical regression coverage, and native media-refusal → text-serving coverage.

The companion d-inference PR distinguishes media-memory refusals from text/KV capacity failures so they do not clamp otherwise-working text providers.

Before

flowchart LR
  A["Image or video request"] --> B["managedBaseCommitmentBytes"]
  B --> C["All frame and layer graphs charged together"]
  C --> D["Host reservation refused"]
  D --> E["Media cannot reach inference"]
  classDef flow fill:#dbeafe,stroke:#2563eb,color:#172554
  classDef failure fill:#fee2e2,stroke:#dc2626,color:#450a0a
  class A,B,C flow
  class D,E failure
Loading

After

flowchart LR
  A["Image, video or audio request"] --> B["Kernel-aware workspace plus retained buffers"]
  B --> C["Host reservation"]
  C --> D["Bounded vision / encoder / RVQ stage"]
  D --> E["Track roots and checked eval"]
  E --> H["Retire completed scratch roots"]
  H --> D
  E --> F["Retain completed features; infer"]
  E --> G["Real completion fault: retain owner"]
  classDef flow fill:#dbeafe,stroke:#2563eb,color:#172554
  classDef success fill:#dcfce7,stroke:#16a34a,color:#052e16
  classDef failure fill:#fee2e2,stroke:#dc2626,color:#450a0a
  class A,B,C,D,E,H flow
  class F success
  class G failure
Loading

Validation

  • swift build --build-tests with the pinned local MLX and source-matched Metal library.
  • Exact captured media, real fused-kernel allocation, stream/geometry fallback, actual audio tiles, lazy/bounded numerical equivalence, and scratch-owner lifetime tests run in the nonzero/no-skip media lane.
  • Full MiMoV26NativeMediaDeadlineTests: eleven tests, including repeated media refusals followed by real text generation, expiry, cancellation, seal ownership and retirement.
  • MiMoV26FullVisionQualificationTests: all four captured media plus 1080p, 4K, maximum-area portrait/panorama and 32-frame cases passed with the actual 364 BF16 vision tensors.
  • MiMoV26FullAudioQualificationTests: genuine authenticated codec, captured stereo AAC plus 1/30/61/300-second PCM cases; all incremental allocator peaks below the corresponding reservations.
  • Managed cancellation and independent encoder/quantizer/readback fault injections verify actual root retention and no false retirement.

On an M4 Max/128 GiB machine, the large JPEG vision workspace is 0.899 GiB with 0.404 GiB additional measured MLX peak. The MP4 vision workspace is 0.734 GiB and native audio reservation 0.323 GiB (previously 8.713 GiB for audio). Retained pixels/patches/features are additional.

The vision component measurement excludes language-model/codec weights, target KV and non-MLX allocations. The separate audio measurement covers PCM-to-codec output and excludes final audio-patch execution; that patch allowance remains charged. This is not full-size signed-provider or fleet qualification. See docs/mimo-v26/media-working-set-20260930.md for source revision, hashes, calculated reservations and measurement scope.

No language-model weights are committed. The checked-in encoded fixtures total about 8 MB; no request authorization headers or production prompt bodies are included.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-30T19:49:26.422850Z 944beea New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Gajesh2007 Gajesh2007 changed the title fix(mimo): bound vision working memory per frame and layer Fix MiMo media memory reservations with bounded native execution Sep 30, 2026
@Gajesh2007
Gajesh2007 merged commit 0871943 into main Sep 30, 2026
5 of 6 checks passed
@Gajesh2007
Gajesh2007 deleted the fix/mimo-vision-working-set branch September 30, 2026 19:55
javiech1 pushed a commit to javiech1/mlx-swift-lm that referenced this pull request Oct 24, 2026
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