quantized_weight

Non-mutating export helpers for quantized checkpoint weights.

Functions

build_hf_quantization_config

Build the canonical ModelOpt HF config from canonical module states.

capture_quantized_weight_export_state

Capture export state without changing the module or its quantizers.

export_quantized_weight

Pack one canonical weight without mutating it or its quantizers.

quantized_weight_export_states_compatible

Return whether two states share one deployment format and tensor layout.

quantized_weight_export_states_equal

Return whether two opaque export states describe the same checkpoint state.

replicate_quantized_weight_export_state

Authorize scalar state replication across a fused projection split.

synchronize_quantized_weight_export_state

Max-reduce scalar state for ranks that shard one logical weight.

build_hf_quantization_config(layer_states)

Build the canonical ModelOpt HF config from canonical module states.

Parameters:

layer_states (Mapping[str, object | None] | Iterable[tuple[str, object | None]])

Return type:

dict

capture_quantized_weight_export_state(module, weight_name='weight', *, weight_quantizer=None, input_quantizer=None)

Capture export state without changing the module or its quantizers.

Parameters:
  • module (Module)

  • weight_name (str)

  • weight_quantizer (object | None)

  • input_quantizer (object | None)

Return type:

_QuantizedWeightExportState

export_quantized_weight(weight, state, *, dtype=None)

Pack one canonical weight without mutating it or its quantizers.

Parameters:
  • weight (Tensor)

  • state (object)

  • dtype (dtype | None)

Return type:

_QuantizedWeightExport

quantized_weight_export_states_compatible(left, right)

Return whether two states share one deployment format and tensor layout.

Parameters:
  • left (object)

  • right (object)

Return type:

bool

quantized_weight_export_states_equal(left, right)

Return whether two opaque export states describe the same checkpoint state.

Parameters:
  • left (object)

  • right (object)

Return type:

bool

replicate_quantized_weight_export_state(state, projection_count)

Authorize scalar state replication across a fused projection split.

Parameters:
  • state (object)

  • projection_count (int)

Return type:

tuple[object, …]

synchronize_quantized_weight_export_state(state, *, group=None, device=None)

Max-reduce scalar state for ranks that shard one logical weight.

Parameters:
  • state (object)

  • device (device | str | None)

Return type:

object