QuantFormat

Trait QuantFormat 

Source
pub trait QuantFormat:
    Send
    + Sync
    + Debug {
    // Required methods
    fn name(&self) -> &'static str;
    fn base_variant(&self) -> Nvfp4Variant;
    fn is_ignored(&self, module_path: &str) -> bool;

    // Provided method
    fn variant_for(&self, module_path: &str) -> Nvfp4Variant { ... }
}
Expand description

A serialization layout for quantized weights.

Implementations describe a loading policy for a checkpoint: which tensor names to read, which dtypes to expect, and which module paths should stay BF16 (the ignore list). The heavy per-linear loading code remains in weight_map.rs; this trait is a thin dispatch wrapper that selects the right variant while honoring per-module overrides.

Required Methods§

Source

fn name(&self) -> &'static str

Human-readable name for logs ("modelopt", "compressed-tensors", "fp8-blockscaled").

Source

fn base_variant(&self) -> Nvfp4Variant

The Nvfp4Variant that this format maps to in the existing weight_map.rs dispatch. Allows the trait to co-exist with the legacy variant-based call sites during incremental migration.

Source

fn is_ignored(&self, module_path: &str) -> bool

Is module_path in the format’s ignore list (should be loaded as dense BF16 rather than quantized)? module_path is the tensor name with the trailing .weight_scale_2 / .weight_packed / etc. stripped — i.e. the prefix passed to weight_map::quantized_any.

Provided Methods§

Source

fn variant_for(&self, module_path: &str) -> Nvfp4Variant

Effective variant for a specific module: the base variant, or Bf16Raw if the module is in the ignore list. Loaders should consult this instead of base_variant when loading per-module.

Implementors§