Skip to content

feat(agent): coordinate shared local inference#97

Open
Brooooooklyn wants to merge 25 commits into
mainfrom
agent/mlx-agent-reliability
Open

feat(agent): coordinate shared local inference#97
Brooooooklyn wants to merge 25 commits into
mainfrom
agent/mlx-agent-reliability

Conversation

@Brooooooklyn

@Brooooooklyn Brooooooklyn commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • run Pi subagents as isolated in-process sessions that share one serialized MlxModelHost, model registry, and physical paged KV pool instead of loading one model per child process
  • size Qwen3.5/Qwen3.6 dense and MoE paged pools after weight materialization from live unified-memory ceilings; explicit cache budgets remain maxima and cannot bypass the safety cap
  • publish the physical context window to Pi, scale subagent compaction budgets, preflight exact rendered prompts, and convert capacity failures into clean agent compaction or HTTP 400 paths
  • force a full-history replay after interrupted or failed native deltas so JavaScript history cannot diverge from committed native cache state
  • add a restart-safe SSD cold-cache primitive with stable model/prefix keys, checksummed safetensors, bounded atomic writes, quota/LRU enforcement, and transactional restore
  • preserve the earlier terminal-title, split reasoning-tag, and permission-summary fixes in this branch
  • request native timing metrics and show transient prefill/decode tok/s in Pi's TUI footer; clear stale rates at turn/model boundaries without persisting telemetry

Why 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 SettingsManager injection/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

  • full TypeScript suite: 1,737 passed, 21 skipped
  • focused agent/session/server integration: 485 passed
  • agent provider/TUI telemetry suite: 221 passed
  • paged-attention Rust suite: 118 passed
  • native capacity boundary tests: 3 passed
  • cargo check -p mlx-core
  • clippy for mlx-core and mlx-paged-attn with warnings denied
  • TypeScript typecheck and lint
  • Rust and TypeScript formatting checks
  • full release native addon rebuild

Note

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, wiring MLX_NODE_LOG / MLX_NODE_LOG_FILE before the native addon loads, and tightens local-first handoff by prepending --models mlx/* (including --fork and value-aware flag parsing). Paged cache overrides move into PagedConfigOverrideManager in @mlx-node/lm, with separate launch-claude vs agent policies (Qwen memory floor, Gemma4 draft hiding unless opted in, MTP sidecar symlinks).

ChatSession now preflights rendered prompts against the physical window (ContextCapacityError / preflightContextCapacity) and retries failed or aborted native deltas via resetCaches + full chatSessionStart replay 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 (step per emitted token, N−1 decode rate), adds mlx_core::inference structured 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 and cache_owner_id / cache_root_owner_id on ChatConfig support hybrid cache ownership. Gemma continuation e2e expectations shift (pure-image warm continue; audio cold replay). image crate 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

  • keep PagedAttention enabled and use an exact-shape grouped-GQA Metal path for BF16 D256/BS16 long-context decode: dense 24Q/4KV and MoE 16Q/2KV, including two-row MTP verification
  • preserve generic V2 below measured crossover points, on unsupported devices, and for every other shape; capability or pipeline failures fall back instead of failing inference
  • use conservative layout-specific cutoffs: dense 16K q1 / 8K q2, MoE 32K q1 / 16K q2
  • align graph-native C++ and raw Rust dispatch, stripe/reducer scheduling, auxiliary-memory estimates, cache accounting, and permanent numerical-parity coverage
  • capture materialized MoE GDN state at the final reusable paged-block boundary, restore it by exact token/hash/namespace match before suffix prefill, and bound/materialize full-prefix replay on a miss
  • fix AR/MTP profiling so prefill, TTFT, generated-token count, N-1 decode throughput, replay errors, and TUI metric persistence describe the same turn
  • use normal configurable tracing for inference diagnostics
  • replace deprecated metal-rs 0.33 / objc 0.2 / block 0.1.6 with a narrow ownership-aware adapter over objc2 0.6.4 and objc2-metal 0.3.2

Measurements

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:

Trial Prefill Decode
AR 1 686.9 tok/s 20.6 tok/s
MTP depth 1 577.2 tok/s 18.1 tok/s
AR 2 540.7 tok/s 19.1 tok/s

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/2KV raw-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

  • grouped graph numerical parity covers dense/MoE and q1/q2
  • raw Metal host-reference parity covers dense 24Q/4KV and MoE 16Q/2KV q1/q2, including non-finite rejection
  • layout-specific selector, threshold, capability, and auxiliary-sizing tests
  • MoE GDN forced-boundary split parity, exact publish/restore, token/salt rejection, and bounded-replay state parity
  • profiler accounting: 26 passed
  • MTP turn control flow: 23 passed
  • agent CLI/tracing/TUI tests: 84 passed
  • strict Clippy for mlx-core, mlx-paged-attn, and mlx-metal
  • TypeScript build, Rust format, diff check, lint, and release native addon/metallib rebuild
  • dependency-tree proof: block 0.1.6, objc 0.2.7, and metal 0.33 are absent

Gemma4 QAT conversion and agent inference update

  • preserve source GGUF Q4_0/Q4_1/Q8_0 block-32 affine geometry in MLX safetensors; dequantize the supported Gemma4 Q6_K token embedding to BF16, and reject unsupported Q6_K placements
  • add --config-dir plus Gemma4 mmproj remapping so authoritative config/tokenizer assets and unified vision/audio tensors can be carried into the converted checkpoint
  • load unified media sidecars only when the parsed Gemma4 capabilities require them, and hoist BF16 affine-QMM FP16 sidecar widening to model load while preserving projection outputs
  • preserve the thinking-mode provenance used to render historical assistant turns so prompt-cache replay remains byte-stable
  • auto-discover an embedded Gemma4 draft/; mlx agent continues to prefer paged AR and requires MLX_AGENT_ENABLE_GEMMA_DRAFT=1 for the flat speculative path
  • add a measured per-turn DSpark break-even guard that falls back to exact target AR when speculation loses, while explicit depth/adaptive settings retain their documented control
  • add Gemma4 cache-hit prefill/sliding-checkpoint plumbing and an experimental BF16 D512/16Q/1KV grouped paged-attention kernel with graph/reducer parity coverage

The 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

  • Qwen paged-override regression suite: 20/20
  • TypeScript typecheck and focused lint
  • Rust and changed-file TypeScript formatting
  • git diff --check
  • full native/Metal validation delegated to the fresh GitHub CI run because a user mlx agent session is active locally

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2612a466-7862-41a3-9cfa-45eaf2a06846

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/mlx-agent-reliability

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Brooooooklyn Brooooooklyn marked this pull request as ready for review July 12, 2026 16:22
@cursor

cursor Bot commented Jul 12, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread crates/mlx-core/src/models/qwen3_5/model.rs Outdated
@cursor

cursor Bot commented Jul 13, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

@cursor

cursor Bot commented Jul 13, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread packages/agent/src/extensions/permission-gate.ts Outdated
Comment thread packages/agent/src/extensions/permission-gate.ts Outdated
@cursor

cursor Bot commented Jul 13, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

@Brooooooklyn Brooooooklyn changed the title fix(agent): stabilize long local sessions feat(agent): coordinate shared local inference Jul 13, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread packages/server/src/endpoints/messages.ts Outdated
Comment thread packages/server/src/endpoints/responses.ts Outdated
@cursor

cursor Bot commented Jul 13, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Caution

Review failed

An error occurred during the review process. Please try again later.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/mlx-agent-reliability

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cursor

cursor Bot commented Jul 13, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread packages/lm/src/chat-session.ts Outdated
@cursor

cursor Bot commented Jul 13, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

@cursor

cursor Bot commented Jul 13, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

@cursor

cursor Bot commented Jul 13, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

@cursor

cursor Bot commented Jul 13, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

@Brooooooklyn

Brooooooklyn commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

Pushed 3b860770 with the long-session Qwen3.6 dense prefill fix.

What changed:

  • keeps the paged KV pool, prefix reuse, and paged decode enabled
  • replaces the old per-query duplicated block table with compact one-row varlen PagedAttention metadata
  • adds a graph-native paged-pool K/V gather for MLX causal SDPA, avoiding the Metal -> CPU -> MLX round trip
  • routes cache-hit prefill from live memory headroom and the actual MLX fused-kernel shape gate
  • accounts for Qwen3.6-27B head_dim=256, where multi-token SDPA materializes the score matrix
  • uses the fast MLX path when the full transient fits and compact varlen PagedAttention under pressure
  • preserves MLX_PAGED_PREFILL_PAGED_ATTENTION=0 as an SDPA-only escape hatch
  • keeps FP8 KV cache on the scale-aware varlen path

Verification:

  • Qwen attention router: 11/11
  • paged cache adapter, including Metal layout/lazy-write tests: 88/88
  • varlen native bridge smoke tests: 9/9
  • cargo check --workspace
  • cargo clippy --all-targets -- -D warnings
  • yarn build and final yarn build:native
  • independent integrated review: approve
  • GitHub CI: all jobs green

I intentionally did not launch the 27B model; the globally linked mlx binary has been rebuilt and is ready for the long-session benchmark.

@cursor

cursor Bot commented Jul 14, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

@cursor

cursor Bot commented Jul 14, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

@Brooooooklyn

Copy link
Copy Markdown
Contributor Author

Qwen3.6-27B long-context prefill update is now pushed in ca8053f7.

Root cause: MLX fell back to the unfused score-matrix SDPA path for multi-token head_dim=256 prefill. This update pins the D256 NAX kernel work from upstream MLX PR #3842, aligns planner/runtime eligibility, keeps PagedAttention enabled, and adds a process-cached rollback switch: MLX_ENABLE_D256_FULL_SDPA=0.

Measured on the local M5 Max with the Qwen3.6-27B MXFP4+MXFP8 model:

  • Operator A/B at q=2048, context=8192: 35.94 ms fallback -> 12.69 ms fused (2.83x faster); MLX peak allocation 964.8 MB -> 117.5 MB (~8.2x lower).
  • Full 45,416-token agent prompt: 542.1 tok/s prefill, with PagedAttention and MTP both enabled.
  • Decode after the one-time MTP compile window: 24.0 tok/s over the second 32-token window.
  • The inference trace recorded 22/22 cache-hit plans on paged_pool_sdpa, with no warnings or fallback events.

Safety/coverage added alongside the fast path:

  • conservative INT32-safe varlen partition planning shared with runtime behavior;
  • FP16/BF16/FP32 eligibility and rollback probes;
  • clean CPU-only build/link path and stale-metallib cleanup;
  • ignored hardware/operator benchmarks that require explicit invocation.

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.

@cursor

cursor Bot commented Jul 14, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

@cursor

cursor Bot commented Jul 15, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

@cursor

cursor Bot commented Jul 15, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

@Brooooooklyn

Copy link
Copy Markdown
Contributor Author

Live mlx agent --trace subagent audit and fix:

  • Confirmed each child is an in-process Pi AgentSession: logical history/tools are isolated, while one resident model, native ChatSession, PagedAttention pool, and serialized inference host are shared.
  • The trace exposed GDN sidecar thrashing: after a child branch reached 111,456 cached tokens, returning to the parent recovered its 66,784-token paged-KV prefix but replayed all 66,784 GDN tokens, adding 16.2 seconds outside the reported prefill metric.
  • Pi active session ID and current top-level session ID now flow separately into dense/MoE GDN sidecars. Retention is exact owner+token+allocator-hash, LRU-touched, capped at 2 per owner and 5 total, and rotates root protection across /new and resume. Physical PagedAttention identity and cache_salt remain unchanged.
  • --trace now re-announces the exact inference.log path after the TUI starts, so Pi no longer erases the startup-only path.
  • Corrected CLI help: subagents are in-memory sessions; tool loops may overlap, but inference is serialized. Separate top-level processes still do not share model memory.

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.

@cursor

cursor Bot commented Jul 15, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

@Brooooooklyn

Copy link
Copy Markdown
Contributor Author

Qwen3.6 35B-A3B trace follow-up is now pushed in 85cbb91 and 25a6d93.

Performance diagnosis:

  • The TUI 2,949.9 PP result was the cold first request: 4,379 tokens / 1,477.3 ms = 2,964 tok/s.
  • The next warmed 4,037-token request reached 3,909 tok/s. The fair gap versus the oMLX 4K result (4,459 tok/s) is 12.3%; oMLX explicitly runs a 32-token warmup first.
  • All 103 traced attention-prefill routes used paged_pool_sdpa, with native paged KV writes, D256 SDPA available, no fallbacks, and roughly 67-70 GiB headroom.
  • The selected hybrid artifact contains 192 MXFP4 and 179 MXFP8 tensors and is not artifact-identical to the benchmark 4bit checkpoint; no baseline PagedAttention dispatch bug was found.

Long-session fix:

  • GDN checkpoints now use the largest complete block strictly below prompt end, matching the allocator prompt.len()-1 lookup cap.
  • The three observed 10.0s / 12.0s / 10.8s replay cases now capture exact reusable boundaries: 41,216 -> 41,200; 45,360 -> 45,344; 47,488 -> 47,472.
  • Longer rollbacks restore the longest identity-safe ancestor and replay only the delta. Owner, tokens, block hashes, salt, per-block keys, and cache readiness are all checked.
  • Dense and MoE replay are transactional: partially replayed recurrent state is never published after an eval/OOM error.

Agent reliability follow-up:

  • Pending permission dialogs now receive the active abort signal, so Ctrl+C fails closed instead of leaving the tool-call hook suspended. Pi parallel-tool head-of-line blocking itself remains an upstream core scheduling limitation.

Validation:

  • 15 focused GDN tests passed.
  • Dense and MoE ignored Metal lifecycle tests passed sequentially; MoE retained the same argmax with max abs logit diff 0.015625.
  • Permission-gate tests: 52/52 passed.
  • cargo check/clippy, rustfmt, yarn typecheck/lint, git diff --check, and a full release native+TS build passed.
  • The globally linked mlx CLI now points at this rebuilt workspace output.

Benchmark references: https://omlx.ai/benchmarks/3589vqed and https://github.com/jundot/omlx/blob/main/omlx/admin/benchmark.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread crates/mlx-metal/src/lib.rs Outdated
@cursor

cursor Bot commented Jul 15, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

@Brooooooklyn

Brooooooklyn commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

Image tool-result support is now included in commit 9c8e2a2.

  • Qwen3.5/3.6 dense and MoE sessions now publish image capability only after the native vision encoder, processor, and PagedAttention image path are fully available.
  • Pi read-tool images are preserved and forwarded as a template-safe user image turn; grouped and parallel tool results keep source order.
  • The stale "image will be omitted" marker is removed only from image-tool conversion, while real tool errors and literal user text remain intact.
  • Missing Qwen patch-embedding weights fail closed instead of exposing an image-blind vision tower.
  • GIF, JPEG, PNG, and WebP inputs are enabled and covered.
  • Gemma remains conservatively text-only until its optional vision-weight loading can prove completeness.

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread packages/agent/src/extensions/subagent.ts Outdated
@cursor

cursor Bot commented Jul 15, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

@Brooooooklyn

Copy link
Copy Markdown
Contributor Author

Gemma/Qwen image-aware PagedAttention lifecycle is now pushed in 732bde72.

What changed:

  • Qwen3.5/3.6 Dense and MoE now key reusable paged blocks by ordered image bytes, retain exact recurrent sidecars across branch switches, invalidate fully on every failed lifecycle edge, and propagate finalization errors instead of publishing partial state.
  • Gemma now advertises image support only for a complete loaded processor + projection + vision encoder + paged path; standard SigLIP weights fail closed when required tensors are missing.
  • Gemma sync and streaming image turns share one image-aware prefix planner/finalizer, report real cachedTokens, skip the vision tower after a full image-span hit, and preserve exact physical sliding-anchor checkpoints for KV-shared E2B models.
  • Changed images can reuse only causal leading-text blocks; image-conditioned blocks remain isolated. Unified bidirectional vision never splits a prefill chunk inside the image span.
  • Audio/mixed turns and reuseCache=false remain cold and publish no reusable media checkpoints.
  • Sliding checkpoint retention is memory-bounded (1 GiB default estimate) while protecting the two latest image prompt identities for A -> B -> A recovery.
  • Fresh text starts cannot inherit image lineage without declared media context.

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:

  • release native addon build + metallib smoke checks
  • cargo check and strict Clippy
  • shared paged-image cache suite: 9/9
  • Gemma strict persistence suite: 27 passed / 1 model-gated ignored
  • focused Gemma cache/capability/overlay/lineage regressions
  • TypeScript typecheck and Gemma native-surface tests: 14/14
  • rustfmt and diff checks
  • independent end-to-end cache safety review: clean after fixes

@cursor

cursor Bot commented Jul 15, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread packages/lm/src/models/paged-config-override.ts
@cursor

cursor Bot commented Jul 16, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

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