Skip to main content

Module ternary_gpu

Module ternary_gpu 

Source
Expand description

Task #12 / STELLAR §A — native GPU dispatch of the ternary GEMM + on-device parity.

Runs shaders/ternary_gemm.wgsl (ternary::TERNARY_GEMM_WGSL) on a real wgpu device. This is the piece the FFN inference loop calls to execute a ternary-packed weight on the GPU; the #[test] below verifies it on silicon against the byte-exact CPU oracle ternary::ternary_gemm_cpu (it skips cleanly when no adapter is present, e.g. headless CI).

Native only — the wasm WebGPU path reuses the same WGSL through gguf_bridge’s pipeline set when the kernel is spliced into the layer loop (the remaining integration step).

Structs§

TernaryFfnResident
A1b (STELLAR §A): the resident 2-bit branchless ternary-FFN GEMM dispatcher — the perf core.

Functions§

ternary_gemm_gpu
Execute the base-3 ternary GEMM on the GPU (ternary_gemm.wgsl).
ternary_gemm_gpu_2bit
Execute the 2-bit branchless ternary GEMM on the GPU (ternary_gemm_2bit.wgsl). packed must be 2-bit packed (ternary::pack_trits_2bit).