Repository navigation
qwen38: a q8_0 KV cache, set by --cache-type-k and the default on a checkpoint folder - #956
Conversation
There was a problem hiding this comment.
Verdict: MUST_FIX: the q8_0 paths read correct (layout, NaN rows, bytes, shared-memory sizes), but the PR adds a CLI flag to a gate that nothing uses.
Must fix
1. --kv-only is an element nothing needs
gate_qwen4exp_e2e.rs:5796: the gate had no argument parsing. The new flag has no caller in the tree (no just recipe, no script). It copies the gate's tail (tally, exit) and returns before tier::expect_fixture_oracle, so a partial run prints a tally that looks like the gate's. Removing it now is cheaper than keeping a second exit path.
Fix: delete the doc sentence at line 256 and the block at lines 5796 to 5804 (let kv_only … the closing }). The (kv) clause stays in the full run.
Non-blocking
⚠ The default flips to q8_0 on a checkpoint folder with no timed A/B: qwen38.rs:1405. "Performance first" makes the faster path the default. docs/research/adaptive-picks.md §3.3 item 6 says the one unknown is whether the q8_0 flash reads at the f16 flash's byte rate, and asks for tools/ref/depth-decode.sh with BLOOMERY_DEPTHS="1024 4096 16384" and arms f16|q8_0. The PR shows bytes and equal text, not tok/s. Please add that A/B on the GB10 with the conditions (tok/s @ n, depth, card).
⚠ No PTX proof that the f16 entries are unchanged: flash_gqa.rs:2374 (KeyWalk::row replaces stage_row, seg_mma_p and listed_seg_tiles! read through S::word) and flash_gqa_prefill.rs:1965 (listed_rows! gains key < KEY_TILE on the f16 path). The class is "add": ptx-scan must be base plus exactly the new entries. The PR runs ptx-spill-check filtered to _q8, which cannot show it. Paste just ptx-compare BASE BIN.
⚠ No repo test holds the q8_0 host-state paths: saved.rs:127 (Plane::U32, halves), scratch.rs:1392 (KvPlanes::spans) and seq38_bytes(.., Q8) against PlanInputs::seq_state_bytes. Every gate call passes KvQ8::F16 (gate_qwen38_serve.rs:3707), and (kv) never saves a state. Mutant: Plane::halves returns 1 for U32. A prefix restored from the prompt cache then lands at the wrong stride and no assertion turns red; only the PR's own serve script (not in the tree) would. Direction: run the existing seq save/load clause of gate_qwen4exp_e2e on the (kv) model, and compare the two byte owners at Q8.
⚠ Also minor: the bool to KvQ8 mapping is written three times (qwen38.rs:1244, body38.rs:1908, mtp38.rs:369); one KvQ8::of(bool) would own it. Mtp38::store_host (mtp38.rs:517) refuses q8_0 but KvPlanes::f16's doc (scratch.rs:458) names only the qwen3.5 taps.
Checked
- Duplicates: about 25 new items checked. The
in_q8pick repeats an existing idiom (qwen3moe_place.rs:374). The one dryer pair (with_kv_q8~with_indexer_top_k) is a setter shape. - Complexity: the flagged functions grow by one match arm per format (harmless).
#[kernel]bodies read for correctness only. - Silent failure: 7 sites followed. All end in a named error or the fault word (listed rows at or past ctx give a fault plus NaN in both formats).
- Tests: the zero-scale mutant and the precedence flip turn tests red. The Spans mutant above does not.
- Gates: no band moved. The
gpuunsafe pin carriesPIN(2026-10-29). - Escape catalog: no match (no shell changed).
Notes
- No FAIL-first output for clause 21,
(kv)orhw_q8_gated_…(plant the zero-scale mutant, show red). - No
nvidia-smiline or commit hashes in the PR body, so the GPU evidence list is incomplete.
Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/bloomery_serve_qwen38.rs, crates/gpu-gates/src/bin/gate_qwen35moe_attn.rs, crates/gpu-gates/src/bin/gate_qwen38_media.rs … and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
| //! prompt flashes over the cache's q8 tiles, below and past the selection's onset, then the | ||
| //! selected decode flash) judged against ik's by (t)'s rule and bands: the cache's | ||
| //! quantization must not move the argmax past a named tie nor a layer output past | ||
| //! [`FREE_BAND`]. `--kv-only` runs this clause alone. |
There was a problem hiding this comment.
--kv-only has no caller; drop the flag (see the code block below).
| //! [`FREE_BAND`]. `--kv-only` runs this clause alone. | |
| //! [`FREE_BAND`]. |
| let kv_only = std::env::args().any(|a| a == "--kv-only"); | ||
| if kv_only { | ||
| let (man, _) = input_manifest(BATCH)?; | ||
| let (_, toks, _) = man.step()?; | ||
| tier::sc(KV_CLAUSE)?; | ||
| ok &= kv_q8(toks, &mut 0)?; | ||
| println!("{}", tier::tally_line()); | ||
| return if ok { Ok(()) } else { Err(checks_failed()) }; | ||
| } |
There was a problem hiding this comment.
The gate had no arguments and nothing passes this one; the early return also skips expect_fixture_oracle.
| let kv_only = std::env::args().any(|a| a == "--kv-only"); | |
| if kv_only { | |
| let (man, _) = input_manifest(BATCH)?; | |
| let (_, toks, _) = man.step()?; | |
| tier::sc(KV_CLAUSE)?; | |
| ok &= kv_q8(toks, &mut 0)?; | |
| println!("{}", tier::tally_line()); | |
| return if ok { Ok(()) } else { Err(checks_failed()) }; | |
| } |
9a46f82 to
801b2ee
Compare
There was a problem hiding this comment.
Since the last review:
Must-fix 1 fixed: --kv-only and its separate exit path are removed.
Verdict: CLEAN: no must-fix finding remains; four advisory items remain open.
Non-blocking
⚠ 1 still open: no timed A/B for the folder default. qwen38.rs:1633 defaults checkpoint folders to q8_0.
Each selecting layer's K/V payload changes from 2048 to 1088 B per attended position [derived: two KV heads, 256 values per head, both K and V], with dequantization added. Add a GB10 f16/q8_0 depth A/B at 1024/4096/16384, with tok/s, generation length and commands, to establish the default's cost.
⚠ 2 still open: no comparison proving existing f16 PTX is unchanged. flash_gqa_prefill.rs:1766 shares the revised flash body.
Add just ptx-compare BASE generate_ds41 output against the PR base. The filtered _q8 spill run does not compare the existing f16 entries.
⚠ 3 still open: q8 checkpoint regression coverage. gate_qwen4exp_e2e.rs:938 omits save/load on its q8 model; the prefix-restore clause runs on f16.
Extend prefix-restore checks to q8, including saved-byte counts and code-plane strides. Mutant: Plane::halves returns 1 for U32; the current restore tests use u16 stores and do not detect this wrong stride.
⚠ 4 partly fixed: the bool mapping now uses KvQ8::of. scratch.rs:458 describes only qwen3.5 host taps.
Include the MTP host reader's f16-only contract: mtp38.rs:537 also calls this accessor.
Checked
Confirmed the four cited paths, folder-format precedence, U32 span units and the separate f16 prefix-restore call. The findings are distinct, remain advisory and match no exclusion or escape-catalog pattern. No tests executed.
Notes
The PR body lacks the nvidia-smi line, both tested commit hashes and FAIL-first output for the new GPU clauses.
Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/bloomery_serve_qwen38.rs, crates/gpu-gates/src/bin/gate_qwen35moe_attn.rs, crates/gpu-gates/src/bin/gate_qwen38_media.rs … and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
|
The review is done and the contribution check passed, so I'm merging this. |
…#956) Co-Authored-By: Claude Opus 5.5 <[email protected]>
Qwen3.8 FP4-Local의 KV 캐시를 q8_0으로 저장해 DGX Spark에서 KV 메모리를 줄이고,
--cache-type-k로 고를 수 있게 합니다.What and why
The Qwen3.8 seat kept its KV cache in f16 only. This PR adds a q8_0 cache for it, picked by
--cache-type-k f16|q8_0(orBLOOMERY_QWEN3_KV). A checkpoint folder such as the FP4-Local folder defaults to q8_0, and a GGUF file stays on f16.--cache-type-vis refused by name.On the FP4-Local folder the attention store shrinks from 967,921,280 B to 773,279,360 B at 16,896 positions. Greedy output on a 5-token and a 12,123-token prompt is the same text as f16.
What changes, one item for each commit:
gpu: the selected-key flashes (decodegqa_flash_seg_mma_256_p12_sel_q8, promptgqa_prefill_flash_256_p12_sel_q8and_p12_sel_gated_q8) and the MTP draft's dense flashes (gqa_flash_seg_mma_256_p4_q8,gqa_prefill_flash_256_p4_gated_q8) read a q8_0 cache. The existing kernels take the key source as a type (F16KvorQ8Kv), so the f16 and q8_0 paths share one walk. The host side takes the cache as oneCachePlanesvalue, with one length rule and one alignment check. A q8_0 cache on a scalar segment is refused by name.qwen38: one owner,KvPlanes, holds the planes, the format, the zeroed state, the saved spans and the gated prompt flash. The plan bytes, the MTP store and the checkpoint spans take the format. The seat reads--cache-type-k, thenBLOOMERY_QWEN3_KV, then the folder default, andsetupprintscache=. The lever's unset value is now "no value" so the folder default can apply.generate_qwen3moeno longer refusesBLOOMERY_QWEN3_KV=q8_0on Qwen3.8.gate_qwen4exp_e2egains a(kv)clause.docs/serving.mdanddocs/contrib/dgx-spark.mdstate the default.tools: the five new_q8entries are pinned in the PTX shape tables with spill 0 and local 0, measured on the card. Thegpuunsafe pin goes from 2812 to 2823 with aPIN(2026-10-29)line naming the 11 new blocks, which stage the q8_0 key rows the way the existing q8_0 prefill stage does.Release notes: Added: Qwen3.8 can keep its KV cache in q8_0 with
--cache-type-k q8_0, and does so by default on a checkpoint folder such as FP4-Local.Code shape
The review reads these first. A box left unticked needs one line of why.
KeyWalk::row) and one macro body overKvSrc; the cache format has one owner (KvPlanes) and one length rule (q8_plane_lens).stage_rowis replaced byKeyWalk::row; nothing is left behind.--cache-type-vare named errors.gpuunsafe count, and it carriesPIN(2026-10-29):and its reason.cargo fmtandcargo clippyare clean on what I touched; the lint count did not go up.Duplication found or removed (
path:line), or "none": none.What I ran
On a DGX Spark (GB10),
just gate-gpu-qwen35moe-attnbuilds and runsgate_qwen35moe_attn. The new q8_0 lines, bit for bit against the f16 entries on the dequantized cache:gate_qwen4exp_e2eon the Qwen3.8 fixture, the(kv)clause:The q8_0 prompt flash against its f16 twin:
The
_q8entries against the pinned PTX shape tables, on the GB10 with ptxas 13.3.73, for each ofsm_121a,sm_121andsm_86, with$aset to the arch. The first line below issm_121a(sm_121passes with the same counts), the second issm_86:The seat's unit tests:
The real binary,
bloomery-serve -m <Qwen3.8-Flash-Next-FP4-Local folder>with the default and with--cache-type-k f16, on a 5-token and a 12,123-token prompt, the long one sent twice (the first load line is the default, the second--cache-type-k f16):Hardware (if the change is for a machine)
nvidia/Qwen3.8-Flash-Next-FP4-LocalAI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.