Repository navigation
feat(qwen4_exp): the Flash Next window and expert store come from the memory plan - #357
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: 63b270953b
ℹ️ 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".
63b2709 to
b43b26a
Compare
b43b26a to
6bf14f1
Compare
254506b to
19da873
Compare
… memory plan Splash planStreamedMemory + evaluateEngineMemoryPlan for a target that cannot spill. Before any payload read the load prices the fixed weights (hot set less the routed experts, MTP draft banks, vision tower), the routed experts (all, and a top-k floor) and the row cache's 128K-token share from the tensor descriptors. - The KV allowance comes first: the dynamic bytes at which every lane the load serves (AR, and MTP with MTP weights) holds min(trained, 64K). The experts load whole only where they leave the allowance and the row share; otherwise they stream with a cap of what is left. Floors over the hard budget refuse before any read. - The host only gates allocations: a refusal gives partial slots of what it admits while the plan keeps the store at its cap (hostHeldBackBytes). - After the load the engine plan is evaluated from what is resident; a shortfall under the allowance comes back from a streamed cap before any slot exists. The pool starts at a 96-block runway and grows by extents to the plan's maximum under its ceiling, with its registration kept current. Rows, MTP draft state and the transient share the dynamic budget. - The page prices the indexer's block keys; the cell is the real storage (115,651,584 B; Splash cellBytes 115,802,112). - --max-memory reaches qwen4_exp loads, and /v1/models shows a load-free estimate (estimateQwen4ExpContextWindow, descriptors only). 36 GB input (Splash's M5 Max, WS 30,150,672,384; hard 24,554,329,702): allowance 4,468,093,952, row share 1,744,830,464, store cap 14,459,363,158, AR window 65,536 (2,080 pages from a 96-page runway). With MTP weights: allowance 5,746,994,176, store 13,180,462,934, AR 95,225, MTP 65,655. A 128 GiB working set loads the experts whole: 262,144. Deleted: effective_context_limit (the .min(32,768) cap and its 2 GiB f32 estimate), the fixed 1 GiB pool, the host-sized weight budget (plan, automatic_budget, refresh_plan, direct_plan, DIRECT_LRU_BYTES), the 2 GiB prefill scratch cap and the 4 GiB WORKING_BYTES wired/state share. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t gates real allocations - The expert inventory counts transformers `layers.N.mlp.experts.*` as routed experts beside GGUF `_exps`, so an HF checkpoint streams under the plan instead of refusing its floors (Splash `targetWeights` / `streamedExperts`). - A refused scheduled-state need gives free pool extents back, then idle owners, before it errors (Splash `Cache::takeReclaim`): an MTP start after a long AR turn no longer finds the grown pool charged against it. - The load admits the fixed banks it builds, not the store's whole cap; the cap stays a plan number held back (Splash `ExpertStore`, `hostHeldBackBytes`). Co-Authored-By: Claude Opus 5.5 <[email protected]>
6bf14f1 to
b3f945c
Compare
…indow (#358) Stage S22 of the Splash int8 KV alignment (stack #344). Base: FN1 (#357). `mlx serve` and `mlx agent` take `--max-context N`, as Splash 1.6 does. Past the native window, the target RoPE uses static YaRN. ``` --max-context N (K = 1024, M = 1,000,000; 1..=1,010,000; unset = auto) N ≤ native (262,144) → caps every window; RoPE unchanged (bit for bit) N > native → YaRN factor N/native on the target RoPE; the draft keeps its own N > default-lane plan window → the load fails (Splash ServingRuntime::start text) families: qwen3_5, qwen3_5_moe, qwen4_exp; others refuse the option ``` ## Splash rules ported - YaRN math as Splash `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. - The plan prices the served window. Flash Next's KV allowance is N. - The default lane (DFlash2 with a draft, else the pool, else the flat lane) refuses an N above its plan window. The other lanes clamp to N. - A checkpoint whose RoPE is already scaled is refused (`rope_type` / GGUF `rope.scaling.type`). - 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. - Deleted: the four draft-window caps and the draft's `max_position_embeddings` accessors (Splash caps by the target only). ## Tests - 400K: factor 1.5625, attention factor `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. - 28 Rust and 15 TS 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 filters `nn::rope engine:: paddleocr_vl qwen3_5 qwen4_exp functional hybrid_scheduler`: all pass (`RUST_TEST_THREADS=1`). - One TS test fails, `bge-native`: the reranker drift that #348 fixes. #348 is not in this stack's base. ## Not in this PR - No live run past 262,144 tokens. The live check (100K / 400K on qwen3.8-27b, and T=0 output unchanged with no flag) is not run. - Splash's prefill `attentionPairs` cap is not ported. Fused `mlx_qk_norm_rope` steps aside under YaRN, so decode past native is slower. - YaRN angles match Splash within f32 tolerance, not bit for bit (MLX inverts the periods on the GPU). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b3f945c92b
ℹ️ 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".
|
|
||
| /// `indexBytesPerLayerPage`. | ||
| fn index_bytes_per_layer_page(&self) -> u64 { | ||
| KV_PAGE_TOKENS / ATTENTION_BLOCK_TOKENS * self.index_dimension * 2 |
There was a problem hiding this comment.
Price index keys using the checkpoint compression ratio
For an accepted checkpoint with indexer_compress_ratio other than 4, this prices a different number of index keys than the decoder stores. Config::validate permits these ratios, and attention_window.rs creates one index key per c.indexer_compress_ratio tokens. For example, a ratio of 2 requires twice the index bytes charged here. Because both the planned window and the scheduled-state pool charge use this layout, such a checkpoint can exceed its planned memory budget. Carry the checkpoint's compression ratio into the layout calculation, or explicitly reject unsupported ratios.
Useful? React with 👍 / 👎.
Stage FN1 of the Splash int8 KV alignment (stack #344). Base: S4 (#356).
The Flash Next (
qwen4_exp) context window and expert store now come from the one memory plan, the same as SplashplanStreamedMemory+evaluateEngineMemoryPlanfor a target that cannot spill.Changes
cellBytes115,802,112).--max-memoryreachesqwen4_exploads./v1/modelsshows a load-free estimate (estimateQwen4ExpContextWindow, descriptors only).effective_context_limit(the.min(32_768)cap and its 2 GiB f32 estimate), the fixed 1 GiB pool, the host-sized weight budget, the 2 GiB prefill scratch cap, and the 4 GiBWORKING_BYTESshare.Plan numbers
Tests
memory_plan load_plan qwen4_exp hybrid_scheduler engine paged_kv_cache_adapter— 974 passed, 0 failed, 12 ignored (real-checkpoint tests).MUTATIONS.md, 30 mutations).cargo clippy --all-targets -D warnings,cargo fmt --check,yarn typecheck(tsc -b --force),vp lint --type-aware --type-check,vp fmt --check: clean.vp test: 12 files, 252 passed.Not in this PR
🤖 Generated with Claude Code