[PR #2427] [Engine] HC_Q8: skip the layers' bf16 hyper-connection copies on a layer split too #4039

Open
opened 2026-11-07 15:32:41 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/2427
Author: @paltian
Created: 10/14/2026
Status: 🔄 Open

Base: main ← Head: hc-q8-layer-split


📝 Commits (3)

  • 9f2bf87 HC_Q8: skip the layers' bf16 hyper-connection copies on a layer split too
  • 3908d71 native_dense: the HC_Q8 skip comment matches the layer split too
  • f7f4f61 HC_Q8: a trimmed stage keeps the Q8_0 copies of its own layers only

📊 Changes

2 files changed (+11 additions, -6 deletions)

View changed files

📝 src/core/native_dense.cpp (+6 -3)
📝 src/program/generate.cpp (+5 -3)

📄 Description

Problem and result

STRATA_HC_Q8=1 reads the hyper-connection down/up projections from Q8_0 copies. On a single GPU it also leaves their bf16 copies out of the arena (add_hc_skip). On a layer split that skip was gated off (!multi_gpu in generate.cpp), so each card kept the bf16 copies and got the 0.63 GiB of Q8_0 copies on top. HC_Q8 cost VRAM on a split instead of saving it.

With this change a split skips the bf16 copies the same way, and each card gives the freed VRAM to its expert cache. Measured on 0.2.1 (c093ac26), UD-Q4_K_XL, 2x RTX 5060 Ti, --layer-split auto:

before after
canonical tensors skipped 303 495 (+192 = the 4x48 hc_*_down/up rows)
dense weights loaded from the pack 1416 MiB 216 MiB
expert cache, both cards 2967 slots (9.15 GiB) 3370 slots (10.29 GiB)
auto split K=6 (CUDA1 2341 slots) K=7 (CUDA1 2735 slots)
prompt 32k / 120k 1128 / 1334 tok/s 1160 / 1380 tok/s (+2.8% / +3.4%)
decode 4k / 32k (10 pairs) 28.2 / 33.1 tok/s 30.5 / 35.5 tok/s (+7.8% / +7.4%)

This is #2427, closed by the 2026-10-19 tracker reset, rebased on 0.2.1 and re-validated. It answers the review there: the default reach via setup (below), a same-config A/B on the split (Validation), and the native_dense.cpp comment (fixed). It extends the single-GPU HC_Q8 path (b60aab1b) to a layer split. #704 was a requantization approach and was closed as "not with a layer split".

Default reach, needs the owner's call: setup.py:3190 writes STRATA_HC_Q8=1 for CUDA UD-* installs. So this change is active by default on every CUDA UD-* layer split, not only for users who set the variable. There the prompt path and the per-token read switch from the bf16 copy to the Q8_0 dequantized into scratch (the read one GPU has used since b60aab1b). The freed VRAM also moves the auto placement (split point, prompt chunk, cache slots). Greedy output on such a split is therefore no longer bit-identical to 0.2.1 (KL below). STRATA_HC_Q8=0 keeps the full bf16 read as before.

Approach

One gate in src/program/generate.cpp: drop !multi_gpu from the add_hc_skip condition. Plus a comment fix in native_dense.cpp.

The prompt path and the token read already take these rows through hc_bf16_view, which dequantizes the Q8_0 into per-device scratch. So a split can drop the bf16 copies exactly as one GPU does. add_hc_skip names all hc_*_down/up rows. Each stage's loader still limits itself to its own layers through in_range, and a skipped row is quantized on the host from the pack file. Kernels are untouched.

What changes on a split: the verify windows already read the Q8_0 copies with and without the patch (STRATA_HC_Q8=1: 0.63 GiB of Q8_0 hyper-connection projections in both logs). The prompt path and the per-token read move from the bf16 copy to the Q8_0 through hc_bf16_view, as on one GPU.

Validation

Environment: AMD Ryzen 7 5700X3D (8C/16T), 94 GB RAM, 2x RTX 5060 Ti 16 GB (sm_120, driver 610.57.04; CUDA0 on a x4 link, probed 3.1 GB/s, CUDA1 x8, 14.3 GB/s), Debian kernel 6.12.107, CUDA build -DCMAKE_CUDA_ARCHITECTURES="86;120". Patched 3908d716 (= this branch) against stock c093ac26, both built with identical options. The server config is my production config (UD-Q4_K_XL, --spec 4 --mtp, --kv int8, --prefill auto, --layer-split auto, STRATA_HC_Q8=1).

Passed:

  • ctest -j 4 on 3908d716: 66/68 passed. ple_parity and platform_memory_test (mlock, ulimit -l) fail identically on stock.
  • A/B speed, docs/COMMUNITY_BENCHMARKS.md protocol: a fresh server per arm and round, alternating order, one discarded warm-up, unique prompt prefix (0 tokens reused), thinking off, temperature 0. Engine timings come from the engine log, TTFT from the client stream. All requests finish: stop, no errors.
    • Run 1: 5 rounds, ~4k/32k/120k prompts, 256 tokens. Prompt 4k +1.0% (4/5 pairs faster), 32k +2.8% (5/5, +2.1..+3.2%), 120k +3.4% (5/5, +3.0..+6.2%), TTFT 120k 93.0 → 90.1 s.
    • Run 2: 10 rounds, ~4k/32k prompts, 512 tokens. Prompt 32k +3.3% (10/10, +2.2..+4.1%). Decode 4k +7.8% (10/10, +1.0..+10.4%), 32k +7.4% (10/10, +2.7..+13.1%).
    • The same A/B on 0.2.0 (e88ee39d, 5 rounds) gave prompt 32k +2.9%, 120k +3.1%, 5/5 pairs each.
    • The single-pair A/B posted in #2427 (one 91,712-token prompt, a different reserve config) saw prompt and decode unchanged. The runs here have 5-10 pairs per size and see the gain consistently.
  • --batch 2 on the split, two concurrent requests (45k + 49k and 4k + 4k tokens), patched, stock and stock again. Run in the 0.2.1 default (one serial group) and with --batch-groups 2 (pipelined, 2 groups of 1). All answers complete, correct and coherent, no errors in the engine logs.
  • Output check, same prompts on both arms: 1 of 4 cases bit-identical, the others diverge after 85-504 characters with equivalent content. With the split pinned (layer_split "7", --prefill 4096) the divergence moves later. Changing only the placement on stock (auto vs pinned) diverges about as early as the patch does, so placement is a large part of the difference, beside the bf16 → Q8_0 read.
  • KL on the split (on #2427's branch, 2026-10-15, the same one-line change; not repeated on 0.2.1): tools/quant_quality.py, --layer-split auto, CUDA_VISIBLE_DEVICES=0,2, reserve raised so the MTP head fits, the same on both arms. Prompt path (prompt/pcompare, 20 prompts of 256-1000 tokens, full vocabulary): top-1 100% (20/20), KL mean / median / max 0.00134 / 0.00042 / 0.00781. Decode (run/compare, teacher-forced, 4,995 positions): top-1 95.10%, KL mean / p99 0.02858 / 0.4818, perplexity 4.062 vs 4.020. The decode figure includes the cache-size effect (1539 → 1932 slots): changing only the cache size moves it about as much (#704: top-1 94.1%, KL 3.4e-2). Draft acceptance unchanged (53.7% vs 54.0%, 3 runs each).
Per-run results

Run 2, decode tok/s (rounds 0-9):

  • 4k stock 28.1 28.5 28.6 28.4 27.8 27.8 30.3 28.0 28.0 29.2
  • 4k patched 31.0 29.7 29.7 30.6 30.7 30.2 30.6 30.3 29.6 30.8
  • 32k stock 30.0 31.4 32.1 33.7 33.1 32.4 33.6 33.6 33.8 33.1
  • 32k patched 32.6 35.5 36.3 36.5 36.6 35.2 36.2 35.6 34.7 34.5

Run 2, prompt 32k tok/s:

  • stock 1119.7 1122.8 1124.5 1134.4 1127.3 1135.2 1127.1 1138.7 1125.3 1128.4
  • patched 1164.4 1157.8 1159.6 1161.6 1167.0 1160.3 1165.3 1170.9 1171.1 1170.4

Run 1, prompt tok/s (rounds 0-4):

  • 4k stock 496.8 490.9 497.2 493.1 498.3 / patched 495.1 507.9 506.2 502.0 501.1
  • 32k stock 1126.7 1137.6 1135.3 1124.5 1128.3 / patched 1150.4 1161.6 1171.2 1157.6 1160.2
  • 120k stock 1336.4 1317.0 1301.8 1334.3 1338.5 / patched 1379.8 1380.4 1382.3 1378.3 1378.6

Run 1, decode tok/s:

  • 4k stock 28.3 29.2 28.9 28.5 28.8 / patched 19.1 30.3 30.4 31.6 29.4
  • 32k stock 32.9 31.2 33.3 32.0 31.8 / patched 27.2 35.1 36.1 35.2 35.9
  • 120k stock 33.2 34.5 32.3 32.9 33.1 / patched 32.9 38.2 36.7 35.6 37.0

Failed:
None observed. One observation in the decode numbers: 3 of 20 patched servers across the 0.2.0 and 0.2.1 five-round runs decoded 10-35% slower for their whole lifetime (0 of 20 stock). They showed the same cache layout, cache hit rate, draft acceptance and graph captures as the fast ones. The 10-round decode run (10 patched servers) had none, and the cause is not found.

Not run:

  • The KL check on 0.2.1 itself (the numbers above are from the pre-reset branch, same change). The single-GPU KL of the Q8_0 read is in docs/QUANTS.md (UD-Q4_K_XL: mean 0.0562 → 0.0526, p99 0.925 → 0.716).
  • HIP / SYCL / Metal builds (the gate is shared code. gfx12 defaults HC_Q8 on, so a HIP split would be affected the same way).
  • A split with --keep-canonical (the gate sits inside !keep_canonical, unchanged).
  • More than two GPUs, and --batch-mtp.
  • No test in ctest covers this path. I did not add one: the change is a gate on an existing, tested path, and a unit test would only restate it.

Limits

  • The gain comes from the freed VRAM, so it depends on how far the experts already fit: on cards that hold all experts it is smaller.
  • Part of the measured gain is the auto split moving (K=6 → 7). That is a consequence of the freed VRAM, not separate from it, but a manual layer_split sees only the cache part.
  • In batch mode stock itself is not reproducible run to run for one of the four cases (both group modes), so batch output comparisons are only content checks.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/2427 **Author:** [@paltian](https://github.com/paltian) **Created:** 10/14/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `hc-q8-layer-split` --- ### 📝 Commits (3) - [`9f2bf87`](https://github.com/Niko1221/Strata/commit/9f2bf87efe62680c2e94eb579f84d1963c247e2d) HC_Q8: skip the layers' bf16 hyper-connection copies on a layer split too - [`3908d71`](https://github.com/Niko1221/Strata/commit/3908d716af339605c04ed2c555deb81c9e0c9318) native_dense: the HC_Q8 skip comment matches the layer split too - [`f7f4f61`](https://github.com/Niko1221/Strata/commit/f7f4f61c1a6eb7730a597468b22d7d79919c8114) HC_Q8: a trimmed stage keeps the Q8_0 copies of its own layers only ### 📊 Changes **2 files changed** (+11 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `src/core/native_dense.cpp` (+6 -3) 📝 `src/program/generate.cpp` (+5 -3) </details> ### 📄 Description ## Problem and result `STRATA_HC_Q8=1` reads the hyper-connection down/up projections from Q8_0 copies. On a single GPU it also leaves their bf16 copies out of the arena (`add_hc_skip`). On a layer split that skip was gated off (`!multi_gpu` in `generate.cpp`), so each card kept the bf16 copies **and** got the 0.63 GiB of Q8_0 copies on top. HC_Q8 cost VRAM on a split instead of saving it. With this change a split skips the bf16 copies the same way, and each card gives the freed VRAM to its expert cache. Measured on 0.2.1 (`c093ac26`), UD-Q4_K_XL, 2x RTX 5060 Ti, `--layer-split auto`: | | before | after | |---|---:|---:| | canonical tensors skipped | 303 | 495 (+192 = the 4x48 `hc_*_down/up` rows) | | dense weights loaded from the pack | 1416 MiB | 216 MiB | | expert cache, both cards | 2967 slots (9.15 GiB) | 3370 slots (10.29 GiB) | | auto split | K=6 (CUDA1 2341 slots) | K=7 (CUDA1 2735 slots) | | prompt 32k / 120k | 1128 / 1334 tok/s | 1160 / 1380 tok/s (+2.8% / +3.4%) | | decode 4k / 32k (10 pairs) | 28.2 / 33.1 tok/s | 30.5 / 35.5 tok/s (+7.8% / +7.4%) | ## Related discussion This is #2427, closed by the 2026-10-19 tracker reset, rebased on 0.2.1 and re-validated. It answers the review there: the default reach via setup (below), a same-config A/B on the split (Validation), and the `native_dense.cpp` comment (fixed). It extends the single-GPU HC_Q8 path (b60aab1b) to a layer split. #704 was a requantization approach and was closed as "not with a layer split". **Default reach, needs the owner's call:** `setup.py:3190` writes `STRATA_HC_Q8=1` for CUDA UD-* installs. So this change is active by default on every CUDA UD-* layer split, not only for users who set the variable. There the prompt path and the per-token read switch from the bf16 copy to the Q8_0 dequantized into scratch (the read one GPU has used since b60aab1b). The freed VRAM also moves the auto placement (split point, prompt chunk, cache slots). Greedy output on such a split is therefore no longer bit-identical to 0.2.1 (KL below). `STRATA_HC_Q8=0` keeps the full bf16 read as before. ## Approach One gate in `src/program/generate.cpp`: drop `!multi_gpu` from the `add_hc_skip` condition. Plus a comment fix in `native_dense.cpp`. The prompt path and the token read already take these rows through `hc_bf16_view`, which dequantizes the Q8_0 into per-device scratch. So a split can drop the bf16 copies exactly as one GPU does. `add_hc_skip` names all `hc_*_down/up` rows. Each stage's loader still limits itself to its own layers through `in_range`, and a skipped row is quantized on the host from the pack file. Kernels are untouched. What changes on a split: the verify windows already read the Q8_0 copies with and without the patch (`STRATA_HC_Q8=1: 0.63 GiB of Q8_0 hyper-connection projections` in both logs). The prompt path and the per-token read move from the bf16 copy to the Q8_0 through `hc_bf16_view`, as on one GPU. ## Validation Environment: AMD Ryzen 7 5700X3D (8C/16T), 94 GB RAM, 2x RTX 5060 Ti 16 GB (sm_120, driver 610.57.04; CUDA0 on a x4 link, probed 3.1 GB/s, CUDA1 x8, 14.3 GB/s), Debian kernel 6.12.107, CUDA build `-DCMAKE_CUDA_ARCHITECTURES="86;120"`. Patched `3908d716` (= this branch) against stock `c093ac26`, both built with identical options. The server config is my production config (UD-Q4_K_XL, `--spec 4 --mtp`, `--kv int8`, `--prefill auto`, `--layer-split auto`, `STRATA_HC_Q8=1`). **Passed:** - `ctest -j 4` on `3908d716`: 66/68 passed. `ple_parity` and `platform_memory_test` (mlock, `ulimit -l`) fail identically on stock. - A/B speed, docs/COMMUNITY_BENCHMARKS.md protocol: a fresh server per arm and round, alternating order, one discarded warm-up, unique prompt prefix (0 tokens reused), thinking off, temperature 0. Engine timings come from the engine log, TTFT from the client stream. All requests `finish: stop`, no errors. - Run 1: 5 rounds, ~4k/32k/120k prompts, 256 tokens. Prompt 4k +1.0% (4/5 pairs faster), 32k +2.8% (5/5, +2.1..+3.2%), 120k +3.4% (5/5, +3.0..+6.2%), TTFT 120k 93.0 → 90.1 s. - Run 2: 10 rounds, ~4k/32k prompts, 512 tokens. Prompt 32k +3.3% (10/10, +2.2..+4.1%). Decode 4k +7.8% (10/10, +1.0..+10.4%), 32k +7.4% (10/10, +2.7..+13.1%). - The same A/B on 0.2.0 (`e88ee39d`, 5 rounds) gave prompt 32k +2.9%, 120k +3.1%, 5/5 pairs each. - The single-pair A/B posted in #2427 (one 91,712-token prompt, a different reserve config) saw prompt and decode unchanged. The runs here have 5-10 pairs per size and see the gain consistently. - `--batch 2` on the split, two concurrent requests (45k + 49k and 4k + 4k tokens), patched, stock and stock again. Run in the 0.2.1 default (one serial group) and with `--batch-groups 2` (pipelined, 2 groups of 1). All answers complete, correct and coherent, no errors in the engine logs. - Output check, same prompts on both arms: 1 of 4 cases bit-identical, the others diverge after 85-504 characters with equivalent content. With the split pinned (`layer_split "7"`, `--prefill 4096`) the divergence moves later. Changing only the placement on stock (auto vs pinned) diverges about as early as the patch does, so placement is a large part of the difference, beside the bf16 → Q8_0 read. - KL on the split (on #2427's branch, 2026-10-15, the same one-line change; not repeated on 0.2.1): `tools/quant_quality.py`, `--layer-split auto`, `CUDA_VISIBLE_DEVICES=0,2`, reserve raised so the MTP head fits, the same on both arms. Prompt path (`prompt`/`pcompare`, 20 prompts of 256-1000 tokens, full vocabulary): top-1 100% (20/20), KL mean / median / max 0.00134 / 0.00042 / 0.00781. Decode (`run`/`compare`, teacher-forced, 4,995 positions): top-1 95.10%, KL mean / p99 0.02858 / 0.4818, perplexity 4.062 vs 4.020. The decode figure includes the cache-size effect (1539 → 1932 slots): changing only the cache size moves it about as much (#704: top-1 94.1%, KL 3.4e-2). Draft acceptance unchanged (53.7% vs 54.0%, 3 runs each). <details><summary>Per-run results</summary> Run 2, decode tok/s (rounds 0-9): - 4k stock 28.1 28.5 28.6 28.4 27.8 27.8 30.3 28.0 28.0 29.2 - 4k patched 31.0 29.7 29.7 30.6 30.7 30.2 30.6 30.3 29.6 30.8 - 32k stock 30.0 31.4 32.1 33.7 33.1 32.4 33.6 33.6 33.8 33.1 - 32k patched 32.6 35.5 36.3 36.5 36.6 35.2 36.2 35.6 34.7 34.5 Run 2, prompt 32k tok/s: - stock 1119.7 1122.8 1124.5 1134.4 1127.3 1135.2 1127.1 1138.7 1125.3 1128.4 - patched 1164.4 1157.8 1159.6 1161.6 1167.0 1160.3 1165.3 1170.9 1171.1 1170.4 Run 1, prompt tok/s (rounds 0-4): - 4k stock 496.8 490.9 497.2 493.1 498.3 / patched 495.1 507.9 506.2 502.0 501.1 - 32k stock 1126.7 1137.6 1135.3 1124.5 1128.3 / patched 1150.4 1161.6 1171.2 1157.6 1160.2 - 120k stock 1336.4 1317.0 1301.8 1334.3 1338.5 / patched 1379.8 1380.4 1382.3 1378.3 1378.6 Run 1, decode tok/s: - 4k stock 28.3 29.2 28.9 28.5 28.8 / patched 19.1 30.3 30.4 31.6 29.4 - 32k stock 32.9 31.2 33.3 32.0 31.8 / patched 27.2 35.1 36.1 35.2 35.9 - 120k stock 33.2 34.5 32.3 32.9 33.1 / patched 32.9 38.2 36.7 35.6 37.0 </details> **Failed:** None observed. One observation in the decode numbers: 3 of 20 patched servers across the 0.2.0 and 0.2.1 five-round runs decoded 10-35% slower for their whole lifetime (0 of 20 stock). They showed the same cache layout, cache hit rate, draft acceptance and graph captures as the fast ones. The 10-round decode run (10 patched servers) had none, and the cause is not found. **Not run:** - The KL check on 0.2.1 itself (the numbers above are from the pre-reset branch, same change). The single-GPU KL of the Q8_0 read is in docs/QUANTS.md (UD-Q4_K_XL: mean 0.0562 → 0.0526, p99 0.925 → 0.716). - HIP / SYCL / Metal builds (the gate is shared code. gfx12 defaults HC_Q8 on, so a HIP split would be affected the same way). - A split with `--keep-canonical` (the gate sits inside `!keep_canonical`, unchanged). - More than two GPUs, and `--batch-mtp`. - No test in ctest covers this path. I did not add one: the change is a gate on an existing, tested path, and a unit test would only restate it. ## Limits - The gain comes from the freed VRAM, so it depends on how far the experts already fit: on cards that hold all experts it is smaller. - Part of the measured gain is the auto split moving (K=6 → 7). That is a consequence of the freed VRAM, not separate from it, but a manual `layer_split` sees only the cache part. - In batch mode stock itself is not reproducible run to run for one of the four cases (both group modes), so batch output comparisons are only content checks. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4039
No description provided.