feat(agent): coordinate shared local inference#97
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_b4884de9-270b-40c2-94b2-542be1ad900b) |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6a3fe3e40b
ℹ️ 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".
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_45beb517-0ddc-4f4e-a427-fb42f135d258) |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_952ae4df-3c2e-4938-aacf-86f7401eb5c6) |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ea42165ac2
ℹ️ 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".
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_373706a5-e317-49f8-9f3d-ec619c4dd1f6) |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1d2db7b781
ℹ️ 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".
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_7f7ef354-45d0-4dd1-83c5-9c6f55e38472) |
|
Caution Review failedAn error occurred during the review process. Please try again later. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_2c86a194-1ca3-4925-8f2b-47d7ef30d0eb) |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7deb4979b1
ℹ️ 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".
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_944fae22-f320-4ab1-9570-3885e618d825) |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_083c3507-9ee1-4ff7-976b-dfc93c5a0c99) |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_6df17067-9728-4486-a968-54c749665594) |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_476877b3-848c-4234-bf8f-0d48ae16c675) |
|
Pushed What changed:
Verification:
I intentionally did not launch the 27B model; the globally linked |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_7ea6ac23-a7d6-4497-ab3d-550b40358d58) |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_8c6bfffa-c927-4a4c-8f8f-51fc5de210ff) |
|
Qwen3.6-27B long-context prefill update is now pushed in Root cause: MLX fell back to the unfused score-matrix SDPA path for multi-token Measured on the local M5 Max with the Qwen3.6-27B MXFP4+MXFP8 model:
Safety/coverage added alongside the fast path:
Validation completed locally: strict native build, TypeScript build/lint, full test suite (106 files; 1,784 passed, 21 skipped), targeted Rust suites, explicit NAX D256 tests, and a fresh CPU-only compile target. |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_6aa55cad-a882-42e1-88f3-a3e53049fe48) |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_4c2c49bb-6195-4880-b8d5-35b0aacb1e2d) |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_dc52d82e-1541-4186-8e89-84ef7150930d) |
|
Live
Local validation: release native addon + TS builds; Rust fmt/check/Clippy; 8 checkpoint-policy tests plus owner propagation/model lifecycle tests; 143 focused TS tests; full TS suite 1,794 passed / 21 skipped. No model process was launched or signaled by the fix/validation. |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_82e658ee-8b9c-4d3c-b1f1-ed293e1ba842) |
|
Qwen3.6 35B-A3B trace follow-up is now pushed in 85cbb91 and 25a6d93. Performance diagnosis:
Long-session fix:
Agent reliability follow-up:
Validation:
Benchmark references: https://omlx.ai/benchmarks/3589vqed and https://github.com/jundot/omlx/blob/main/omlx/admin/benchmark.py |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 25a6d93ca4
ℹ️ 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".
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_c37e308d-0dc0-4309-a079-fc4e62bdeb5c) |
|
Image tool-result support is now included in commit 9c8e2a2.
Local verification passed: full TS suite (1,805 passed, 21 skipped), typecheck, lint, TS/native builds, focused Rust tests, cargo check, strict Clippy, fmt, and diff checks. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9c8e2a2cd9
ℹ️ 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".
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_1523c1d6-ba5f-495f-b27f-b40a1f317e17) |
|
Gemma/Qwen image-aware PagedAttention lifecycle is now pushed in What changed:
Real single-model E2B validation passed sequentially (no second agent/model process): cold A -> warm A -> changed-image B -> warm A again -> explicit reset, 86.28s total. The same-image and A-after-B turns both reported image-aware cache hits and preserved deterministic output. Local verification:
|
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_e706e6df-9697-4266-861f-7c4ca8b1380c) |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 25329df9b5
ℹ️ 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".
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_5b034475-e28a-4768-957c-371f37d36064) |
Summary
MlxModelHost, model registry, and physical paged KV pool instead of loading one model per child processWhy the allocator exhausted
The previous fixed/default pool could advertise a 262,144-token trained window while physically holding about 104,848 tokens. Pi therefore continued sending turns after the hot KV pool was full, producing
BlockAllocator exhausted. The loaded model now exposes both trained and physical limits, and both TypeScript and native paged entry points reject or clamp before allocator mutation.Shared-host behavior
Parallel subagents may run up to four independent Pi tool loops, but all inference is serialized through one resident model host. Each subagent keeps independent in-memory conversation, settings, cwd, tools, skills, and project context. Model weights and the paged pool are loaded only once for the shared model.
SSD tier boundary
This PR provides and verifies the durable cold-cache storage/restore layer, but does not enable Qwen eviction yet. Qwen3.5/3.6 hybrid continuation also needs matching GDN and MTP side state; restoring full-attention K/V alone would be incorrect. Wiring eviction is intentionally deferred until that sidecar can be captured and restored atomically.
Top-level Pi still needs an upstream
SettingsManagerinjection/update hook to scale its fixed compaction reserve for unusually small physical windows. In-process subagents are scaled here; exact preflight remains the correctness backstop everywhere.Verification
cargo check -p mlx-coremlx-coreandmlx-paged-attnwith warnings deniedNote
High Risk
Changes core inference scheduling, native KV/GDN cache identity, context limits, and session replay semantics across agent, server, and mlx-core; regressions could cause silent cache misuse, allocator exhaustion, or divergent agent history.
Overview
Extends mlx agent with
--trace/--trace-dir, wiringMLX_NODE_LOG/MLX_NODE_LOG_FILEbefore the native addon loads, and tightens local-first handoff by prepending--models mlx/*(including--forkand value-aware flag parsing). Paged cache overrides move intoPagedConfigOverrideManagerin@mlx-node/lm, with separate launch-claude vs agent policies (Qwen memory floor, Gemma4 draft hiding unless opted in, MTP sidecar symlinks).ChatSessionnow preflights rendered prompts against the physical window (ContextCapacityError/preflightContextCapacity) and retries failed or aborted native deltas viaresetCaches+ fullchatSessionStartreplay instead of another delta. HTTP streaming paths reject overflow as JSON 400 before SSE and emit initial stream events before blocking on the first native chunk.On the Rust side: decode profiling aligns TTFT vs decode throughput (
stepper emitted token, N−1 decode rate), addsmlx_core::inferencestructured logs, and DSpark can calibrate and fall back to target-only AR when speculative cycles lose on measured throughput. VLM paged prefix logic downgrades K/V hits without matching GDN sidecars to a cold restart; image-aware block keys andcache_owner_id/cache_root_owner_idonChatConfigsupport hybrid cache ownership. Gemma continuation e2e expectations shift (pure-image warm continue; audio cold replay).imagecrate gains GIF support.Reviewed by Cursor Bugbot for commit a94ec73. Bugbot is set up for automated code reviews on this repo. Configure here.
Qwen3.5 / Qwen3.6 dense and MoE performance update
D256/BS16long-context decode: dense24Q/4KVand MoE16Q/2KV, including two-row MTP verificationmetal-rs 0.33/objc 0.2/block 0.1.6with a narrow ownership-aware adapter overobjc2 0.6.4andobjc2-metal 0.3.2Measurements
Controlled 16K / 128-token runs on the local Qwen3.6-27B MXFP4+MXFP8 dense model, with one loaded model and cold cache before each trial:
The bracketing AR weighted decode rate was 19.8 tok/s; MTP reached 91.4% of it with a mean commit of 1.826 tokens/cycle. This confirms the profiler fix and rules out the earlier 12 tok/s report as the healthy short-context baseline.
For Qwen3.6-35B-A3B without MTP, the pre-fix mlx-agent trace reached about 584 tok/s prefill but only 24.2 tok/s decode near 91K context. The corrected oMLX comparison supplied for the same M5 Max class is 547.3 tok/s prefill and 44.9 tok/s decode at 128K, so prefill is already in range and long-context decode is the remaining gap.
Isolated
16Q/2KVraw-attention A/B at 112K cached tokens improved q1 from 3.770 ms to 1.441 ms and q2 from 4.294 ms to 2.148 ms. The release addon is rebuilt; full-model post-fix 35B-A3B validation is pending the next mlx-agent trace.Additional verification
mlx-core,mlx-paged-attn, andmlx-metalblock 0.1.6,objc 0.2.7, andmetal 0.33are absentGemma4 QAT conversion and agent inference update
--config-dirplus Gemma4 mmproj remapping so authoritative config/tokenizer assets and unified vision/audio tensors can be carried into the converted checkpointdraft/;mlx agentcontinues to prefer paged AR and requiresMLX_AGENT_ENABLE_GEMMA_DRAFT=1for the flat speculative pathThe grouped Gemma4 D512 route remains default-off and diagnostic until sequential full-model A/B establishes a safe context/device crossover. The latest 47K-context agent trace confirmed prompt-cache and physical paging correctness at 607.7 tok/s bulk prefill and 15.3 tok/s decode; this update does not claim that the default long-context decode gap is closed yet.
The final unresolved review thread is also addressed: paged override clones now preserve only loader-known Qwen3.5 nested MTP sidecars and reject escaping paths while keeping unrelated directories and Gemma4
draft/hidden.Additional verification
git diff --checkmlx agentsession is active locally