quantized_weight_export#
Functional export of quantized weight tensors.
Functions
Build canonical ModelOpt HF configuration from named states or specs. |
|
Capture detached state for one weight, or |
|
Pack a logical weight into canonical ModelOpt checkpoint tensors. |
|
Return stable deployment metadata without retaining quantizer tensors. |
|
Merge state for logical weight shards concatenated along |
|
Restore opaque export state after its tensor values have been transported. |
|
Select logical indices that preserve complete quantization blocks. |
|
Separate opaque state metadata from tensor values for typed transport. |
- build_hf_quantization_config(named_states)#
Build canonical ModelOpt HF configuration from named states or specs.
- Parameters:
named_states (Mapping[str, _QuantizedWeightExportState | _QuantizedWeightExportSpec | None] | Iterable[tuple[str, _QuantizedWeightExportState | _QuantizedWeightExportSpec | None]])
- Return type:
dict[str, Any]
- capture_quantized_weight_export_state(module, weight_name='weight', *, cpu=True)#
Capture detached state for one weight, or
Nonewhen it is not quantized.- Parameters:
module (Module)
weight_name (str)
cpu (bool)
- Return type:
_QuantizedWeightExportState | None
- export_quantized_weight_tensors(weight, state, dtype, weight_name='weight')#
Pack a logical weight into canonical ModelOpt checkpoint tensors.
- Parameters:
weight (Tensor)
state (_QuantizedWeightExportState)
dtype (dtype)
weight_name (str)
- Return type:
OrderedDict[str, Tensor]
- get_quantized_weight_export_spec(module, weight_name='weight')#
Return stable deployment metadata without retaining quantizer tensors.
- Parameters:
module (Module)
weight_name (str)
- Return type:
_QuantizedWeightExportSpec | None
- merge_quantized_weight_export_states(states, weight_dim)#
Merge state for logical weight shards concatenated along
weight_dim.- Parameters:
states (Sequence[_QuantizedWeightExportState])
weight_dim (int)
- Return type:
_QuantizedWeightExportState
- restore_quantized_weight_export_state(metadata, tensors)#
Restore opaque export state after its tensor values have been transported.
- Parameters:
metadata (object)
tensors (Sequence[Tensor])
- Return type:
_QuantizedWeightExportState
- select_quantized_weight_export_state(state, weight_dim, indices)#
Select logical indices that preserve complete quantization blocks.
- Parameters:
state (_QuantizedWeightExportState)
weight_dim (int)
indices (Iterable[int] | Tensor)
- Return type:
_QuantizedWeightExportState
- split_quantized_weight_export_state(state)#
Separate opaque state metadata from tensor values for typed transport.
- Parameters:
state (_QuantizedWeightExportState)
- Return type:
tuple[object, tuple[Tensor, …]]