Repository navigation
feat(kv-int8): --max-context caps the window; YaRN above the native window - #358
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cd34d9a182
ℹ️ 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".
cd34d9a to
a0ff878
Compare
a0ff878 to
a1287cb
Compare
b43b26a to
6bf14f1
Compare
6bf14f1 to
b3f945c
Compare
…indow mlx serve and mlx agent take --max-context N (K = 1024, M = 1,000,000, 1 to 1,010,000, auto = unset), parsed like Splash parse_max_context. The loader hands it to qwen3_5, qwen3_5_moe and qwen4_exp loads as maxContextTokens; other families refuse it. Splash rules: - N at or below the native window only caps: every published window, preflight and scheduled turn holds at most N. The trained window stays native. Flat qwen3_5 / MoE chat turns hold it natively too. - N past the native window turns on static YaRN on the target RoPE (servedFor): factor N / native, beta_fast 32, beta_slow 1, rotated q/k dims times 0.1 ln(factor) + 1 (rotaryInverseFrequencies, attentionFactor). Image rows and the Flash Next indexer take the same table. The DFlash2 draft keeps its own RoPE. - YaRN only where the native window is 262,144; up to 1,010,000. - The plan prices the served window; Flash Next's KV allowance is N. - N above the default turn's lane fails the load with Splash's ServingRuntime::start text. The default lane is DFlash2 with a draft, else the pool, else the flat lane of a load with neither; the other lanes are clamped to N. N past native with no plan (device memory unreadable) fails too. - A checkpoint whose RoPE is already scaled is refused (rope_type, else type, not default; a GGUF rope.scaling.type other than none). - The cold-tier key gets "rope yarn <%.17g> <native>" only with YaRN; the saved config.json never carries the factor. Training refuses a YaRN load. - /v1/models shows N until the load-free estimate lands; a refused estimate leaves the trained window. Deleted: the four draft-window caps (load plan, speculative_window, constrain_dflash2_context_params, DFlash2Model::propose) and the draft's max_position_embeddings accessors. Splash caps by the target only. Fused mlx_qk_norm_rope and the source QK path step aside under YaRN. Below the native window the RoPE is today's kernel bit for bit. Tests: 400K gives factor 1.5625, attention factor 0x3f85b665 and Splash's -O3 table bit for bit; a 100K cap publishes 102,400 on both lanes while the plan prices 262,144; 400K plans 409,600; on a flat load whose 4 GiB plan holds 45,056 rows, 40,000 publishes 40,000 and 45,057 is refused. 31 Rust and 15 TS named mutations, each red when on and green when off. No model was loaded. Co-Authored-By: Claude Opus 5.5 <[email protected]>
a1287cb to
65bdcb8
Compare
…ees it (#359) Stage S21 of the Splash int8 KV alignment (stack #344). Base: S22 (#358). The model holds one wired residency for its life, as Splash 1.6 `metal::Residency` does. `--idle-release` frees the weights after an idle time. ``` load ──► lease(max_rec − pool sets) ─┬─ drive loop marks the clock before GPU work ├─ beat thread: requestResidency every 500 ms │ (MLX sets + one pool set per LayerKVPool, not on a queue) └─ no command for --idle-release (default 10m, off = never) ├─ Rust: lease ends, pool sets end, residency_kick └─ TS: chat model unloaded, dispose() frees weights next request ──► lazy load again (restores += 1) POST /v1/memory/release ──► 200 | 409 engine_busy | 503 server_shutdown (Splash fieldless body rules) ``` ## Changes - qwen3_5, qwen3_5_moe and qwen4_exp: one lease in `HybridScheduler::drive` covers every lane, DFlash2 included. The 14 per-turn `WiredLimitContext` sites and `scheduler_wired_bytes` are deleted. - `mlx-paged-attn`: `residency.rs` (one process clock, 500 ms beat, pool residency set) and the `residency_kick` kernel. - The addon sets `MLX_METAL_RESIDENCY_REFRESH_INTERVAL_MS=500` when unset. New napi: `setResidencyKeepAlive`, `dispose()` on the three model classes. - `mlx serve` / `mlx agent`: `--idle-release`. `/health` gains `weights` and `work.releasePending`. The 30 s cache clear stays. - Flash Next: banks stay non-volatile between turns (Splash `ExpertStore` has no timed purge). `SLOT_RECLAIM_FALLBACK`, the 30 s purge, bank suspend/activate and slow-source detection are deleted. ## Gaps vs Splash - The release unloads the whole model. KV, prefix cache, sessions and state go too. Restore is a full load with no governor (S11). - MLX's own sets stay attached to its queues, so wiring uses the lease plus the pool sets. - Training drops the lease. Rerank, ASR and TTS models are not released. `--allow-idle-sleep` is not ported. ## Tests - 10 new Rust tests, 3 new and 8 changed TS test files. 18 named mutations, each red when on and green when off. - `cargo fmt --check`, `cargo clippy --all-targets -D warnings`, `yarn typecheck`, `vp lint`, `vp fmt --check`: clean. - Rust (`RUST_TEST_THREADS=1`): stream, engine::, qwen3_5, qwen4_exp, memory_plan, model_thread, cache_limit, grpo::engine, qwen3_asr, qwen3::model: all pass. `mlx-paged-attn --lib`: 200 pass. - TS: `__test__/server`, `__test__/server/host`, cli serve / agent-args / agent-update / launch-claude / delegate: 1725 pass. ## Not in this PR - No live run. To check on qwen3.8-27b + dflash2 with `--idle-release 2m`: wired bytes stay up between turns, release and restore log lines, `/health`, 409 while streaming, and an A/B of the 500 ms refresh against 0. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Stage S22 of the Splash int8 KV alignment (stack #344). Base: FN1 (#357).
mlx serveandmlx agenttake--max-context N, as Splash 1.6 does. Past the native window, the target RoPE uses static YaRN.Splash rules ported
rotaryInverseFrequencies/attentionFactor: beta_fast 32, beta_slow 1, rotated q/k dims ×0.1·ln(f)+1. YaRN is on only where native is 262,144.rope_type/ GGUFrope.scaling.type).rope yarn <%.17g> <native>only with YaRN. The savedconfig.jsonnever carries the factor. Training refuses a YaRN load.max_position_embeddingsaccessors (Splash caps by the target only).Tests
0x3f85b665, and Splash's table bit for bit. A 100K cap publishes 102,400; 400K plans 409,600. A flat load whose 4 GiB plan holds 45,056 rows refuses 45,057.cargo fmt --check,cargo clippy --all-targets -D warnings,yarn typecheck,vp lint,vp fmt --check: clean. Rust filtersnn::rope engine:: paddleocr_vl qwen3_5 qwen4_exp functional hybrid_scheduler: all pass (RUST_TEST_THREADS=1).bge-native: the reranker drift that fix: test precision (reranker f32, MoE autograd stop_gradient, deterministic draft parity) #348 fixes. fix: test precision (reranker f32, MoE autograd stop_gradient, deterministic draft parity) #348 is not in this stack's base.Not in this PR
attentionPairscap is not ported. Fusedmlx_qk_norm_ropesteps aside under YaRN, so decode past native is slower.🤖 Generated with Claude Code