okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

albedocmake: strata_kernels links strata_kernels_cpu (iq_kernels.cu reads the latent colscale table from expert_layout.cpp; strata-q36ref failed to link)a4af4df61

main
1 file

files

README.md2.7 KiB

V100 / Swift IQ2_XS / 32k / --kv int8: the KV read path

Test bed: 2x Tesla V100-SXM2-16GB (SM 7.0), CUDA 12.8, one card. No full-engine run; kernel microbench only.

1. Audit - where int8 KV is decoded, and whether it is vectorized

The default decode path is the fused split-K attention (g_fast_attn = true, src/core/layer.cpp:42, chosen at layer.cpp:950-952), which reads the pools directly - no gather:

The non-fast fallback gathers int8 into an fp16 scratch first, then attends over it:

The KV-streaming copy is already wide: copy_kernel, src/kernels/cuda/kv_stream.cu:161-171, uint4 (16 B).

2. Vectorization

The gather (kv_gather_q8_kernel) was 4 values/thread: two char4 (4 B) loads + two ushort4 (8 B) stores. The experimental build (-DSTRATA_EXPERIMENTAL_SM60=ON, Pascal/Volta) adds an 8-wide kv_gather_q8_wide_kernel: one uint2 (8 B) load of codes, one uint4 (16 B) store of the dequantized fp16, one scale per thread instead of two. The 8 values lie in one 64-value group, and the arithmetic is unchanged ((float) code * scale -> f16_from_f32, packed two halfs per 32-bit word), so the output is byte-identical. The ready-made engine keeps exactly the 4-wide kernel.

kv_q8_parity: OK, worst INT8-vs-FP16 error 0.590 steps (bitwise codes, scales and gather; unchanged).

Microbench (kv_q8_parity --bench, 2,051 cells / 2 KV heads / 256 dims, 32k pool, random cells, V100):

us/callGB/s
before (4-wide)15.85401
after (8-wide)14.05452

+11.4% on the gather. The default decode path (g_fast_attn) does not gather; its decode (load8_q8, qsa_decode_attn.cu:46-54) already reads 8 int8 with one uint2 and is arithmetic-bound (8 I2F + 8 FMUL per cell), which __byte_perm/half2 cannot improve while staying bit-exact. The gather is what the non-fast, streaming and hybrid paths use.

3. int8 vs q4_0 vs k8v4 at 32k

TBD