mstar.model.glm5_next.weight_loader#

HF GLM-5.3-Flash checkpoint loading for the glm5_next module tree.

Functions

build_glm5_next_read_plan(checkpoint_keys, ...)

Keys-to-read + per-key slice specs for the TP fast read path.

build_glm5_next_stacked_params(n_routed_experts)

cross_check_index(index_path[, config, ...])

Dry-run the load pipeline over the safetensors index and diff it against the expected module tree.

expected_parameter_paths(config[, load_mtp])

The module tree the schedule implies: parameter path -> the number of checkpoint tensors that must land in it (stacked shards count each; dequant-absorbed scale siblings do not).

glm5_next_name_remapper(name)

load_glm5_next_hf_weights(module, weights, ...)

load_weights(module, source[, device])

resolve_index_names(index_names, config[, ...])

Classify every checkpoint name through the real pipeline stages.

restore_fp32_params(module)

Re-widen params the checkpoint stores fp32 before loading into them.

skip_vision_and_mtp_keys(weights, ...[, ...])

Drop vision-tower keys, and MTP-layer keys unless load_mtp, before any dequant buffering.

mstar.model.glm5_next.weight_loader.build_glm5_next_read_plan(checkpoint_keys, config, tp_rank, tp_size, load_mtp=False)[source]#

Keys-to-read + per-key slice specs for the TP fast read path.

Parameters:
Return type:

tuple[set[str], dict[str, tuple[int, int, int]]]

mstar.model.glm5_next.weight_loader.build_glm5_next_stacked_params(n_routed_experts, fp8_experts=False)[source]#
Parameters:
  • n_routed_experts (int)

  • fp8_experts (bool)

Return type:

list[StackedParamRule]

mstar.model.glm5_next.weight_loader.cross_check_index(index_path, config=None, load_mtp=True, max_examples=10)[source]#

Dry-run the load pipeline over the safetensors index and diff it against the expected module tree. Prints a report; returns pass/fail.

Parameters:
Return type:

bool

mstar.model.glm5_next.weight_loader.expected_parameter_paths(config, load_mtp=True)[source]#

The module tree the schedule implies: parameter path -> the number of checkpoint tensors that must land in it (stacked shards count each; dequant-absorbed scale siblings do not).

Parameters:
Return type:

dict[str, int]

mstar.model.glm5_next.weight_loader.glm5_next_name_remapper(name)[source]#
Parameters:

name (str)

Return type:

str | None

mstar.model.glm5_next.weight_loader.load_glm5_next_hf_weights(module, weights, n_routed_experts, quant_config=None, fp8_experts=False, num_hidden_layers=45, load_mtp=False)[source]#
Parameters:
Return type:

set[str]

mstar.model.glm5_next.weight_loader.load_weights(module, source, device='cpu')[source]#
Parameters:
Return type:

set[str]

mstar.model.glm5_next.weight_loader.resolve_index_names(index_names, config, load_mtp=True)[source]#

Classify every checkpoint name through the real pipeline stages.

Parameters:
Return type:

dict[str, tuple[str, …]]

mstar.model.glm5_next.weight_loader.restore_fp32_params(module)[source]#

Re-widen params the checkpoint stores fp32 before loading into them.

Parameters:

module (Module)

Return type:

None

mstar.model.glm5_next.weight_loader.skip_vision_and_mtp_keys(weights, num_hidden_layers, load_mtp=False)[source]#

Drop vision-tower keys, and MTP-layer keys unless load_mtp, before any dequant buffering.

Parameters:
Return type:

Iterator[tuple[str, Tensor]]