nemo_automodel.components.models.kimi_k25_vl.state_dict_adapter
nemo_automodel.components.models.kimi_k25_vl.state_dict_adapter
Module Contents
Classes
Functions
Data
API
Bases: MoESplitExpertsStateDictMixin, StateDictAdapter
State dict adapter for KimiK25VL checkpoints.
Expand expert ‘weight’ keys to INT4 triplets: _packed/_scale/*_shape.
MoE expert weights are known to be INT4 quantized in the HF checkpoint.
Convert a single tensor from native format to HuggingFace format.
Parameters:
Fully qualified name of the tensor in native format
The tensor to convert
Additional arguments for conversion
Returns: list[tuple[str, Any]]
List of (fqn, tensor) tuples in HuggingFace format
Convert HF checkpoint state dict to model format.
This handles INT4 dequantization: _packed/_scale/*_shape -> weight
Convert from native model state dict to HuggingFace format.
If quantization=True, expert weights are quantized to INT4.
Dequantize INT4 packed weights to bfloat16.
Extracts local tensors from DTensors before unpacking (bitwise ops don’t work on DTensor). Both weight_packed and weight_scale should have matching sharding so .to_local() gives corresponding slices automatically.
Parameters:
INT4 packed weights [out_features, in_features // 8], may be DTensor
Per-group scales [out_features, num_groups], should be DTensor with same sharding
Original shape [2], stores global dimensions
Elements per scale group (default 32)
Target device for computation
Quantize bfloat16/float16 weights to INT4 packed format.
Returns: torch.Tensor
INT4 values packed into int32 (8 values per int32)