bridge.models.glm_moe_dsa.glm5_provider#

Hybrid model provider for the GLM-5 DSA family.

Module Contents#

Classes#

GLM5ModelProvider

Construct GLM as DSA/dense/MoE Hybrid layers with MLA configuration.

Functions#

glm_hybrid_pattern

Build an architecture-preserving pattern from HF block counts.

split_glm_pattern

Place PP boundaries without splitting attention/MLP pairs.

_partition_layer_groups

Split ordered layer groups into contiguous stages that minimize the largest stage.

Data#

API#

bridge.models.glm_moe_dsa.glm5_provider.glm_hybrid_pattern(
*,
num_layers: int,
first_k_dense_replace: int,
) → str#

Build an architecture-preserving pattern from HF block counts.

bridge.models.glm_moe_dsa.glm5_provider.split_glm_pattern(pattern: str, block_counts: list[int]) → str#

Place PP boundaries without splitting attention/MLP pairs.

bridge.models.glm_moe_dsa.glm5_provider._partition_layer_groups(
group_sizes: list[int],
num_stages: int,
) → list[int]#

Split ordered layer groups into contiguous stages that minimize the largest stage.

Parameters:
  • group_sizes – Number of layers in each group, in layer order.

  • num_stages – Number of stages; must not exceed the number of groups.

Returns:

Number of layers in each stage. Every stage receives at least one whole group.

class bridge.models.glm_moe_dsa.glm5_provider.GLM5ModelProvider#

Bases: megatron.bridge.models.hybrid.hybrid_provider.HybridModelProvider, megatron.bridge.models.transformer_config.MLATransformerConfig

Construct GLM as DSA/dense/MoE Hybrid layers with MLA configuration.

_resolve_hybrid_stack_spec() → megatron.core.transformer.spec_utils.ModuleSpec#
finalize() → None#

Validate physical layout and preserve DSA sharing within each stage.

bridge.models.glm_moe_dsa.glm5_provider.__all__#

[‘GLM5ModelProvider’]