klyn.math.nn.quantization.Quantizer.quantize
method
public static quantize(source as Path, destination as Path, options as QuantizationOptions = null) as QuantizationReport
Description

Converts a local Safetensors file or a Hugging Face checkpoint directory. A directory output retains configuration/tokenizer files and includes a quantization.json manifest with the exact scheme, original dtypes, scales and per-shard SHA-256. Missing or invalid shards abort the operation. Publication is atomic in the destination's parent. Existing outputs are never replaced, and a failed conversion does not publish partial weights. Working data buffers are bounded by options.bufferBytes, plus scale and header metadata; they do not grow with the largest tensor or model.

Parameters
ParameterDescription
sourceLocal file or complete model snapshot directory.
destinationNew file or new directory, matching the source kind.
optionsQ8 group size, buffer budget and progress settings.
Returns

Size and reconstruction-error summary after successful publication.

Throws
  • IOException for missing origin, an existing destination or failed I/O.
  • ValueException for an invalid checkpoint, aliases or non-finite weights.
Example

report = Quantizer.quantize(Path("model.safetensors"), Path("model-q8.safetensors"), QuantizationOptions(verbose=false))