Skip to content

Checkpoint: consolidated runtime + native image work + Gemma-4 KV-cache wiring lock#72

Draft
jjang-ai wants to merge 10 commits into
mainfrom
codex/vmlx-checkpoint-2026-06-16
Draft

Checkpoint: consolidated runtime + native image work + Gemma-4 KV-cache wiring lock#72
jjang-ai wants to merge 10 commits into
mainfrom
codex/vmlx-checkpoint-2026-06-16

Conversation

@jjang-ai

Copy link
Copy Markdown
Contributor

Summary

Large consolidation checkpoint of accumulated, individually-proven vmlx-swift work, plus the vmlx-side lock for the Gemma-4 tool-call KV-cache wiring. Opened as a draft — this is a save-point for review, not for immediate merge. CI is expected to be the gate; un-draft when the team is ready to land.

What's in here

Runtime

  • MiMo v2 hybrid cache topology + runtime ABI alignment
  • BatchEngine / scheduler updates
  • Distributed TP / JACCL sharding plans (incl. MiMoV2 plan, switch-linear layers)
  • Config-init guards across the LLM model family + matching scripts/vmlx-*-guard-check.sh
  • Slider-governed default KV cap; resolved memory-safety plan cache

Native image generation (vMLXFlux{,Kit,Models,Video} targets, wired into Package.swift)

  • z-image-turbo, flux-schnell, qwen-image native pipelines + local model store
  • Spec/handoff docs under docs/ (MFLUX_HANDOFF.md, OSAURUS_VMLX_FLUX_INTEGRATION_SPEC.md, port plans)

Gemma-4 tool-call KV-cache wiring (the "prefill resets to 0 after a tool call" report)

  • Root cause was osaurus-side and is already fixed upstream in osaurus-ai/osaurus#1525: finalizingPostToolChoice deleted (no more gemma-4/qat/mxfp4 tool_choice→none flip), tool_choice/tools held byte-stable per iteration, transient [System Notice] lines now ride as tool-role feedback.
  • This PR locks the vmlx half of the contract: Gemma4WithTools.jinja's system turn (system content + <|tool>declaration: block) must stay byte-identical across a tool-call → tool-result iteration so the KV prefix is reused. Two pure-template regression tests in Tests/MLXLMTests/Gemma4ChatTemplateProbeTests.swift (no weights, CI-safe) assert both prefix-stability and the busting failure mode.
  • Full chain documented in docs/GEMMA4_TOOLCALL_KV_CACHE_WIRING.md.

Verification

  • swift build (full package, 1876 steps) green on this branch.
  • New Gemma-4 prefix-stability tests pass:
    • testGemma4WithToolsSystemPrefixStableAcrossToolResultTurn
    • testGemma4WithToolsDroppingToolsBustsSystemPrefix

Notes

  • goalnew.md and local scratch (.agents/, docs/local/, .logs/) are intentionally excluded; .gitignore updated to cover .logs/, codex/logs/, .sentry.local.env, .claude/*.local.md.
  • ITEM 5 (TurboQuant over-budget warning) is still in progress and not part of this checkpoint's claims.

Eric added 10 commits May 25, 2026 12:58
…a-4 KV-cache wiring lock

Consolidates accumulated, individually-proven work into one reviewable
checkpoint for main:

- Runtime: MiMo v2 hybrid cache topology/ABI, BatchEngine scheduler updates,
  distributed TP/JACCL sharding plans, model config-init guards across the
  LLM model family, slider-governed KV cap, memory-safety plan cache.
- Native image generation (vMLXFlux{,Kit,Models,Video} targets): z-image-turbo,
  flux-schnell, qwen-image native pipelines + local model store, wired into
  Package.swift. Spec/handoff docs under docs/.
- Release guard scripts (scripts/vmlx-*-guard-check.sh) and focused tests.

Gemma-4 tool-call KV-cache wiring (osaurus prefill→0 after tool call):
- osaurus root cause already fixed upstream in osaurus-ai/osaurus#1525
  (removed finalizingPostToolChoice; tool_choice/tools held byte-stable per
  iteration; transient notices ride as tool-role feedback).
- vmlx side: lock the Gemma4WithTools.jinja prefix-stability contract with two
  pure-template regression tests in Gemma4ChatTemplateProbeTests, and document
  the full chain in docs/GEMMA4_TOOLCALL_KV_CACHE_WIRING.md.
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