Skip to main content

Module qtensor

Module qtensor 

Source
Expand description

QTensor — weight tensor with pluggable storage.

Two backings, one interface:

  • F32 — owned dense floats (small models, tests). Every operation is bit-identical to the historical &[f32] code paths.
  • Mapped — quantized bytes zero-copy from the CMF mmap (q8_row / q8_2f). The matvec is fused: int8 rows × f32 activations, the q8_2f column field folds into a pre-scale of the input (x'[i] = col[i]·x[i]), so the inner loop is the same i8 dot as q8_row. This is what lets a 15B file run in a few GB of RSS.

Extension point: new dtypes = new match arm here, nothing else moves.

Enums§

QTensor

Functions§

q2tp_matmat_for_test
q2tp_matvec_for_test
Batched q2tp matmat: scalar row kernel over every batch column. CPU prefill only — decode rides the graph, so plain and correct beats clever here. Test doors into the host 2-bit kernels: the stand’s heap corruption pointed at down-shaped tensors, and the private fns need a way to be held to a reference without a model file around them.
set_blocked_override
Force the blocked GEMM on or off, ignoring the environment; None restores it. For tests that need to run BOTH paths and compare them: blocked_enabled caches its answer for the life of the process, which is right when the environment is the only input, but leaves a test that flips CMF_X86_BLOCKED between two calls comparing a path against itself — or against whatever a test running in parallel latched first.
sgemm_public
Row-major f32 GEMM, exposed for offline tools (the AWNP pass builds a per-layer projection and applies it to every expert; a naive triple loop would turn a two-minute job into half an hour).