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
27 files

files

README.md3.3 KiB
blockldl.py2.7 KiB
build.sh1.8 KiB
build_swap.py10.3 KiB
conftest.py411 B
fetch_orig.py2.7 KiB
gyro_column_profile.py3.2 KiB
gyro_error_profile.py4.9 KiB
gyro_reencode.py5.3 KiB
gyro_vs_original.py5.0 KiB
hf_slice.py3.7 KiB
make_corpus.py8.5 KiB
merge_dumps.py1.4 KiB
pilot.py11.8 KiB
pilot_summary.py2.0 KiB
proxy_diag_error.py4.9 KiB
proxy_ldl.py5.0 KiB
run_parts.py3.9 KiB
sanity_greedy.py2.8 KiB
swap_compare.py3.7 KiB
test_blockldl.py1.7 KiB
test_tqenc_py.py2.4 KiB
tqenc.cpp22.7 KiB
tqenc.hpp7.2 KiB
tqenc_hip.cpp25.3 KiB
tqenc_hip_test.cpp6.5 KiB
tqenc_test.cpp28.2 KiB

Trellis encoder (research, branch f-dsv41-enc)

An encoder for the trellis expert formats that Strata already decodes (TQ2_T, TQK6, TQK7 of agentionai's llama.cpp fork) and for two experimental lower rates, K5 (22 bytes per 128 weights, 1.375 bpw) and K4 (18 bytes, 1.125 bpw), in two versions: TQK5X / TQK4X (ids 224 / 225, experimental version 2) use a computed codebook, two LCG words per state masked into four fp16 (src/kernels/cpu/tq_computed.hpp, from the z440 lab's "3single"), and TQK5T / TQK4T (226 / 227, version 1) the fork's hashed point table. On real DeepSeek expert tensors the computed code costs 0.02 to 0.04 dB (K5 7.07 against 7.10 dB, K4 5.61 against 5.63) and needs no table lookups in a GEMV. The fork's types keep their table. Written for the DeepSeek-V4.1-Flash compression plan (gate 2 and the start of gate 3). Nothing here changes an existing type, layout or default; the engine's CPU decoder only gains K = 5 and 4 (ids 224 / 225, experimental version 1).

filewhat
tqenc.hpp, tqenc.cppthe encoder: tail-biting Viterbi on the 2^15-state shift trellis, fp16 scale refinement, importance weights; a C API
tqenc_test.cppthe tests (about 64,000 checks): streams and the circular wrap, Viterbi against a naive DP, planted solutions, bit-exact decode against tq_states.hpp and the scalar / AVX2 / AVX-512 kernels, special blocks, thread determinism, quality against the rate-distortion limit
tqenc_hip.cpp, tqenc_hip_test.cppthe same search on a GPU (HIP, gfx1201): bit-identical blocks, about 20 M weights/s on one R9700
../tqenc.pyPython wrapper (ctypes): encode, decode, the input-only block-128 Hadamard, signs, the .tqx container
pilot.py, pilot_summary.pythe block-quality pilot on a source GGUF (local files or HTTP range requests)
gyro_reencode.py, gyro_vs_original.py, gyro_error_profile.py, hf_slice.pychecks against agentionai's Gyro files and the original Qwen weights

Build and test (Linux x86-64, g++ with AVX2; the GPU part needs ROCm):

sh tools/trellis/build.sh test && build-tqenc/tqenc_test          # --quick skips the quality table
sh tools/trellis/build.sh lib  && python3 tools/trellis/test_tqenc_py.py
sh tools/trellis/build.sh hip  && HIP_VISIBLE_DEVICES=3 build-tqenc/tqenc_hip_test

build.sh hip compiles tqenc.cpp with g++ on purpose: under hipcc, ggml-common-tq.h turns its codebook into a __device__ variable and the host side reads zeros.

Format facts the encoder relies on (checked against the decoder, not the comments)