Skip to content

gpu, qwen38, qwen3: the KV cache's unset format is one rule (gpu::kv_format), f16 for a GGUF file and a checkpoint folder alike, and the load names what chose it - #1119

Merged
juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-cmn-kv-default
Nov 2, 2026

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

KV cache 형식을 정하지 않았을 때의 기본값을 한 곳(gpu::kv_format)의 규칙으로 모으고, GGUF 파일과 checkpoint 폴더 모두 f16이 되게 했으며, load 기록에 그 선택의 출처를 남깁니다.

What and why

The Qwen seats chose an unset KV cache format in three places. The qwen38 seat ran q8_0 for a checkpoint folder and f16 for a GGUF file, the qwen3 seat had its own f16 default, and two gate binaries repeated the choice. This PR moves the choice into one owner, crates/gpu/src/kv_format.rs. KvChoice::choose reads --cache-type-k, then BLOOMERY_QWEN3_KV, and otherwise picks f16. The container the weights come from is not an input. All four callers (serve_seats/qwen38.rs, serve_seats/qwen3.rs, generate_qwen3moe.rs, gate_qwen4exp_nvfp4.rs) read that rule.

The qwen38 setup record and the qwen3 load record gain cache_from=flag|lever|default, so a log says what chose the format. The checked-in record schema is updated.

One default changes: a checkpoint folder of Qwen3.8 (FP4-Local, NVFP4) that ran q8_0 when the format was unset now runs f16. A GGUF file already ran f16 and does not change. --cache-type-k q8_0 still selects q8_0.

Release notes: Changed: an unset KV cache format is f16 for every Qwen model whichever file format it loads from, so a checkpoint folder of Qwen3.8 now defaults to f16 instead of q8_0, and the load record names what chose the format.

Code shape

The review reads these first. A box left unticked needs one line of why.

  • No second copy. Logic two models (or two call sites) share has one common owner; I lifted it there instead of
    copying it (AGENTS.md "Common code first", docs/rust-quality.md R14). Where I found an existing copy, I
    named it below.
  • Model code holds only architecture facts. A model's own files carry only what its architecture forces
    (tensor shapes, the attention kind, the quant). A common owner gained no per-model branch, flag or trait method.
  • Dead code is gone. Nothing I made unused is left behind (functions, flags, gate clauses, docs).
  • No silent failure. Undefined input is a named error or panic, never a defined-looking output.
  • Comments state what is true now. No dates, issue numbers or how a bug was found (tools/check-comments.sh).
  • No relaxed gate. No band, tolerance or lint moved.
  • cargo fmt and cargo clippy are clean on what I touched; the lint count did not go up.

Duplication found or removed (path:line), or "none": the container rule KvQ8::of(folder.is_some()) in crates/gpu-gates/src/bin/shared/serve_seats/qwen38.rs, the separate f16 default in crates/gpu-gates/src/bin/shared/serve_seats/qwen3.rs, KvQ8::choose in crates/gpu/src/arch/qwen3moe/body.rs and KvQ8::of(path.is_dir()) in crates/gpu-gates/src/bin/gate_qwen4exp_nvfp4.rs are replaced by KvChoice::choose in crates/gpu/src/kv_format.rs. KvQ8 moved there from body.rs.

What I ran

The upstream base is 3e31152774d8fe13ec2b97699913a3e0488e1509 and the PR head is b3798f236fbef5219ed53a81cd33d38a1a6f454c.

Card and driver on the GB10 (raw output):

$ nvidia-smi
Mon Nov  2 00:36:54 2026       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 595.84                 Driver Version: 595.84         CUDA Version: 13.3     |
+-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GB10                    On  |   0000000F:01:00.0 Off |                  N/A |
| N/A   49C    P8              5W /  N/A  | Not Supported          |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI              PID   Type   Process name                        GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|  No running processes found                                                             |
+-----------------------------------------------------------------------------------------+
$ nvidia-smi --query-gpu=name,driver_version --format=csv,noheader
NVIDIA GB10, 595.84

Card and driver on the RTX 5090 (raw output):

$ nvidia-smi
Mon Nov  2 07:52:59 2026       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 595.99.02              Driver Version: 595.99.02      CUDA Version: 13.2     |
+-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GeForce RTX 5090        Off |   00000000:01:00.0 Off |                  N/A |
|  0%   41C    P8             12W /  400W |       2MiB /  32607MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI              PID   Type   Process name                        GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|  No running processes found                                                             |
+-----------------------------------------------------------------------------------------+
$ nvidia-smi --query-gpu=name,driver_version --format=csv,noheader
NVIDIA GeForce RTX 5090, 595.99.02

Models and SHA-256 of each file. Qwen3.8 UD-Q4_K_XL, unsloth/Qwen3.8-Flash-Next-GGUF, revision 766911a6b7369840a91dbcd95f9f997acaab6cd6, file UD-Q4_K_XL/Qwen3.8-Flash-Next-UD-Q4_K_XL-00001-of-00004.gguf:

Qwen3.8-Flash-Next-UD-Q4_K_XL-00001-of-00004.gguf  4448186216b3af4cc558bbce2c3213f01608f8f8b2e5267a9767971dd3ec8082

Qwen3-30B-A3B, unsloth/Qwen3-30B-A3B-Instruct-2507-GGUF, revision eea7b2be5805a5f151f8847ede8e5f9a9284bf77:

Qwen3-30B-A3B-Instruct-2507-Q4_K_M.gguf  6c997b8af17debdfb01d890214400ccbab00db6acc0ba8da5de1cc906c4774d0

Qwen3.6-35B-A3B, lmstudio-community/Qwen3.6-35B-A3B-GGUF, revision 68a34855558af61cbef0324d31f411be8a506b08:

Qwen3.6-35B-A3B-Q4_K_M.gguf  4ac6a06bce551257267f49ad2226f8671a22519ccc1a4dde9d5b433d1f2a410d

The gate on the RTX 5090 below also loads Qwen3.8-27B-Q4_K_M.gguf.

Gates

On the GB10, the common rule's unit test and the record and host-rule tests for the changed code, on the PR head:

bash tools/gate.sh --gpu --oxide -p bloomery-gpu --release --lib -- kv_format
test kv_format::tests::the_cache_format_is_the_flags_then_the_levers_then_f16 ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 487 filtered out; finished in 0.00s
cargo test -p bloomery-gpu-gates --lib record::
just gate-q38-serve-rules
test result: ok. 24 passed; 0 failed; 0 ignored; 0 measured; 172 filtered out; finished in 0.03s
test result: ok. 9 passed; 0 failed; 0 ignored; 0 measured; 314 filtered out; finished in 0.11s
test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 320 filtered out; finished in 0.00s
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 322 filtered out; finished in 0.00s
test result: ok. 33 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s

On the GB10, gate_qwen38_serve runs the real bloomery-serve-qwen38 on UD-Q4_K_XL and checks the server's setup cache against the rule:

BLOOMERY_MODEL=qwen4exp ./tools/box.sh 'export BLOOMERY_GATE_V41_LOAD=1 && . tools/ref/ref-paths.sh && A=$(bash tools/arch.sh) && cargo oxide build --arch $A -- -p bloomery-gpu-gates --features deepseek41,gemma-embedding2,hf --release --bin bloomery-serve-qwen38 --bin gate_qwen38_serve && cargo oxide build --arch $A -- -p bloomery-gpu-gates --features gpu --release --bin generate_qwen3moe && D=target/q38-serve-gate-kv && mkdir -p $D && T="The capital of France is" && I=$REF_TOKENS && bash tools/gpu-gate.sh generate_qwen3moe --place gate --tokens "$I" -n 16 > $D/gen.log && for arm in drafted lookup; do bash tools/gpu-gate.sh gate_qwen38_serve --arm $arm --gen $D/gen.log --prompt "$T" --ids "$I" --dir $D/$arm; done'
gpu-gate.sh: generate_qwen3moe ran 51 s (exit 0)
check props_engine_vram_kv: PASS
check setup_names_the_kv_rule: PASS
gpu-gate.sh: gate_qwen38_serve ran 263 s (exit 0)
gpu-gate.sh: gate_qwen38_serve ran 237 s (exit 0)

On the RTX 5090, gate_qwen3_serve runs the real bloomery-serve on Qwen3-30B-A3B, Qwen3.6-35B-A3B and Qwen3.8-27B and checks each load record's cache against the rule:

BLOOMERY_MODEL=qwen3moe ./tools/box.sh 'A=$(bash tools/arch.sh) && cargo oxide build --arch $A -- -p bloomery-gpu-gates --features glm5next,clef,mimo2,solar2,minimaxm3,flint,vision,gemma-embedding2,hf,checkpoint --release --bin bloomery-serve --bin gate_qwen3_serve && cargo oxide build --arch $A -- -p bloomery-gpu-gates --features gpu --release --bin generate_qwen3moe && D=target/qwen3-serve-gate-kv && mkdir -p $D && BLOOMERY_GATE_CARD=any bash tools/gpu-gate.sh gate_qwen3_serve --model "${MODEL_Q3}" --model "${MODEL_Q36}" --model "${MODEL_Q38_27B}" --dir $D'
== ${MODEL_Q3}
check default_load_names_the_kv_rule: PASS
check q8_resident_drops_by_the_planes: PASS
check whole_fit_counts_the_planes_granules: PASS
== ${MODEL_Q36}
check default_load_names_the_kv_rule: PASS
check q8_resident_drops_by_the_planes: PASS
check whole_fit_counts_the_planes_granules: PASS
gpu-gate.sh: gate_qwen3_serve ran 309 s (exit 0)
PASS count 198

The clippy ratchet on the PR head (cargo clippy --workspace --all-targets with the workspace feature set):

chain-clippy: lint rc 0 (^warning: 0, the ratchet 0 in tools/lint-ratchet.txt)

Hardware (if the change is for a machine)

GPU Driver CUDA
NVIDIA GB10 595.84 13.3
NVIDIA GeForce RTX 5090 595.99.02 13.2

AI help

AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.

…format), f16 for a GGUF file and a checkpoint folder alike, and the load names what chose it
@github-actions github-actions Bot added dgx-spark The DGX Spark (aarch64, GB10) port documentation Improvements or additions to documentation gpu The card engine: crates/gpu*, crates/app host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset needs-gpu Changes code a card must check, and carries no gate run on a card tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo labels Nov 2, 2026
@github-actions github-actions Bot removed the needs-gpu Changes code a card must check, and carries no gate run on a card label Nov 2, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict: CLEAN: No reachable behavior failure or proven quality defect remains in the changed code.

Non-blocking

⚠ Cover the checkpoint default: crates/gpu-gates/src/bin/gate_qwen38_serve.rs:1059.
The supplied runs use GGUF, and this gate opens the model through Split. Restoring the seat's old folder-only q8_0 default leaves these checks green. Extend the existing coverage to a checkpoint folder and show that mutant failing. This protects the only default that changes.

⚠ Attach the cited timing evidence: docs/serving.md:232.
The docs claim slower q8_0 prefill and no decode gain, but the body supplies functional gates only. Attach the same-lease A/B commands and output, including prompt lengths and decode depths, and PTX equality for the move. This makes the default's performance rationale reviewable.

Checked

Duplicates: 10 added or moved definitions checked; both dryer pairs read. Their enum-to-word matches describe different domains.

Complexity: props_engine 50→56, served 66→70, placement 21→22. Growth adds sequential record checks and error propagation, with no new model-specific branch.

Silent failure: invalid cache words return GpuError::Shape; choose defaults only when both the flag and lever are unset.

Tests, static mutation check: changing kv_format.rs:104 to Q8, reversing precedence at :88, or changing provenance makes the common-rule assertions fail. Removing the preflight validation at serve_seats/qwen38.rs:1632 makes the q4 refusal test fail. The folder-only default mutant survives the supplied coverage, as noted above.

Gates: replacement default cases and the changed Qwen3 clause carry dated PIN reasons; no numeric band or tolerance moved. FAIL-first output is absent from the body.

Escape catalog: no C1–C4 pattern matched. No ledger lessons are in force.

Notes

Static review. GPU gates were not rerun locally; the body includes card gate commands and output.

Card check: gpu-evidence. This pull request changes crates/gpu-gates/src/bin/bloomery_serve_qwen38.rs, crates/gpu-gates/src/bin/gate_clef_hidden.rs, crates/gpu-gates/src/bin/gate_gemma_embedding2_serve.rs … and carries a gate run on the author's card, which counts as verified.

🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)

@github-actions github-actions Bot added the gpu-evidence Verified on the author's card: the pull request carries the gate run and its output label Nov 2, 2026
@juliankang4

Copy link
Copy Markdown
Collaborator Author

The review is done and the contribution check passed, so I'm merging this.

@juliankang4
juliankang4 merged commit e635e3f into midagedev:main Nov 2, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dgx-spark The DGX Spark (aarch64, GB10) port documentation Improvements or additions to documentation gpu The card engine: crates/gpu*, crates/app gpu-evidence Verified on the author's card: the pull request carries the gate run and its output host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant