nemo_automodel.components.models.glm_moe_dsa.state_dict_adapter
nemo_automodel.components.models.glm_moe_dsa.state_dict_adapter
Module Contents
Classes
Functions
Data
API
Bases: Glm4MoeStateDictAdapter
Converts between HF GLM-MoE-DSA checkpoints and native format.
Extends Glm4MoeStateDictAdapter with handling for the DSA indexer weights that should not be quantized (k_norm, weights_proj).
Dequantize blockwise FP8 tensors before merging per-expert weights.
Dequantize GLM FP8 weights without changing other model adapters.
Parameters:
FP8 matrix or DTensor matrix. A DTensor uses its global shape while
to_local() supplies the rank-local [rows, cols] shard.
Matching blockwise scales. For a DTensor weight this is the full global scale grid loaded from the Hugging Face checkpoint.
Output floating-point dtype.
Height and width of each square FP8 quantization block.
Checkpoint tensor name used in diagnostics.
Returns: torch.Tensor
Dequantized tensor preserving the input DTensor mesh and placements when present.
Dequantize a GLM local shard while preserving the global FP8 block grid.
Parameters:
Local FP8 weight shard with shape [rows, cols].
Sliced scale grid with shape [block_rows, block_cols], where
each dimension covers the local shard plus its offset into the first block.
Output floating-point dtype.
Height and width of each square FP8 quantization block.
Element offset (row, col) of the shard origin
within its first global block. Each value is in [0, block_size).
Returns: torch.Tensor
Dequantized local tensor with the same shape as weight.
Run offset-aware GLM FP8 dequantization with Triton.
Parameters:
Local CUDA FP8 weight shard with shape [rows, cols].
Sliced CUDA scale grid covering the shard’s intersecting global blocks.
Output floating-point dtype.
Height and width of each square FP8 quantization block.
Element offset (row, col) of the shard origin
within its first global block. Each value is in [0, block_size).
Returns: torch.Tensor
Dequantized local CUDA tensor with the same shape as weight.
Return the exact global row/column origin of a GLM DTensor shard.
Parameters:
Global two-dimensional DTensor checkpoint destination.
Rank-local weight shard with shape [rows, cols].
Full global blockwise scale grid. Used only by the fallback placement calculation when checkpoint chunk metadata is unavailable.
Height and width of each square FP8 quantization block.
Returns: tuple[int, int]
Absolute element offset (row, col) of the local shard in the global weight.
Dequantize a local GLM shard whose origin is inside a global FP8 block.
Slice the global GLM scale grid for one rank-local weight shard.
Parameters:
Full global scale grid with shape [global_block_rows, global_block_cols].
Global two-dimensional DTensor checkpoint destination.
Rank-local FP8 weight shard with shape [rows, cols].
Height and width of each square FP8 quantization block.
Returns: torch.Tensor
Contiguous scale grid covering every global block intersected by the local shard.
Return whether key has a blockwise-FP8 scale in GLM checkpoints.