mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #5475] [Engine] opt-in int8 copies for the persistent hc read (STRATA_HC_PERSIST_Q8) #5451
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#5451
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/5475
Author: @Vop3p
Created: 11/7/2026
Status: 🔄 Open
Base:
main← Head:pr/hc-persist-q8📝 Commits (2)
1a5274eOpt-in int8 copies for the persistent hc read (STRATA_HC_PERSIST_Q8)158413ffused_gr.hpp: include for size_t📊 Changes
3 files changed (+204 additions, -16 deletions)
View changed files
📝
include/strata/kernels/fused_gr.hpp(+7 -0)📝
src/core/verify.cpp(+19 -0)📝
src/kernels/cuda/fused_gr.cu(+178 -16)📄 Description
Problem and result
With
STRATA_HC_PERSIST=1the verifier's hyper-connection read (down + inject, then up) runs as one persistent kernel per read. On gfx1030 it is bound by memory bandwidth: it streams the bf16 hc weights once per read, and synchronization is only ~4 us of each read. Halving the bytes is the lever.STRATA_HC_Q8already makes Q8_0 copies of these weights, but it does not apply to the persistent read: it runs a separate path, which on this card is slower thanHC_PERSIST.STRATA_HC_PERSIST_Q8=1(withSTRATA_HC_PERSIST=1) makes int8 copies of each hc read's weights at start-up, on Q8_0's grid: one fp16 scale per 32 values, the same rounding asSTRATA_HC_Q8. The persistent kernel then reads those copies. The output changes, by about as much asSTRATA_HC_Q8changes it.Decode, 2x RX 6900 XT, 10 cold-start interleaved pairs, off vs on, same binary. The output text differs between off and on (int8 weights), so the draft acceptance on a given prompt differs too. Time per verify window is therefore the fair number:
Plain decode tok/s on the same runs was +7.2% at 32K and -0.5% at 4K. Both differences mostly reflect acceptance: the windows went 126 -> 120 at 32K and 122 -> 128 at 4K, the same in every pair. I do not claim tok/s from two prompts. The prompt read does not use this path.
Quality (our production tree with the same kernel, teacher-forced KL against a double-precision reference, 8 conversation segments). Top-10 overlap with the reference:
STRATA_HC_Q8=1(upstream)STRATA_HC_PERSIST_Q8=1(this PR)Mean KL was within the segment-to-segment noise for all arms (a single segment varies by up to 5x), so I do not read it either way. The start-up check reports a max relative difference of 0.00497 against the bf16 read. An earlier version of this patch used one fp32 scale per 128 columns, and one per row for
up; it reported 0.00705 and lost 1.3 pt, which is why the grid is now Q8_0's.Related discussion
none (opt-in, decode verifier only; it follows the existing
STRATA_HC_Q8/STRATA_HC_PERSISTpair)Approach
fused_gr_persist_q8_preparebuilds one read's copies at start-up, outside graph capture:qd [NR][D](down rows, then inject rows) withsdh [NR][D/32]fp16 scale bits, andqu [D][LR]withsuh [D][LR/32]. The copies are keyed by the read's bf16w_down, so a read without copies keeps the bf16 kernel.Verifier::initcalls it for each of this stage's layers and prints the count and MiB. Layers whose weights already carryq8_scale(STRATA_HC_Q8) are skipped.q8g32_rows_kernel: d = amax / 127 per 32 contiguous values, then q = round(x / d) with d already rounded to fp16, which is ggml's reference rounding.Q8template argument. In the down/inject phase each lane pair shares one 32-value group and its scale; in the up phase each thread applies five group scales.fused_gr_persist_q8_on()is true only after the int8 kernel passes a start-up check on the current card against the bf16 read (bar 2e-2; ~5e-3 measured).--vram-reserveor context.Validation
Environment: 2x RX 6900 XT (gfx1030, 16 GB, PCIe 4.0 x8 each), Ryzen 5 5600X, 128 GB DDR4-3200, Ubuntu 26.04, kernel 7.0.0-42, ROCm 10.0 runtime (
/opt/rocm/lib).Passed:
54828c7e+ this change,-DSTRATA_ENABLE_HIP=ON -DCMAKE_HIP_ARCHITECTURES=gfx1030 -DSTRATA_NATIVE_EXPERTS=ON -DSTRATA_PREFILL_MMQ=ON -DSTRATA_Q6K_EXPERTS=ON -DGGML_HIP_GRAPHS=ON -DGGML_HIP_NO_VMM=ON -DSTRATA_BUILD_TESTS=ON.ctest -j 1: 221/224 (hc_persist_parityandhc_persist_default_offpass; they cover the bf16 read, not the int8 one). The three failures are the same on main54828c7ewithout this change:ple_parity(Q2_0 gguf relative path),conversation_copy_streams_test(148 MiB first copy stream) andisa_guard_check(CPU iq512 function).--spec 3 --spec-min-p 0.6 --pipeline-windows 1 --kv int8, parallel 1,STRATA_HC_PERSIST=1plus our usual HIP env.benchmark.py4K + 32K, 256 tokens each, arms alternating. Each arm produced the same text in all 10 runs. 0 stalls.--batch-mtp.Failed:
Not run:
fused_gr.cunext to the existing persistent kernel. I built and ran only HIP gfx1030.Limits
Developed with an AI coding assistant; every number above was measured on the machine described in Validation.
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.