klyn.math.nn.quantization.DeviceQuantizedMatrix.DeviceQuantizedMatrix
constructor
public DeviceQuantizedMatrix(reader as GGUFReader, info as GGUFTensor, device as Device, buffer as Byte[], reorder as Int = 0, keyHeads as Long = 1l, valueHeads as Long = 1l, valueDim as Long = 1l)
Description

Loads exact GGUF F32, F16, BF16, Q8_0, Q4_K, Q5_K or Q6_K parameters. Scales are widened losslessly from F16 to F32; integer codes are unchanged. K-quants and 16-bit floats are decoded only in processor registers, not copied into a larger device tensor or requantized into a different variant. Optional head permutation restores the checkpoint's logical HF ordering.

Parameters
ParameterDescription
readerValidated GGUF descriptor reader.
infoSelected tensor.
deviceCPU/GPU selector.
bufferShared bounded upload buffer.
reorderInternal Qwen head-layout permutation selector.
keyHeadsLinear key head count.
valueHeadsLinear value head count.
valueDimLinear value width.
Throws
  • ValueException for unsupported encoding or dimensions.
Example

matrix = DeviceQuantizedMatrix(reader, reader.tensors["output.weight"], Device.gpu[0], buffer)