Files
leleka/gpu/kar

KAR CUDA smoke target

vendor/libkar.h and vendor/libkar.cu are copied unchanged from local koference commit 806d2398ae1daaceb2917242911e5680cbfb3608, paths r08/code/libkar.h and r08/code/libkar.cu. Their SHA-256 values are 1d725069fd2c275423f5db70fb4190e7d51760e0c48a2a5ebe8c91993936ca92 and 331babd2a2f260abb7de602d414edd97399542ec1bccb23ffcdfad69dc0ade28 respectively. Keep these bytes and upstream provenance traceable when making local changes.

On Linux with CUDA 13 and a supported NVIDIA GPU, create a model-free fixture and compare its CPU and GPU decode checksums:

strata-next model smoke-fixture --output /tmp/strata-smoke.kar
cmake -S gpu/kar -B artifacts/kar-gpu-build -G Ninja -DCMAKE_CUDA_ARCHITECTURES=120
cmake --build artifacts/kar-gpu-build --target strata-kar-gpu-smoke
artifacts/kar-gpu-build/strata-kar-gpu-smoke /tmp/strata-smoke.kar smoke.expert 2 30
strata-next model checksum-kar-preview /tmp/strata-smoke.kar smoke.expert 2
artifacts/kar-gpu-build/strata-kar-gpu-smoke /tmp/strata-smoke.kar smoke.expert 2 30 --row 0
strata-next model checksum-kar-row /tmp/strata-smoke.kar smoke.expert 2 --row 0

An optional fifth argument is an overlay archive. The smoke target opens both archives with payload CRC verification, checks their virtual-F32 source identity and every replacement's name, shape, source dtype, source digest, and source offset, then reserves and decodes the requested tensor from the overlay when it is present there. It prints source=base or source=overlay. For a real overlay, first run strata-next model resolve-kar-overlay --base BASE.kar --overlay OVERLAY.kar: that Rust verifier additionally checks complete archive SHA-256 values and provenance. Keep both files unchanged between resolution and this smoke run. The smoke target alone does not authenticate the archive files against provenance and is not a serving loader.

The smoke program validates the KAR container and payload CRCs, reserves a chosen tensor's compressed level prefix in VRAM, decodes it on a CUDA stream, and reports a warm kernel median over the requested iterations. Compare output_fnv1a64 with the native CPU command above using the selected archive, tensor, and level. This is a kernel smoke measurement, not an end-to-end inference comparison or a model quality result. It does not yet link the decoder into Strata's serving path. Use the original model digest, archive digest, driver/CUDA versions, GPU, tensor, cache state, and iteration count when recording results.

Before any CUDA allocation, the smoke program checks the selected prefix, F32 output, and optional row ID against currently free VRAM. It leaves at least 512 MiB or one sixteenth of total VRAM free, whichever is larger, and refuses the run if that reserve would be crossed. This admission check protects shared GPU experiments; another process can still allocate memory afterward, so CUDA allocation errors remain possible. It is not an inference scheduler.

--row ROW_ID selects the CUDA row-gather decoder for one row of a compressed record. The row ID is local to the selected KAR part, so --row 0 on a split PLE part addresses that part's first row. This mode stages the same complete compressed level prefix with kar_reserve, then allocates and writes only one F32 row. It reports mode=row and the one-row output checksum. Compare a real-model result with model checksum-kar-row on the selected archive and part name; that CPU command verifies the complete archive before bounded range decoding. The one-row synthetic fixture above has the same checksum as its full-tensor decode. Row mode does not reduce the initial PCIe transfer of that part and does not make the full model fit in VRAM.