bridge.models.muse_spark_open.modeling_muse_spark_open.blocks#
Missing Muse Spark Open operations composed with existing MCore building blocks.
Module Contents#
Classes#
Apply learned input scaling before native, parameter-free RMSNorm. |
|
Post-normalize and mix a branch with its residual via learned gates. |
|
Reuse GQA and gating, inserting the missing per-head output norm. |
|
Reuse sigmoid top-k routing with the model’s pre-sigmoid logit scale. |
|
Normalize each expert’s output before applying its routing weight. |
|
Reuse latent projections and dispatch with a pre-expert RMSNorm. |
Functions#
Compose independent attention and MoE layers for a repeated |
API#
- class bridge.models.muse_spark_open.modeling_muse_spark_open.blocks.InputScaledRMSNorm(
- hidden_size: int,
- *,
- eps: float,
- config: Any,
- sequence_parallel: bool,
Bases:
torch.nn.ModuleApply learned input scaling before native, parameter-free RMSNorm.
TE’s affine RMSNorm scales after normalization and cannot express this operation. Native RMSNorm supplies the normalization without an extra weight.
Initialization
- forward(hidden_states: torch.Tensor) torch.Tensor#
Normalize scaled activations using the existing framework kernel.
- class bridge.models.muse_spark_open.modeling_muse_spark_open.blocks.MuseSparkResidualGate(config: Any, *, input_scaled_norm: bool)#
Bases:
torch.nn.ModulePost-normalize and mix a branch with its residual via learned gates.
Implements the callable interface expected by TransformerLayer’s BDA slot, keeping the standard layer’s recompute, offload and checkpoint machinery.
Initialization
- forward(training: bool, fused: bool) Callable#
Return the residual operation for MCore’s BDA call convention.
- _apply_branch(
- output_with_bias: tuple[torch.Tensor, torch.Tensor | None],
- residual: torch.Tensor,
- dropout: float,
- class bridge.models.muse_spark_open.modeling_muse_spark_open.blocks.MuseSparkSelfAttention(
- config: Any,
- *args: Any,
- **kwargs: Any,
Bases:
megatron.bridge.models.muse_glimmer.modeling_muse_glimmer.MuseSelfAttentionReuse GQA and gating, inserting the missing per-head output norm.
Initialization
- _apply_output_gate(
- hidden_states: torch.Tensor,
- gate: torch.Tensor,
- class bridge.models.muse_spark_open.modeling_muse_spark_open.blocks.MuseSparkRouter(
- config: Any,
- *args: Any,
- **kwargs: Any,
Bases:
megatron.core.transformer.moe.router.TopKRouterReuse sigmoid top-k routing with the model’s pre-sigmoid logit scale.
Initialization
- _apply(
- fn: Callable,
- recurse: bool = True,
Preserve the FP32 correction buffer across device and model-dtype moves.
- gating(input: torch.Tensor) torch.Tensor#
Scale router logits before MCore performs expert selection.
- class bridge.models.muse_spark_open.modeling_muse_spark_open.blocks.MuseSparkExperts(
- num_local_experts: int,
- config: Any,
- *args: Any,
- **kwargs: Any,
Bases:
megatron.core.transformer.moe.experts.TEGroupedMLPNormalize each expert’s output before applying its routing weight.
Initialization
- forward(
- permuted_local_hidden_states: torch.Tensor,
- tokens_per_expert: torch.Tensor,
- permuted_probs: torch.Tensor,
Keep grouped GEMMs while delaying routing weights until after normalization.
- sharded_state_dict(
- prefix: str = '',
- sharded_offsets: tuple = (),
- metadata: dict | None = None,
Save the shared norm with ordinary TP replication, independently of ETP.
- class bridge.models.muse_spark_open.modeling_muse_spark_open.blocks.MuseSparkMoE(
- config: Any,
- *args: Any,
- **kwargs: Any,
Bases:
megatron.core.transformer.moe.moe_layer.MoELayerReuse latent projections and dispatch with a pre-expert RMSNorm.
Initialization
- preprocess(
- hidden_states: torch.Tensor,
- probs: torch.Tensor,
- routing_map: torch.Tensor,
- padding_mask: torch.Tensor | None = None,
Normalize the shared latent representation before dispatching tokens.
As in
MoELayer.preprocess, only the flex dispatcher takes the batch-first padding mask.
- bridge.models.muse_spark_open.modeling_muse_spark_open.blocks.get_muse_spark_hybrid_stack_spec(
- config: Any,
Compose independent attention and MoE layers for a repeated
*Estack.