#[non_exhaustive]pub enum TernaryFormat {
Tq1_0,
Tq2_0,
I2sInt8,
}Expand description
Canonical packing schemes for ternary weights — the shared vocabulary across
crates. The byte-exact layout, pack, and unpack live in tritium-format;
this enum only fixes the names, block size, and effective width so every
crate agrees on them.
Both follow ggml’s 256-element super-block with one fp16 block scale.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Tq1_0
llama.cpp TQ1_0 — 5 trits per byte (3^5 = 243 < 256). 1.6875 bpw incl.
block scale. Most compact; unpack needs base-3 division — CPU/edge oriented.
Tq2_0
llama.cpp TQ2_0 — 2 bits per trit, 4 per byte. 2.0625 bpw incl. block scale. Cheap shift/mask unpack; matches BitNet’s int8 packing — GPU oriented.
I2sInt8
I2sInt8 — the IMMA (int8 tensor-core) GPU layout, derived from an I2_S
checkpoint at load (tritium_format::convert_i2s_to_int8). Weights stay
2-bit packed in VRAM (≈2.0 bpw, no per-block scale — the I2_S source
carries a single per-tensor f32 scale), interleaved so the IMMA kernel can
unpack them to int8 operands for mma.m16n8k32 in shared memory. Added in
v0.30 (ADR 0005) for the compute-bound prefill path; the CPU/reference
backends do not consume it and return an unsupported-format error — it is a
GPU-only packing.
Implementations§
Source§impl TernaryFormat
impl TernaryFormat
Sourcepub const fn bits_per_weight(self) -> f32
pub const fn bits_per_weight(self) -> f32
Effective bits per weight, block scale amortized over the block.
Sourcepub const fn block_size(self) -> usize
pub const fn block_size(self) -> usize
Weights per quantization block (ggml QK_K). One fp16 scale per block.
Sourcepub const fn is_bit_aligned(self) -> bool
pub const fn is_bit_aligned(self) -> bool
Whether unpack is a cheap shift/mask (true, GPU-friendly) or base-3
division (false, CPU/edge). Both Tq2_0 and I2sInt8 are 2-bit aligned.
Trait Implementations§
Source§impl Clone for TernaryFormat
impl Clone for TernaryFormat
Source§fn clone(&self) -> TernaryFormat
fn clone(&self) -> TernaryFormat
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more