nemo_automodel.components.models.muse_spark.magi_cp
nemo_automodel.components.models.muse_spark.magi_cp
Model-owned packed Magi CP with shared token ownership across Muse masks.
Module Contents
Classes
Functions
Data
API
Per-microbatch keys; all masks retain the same dispatched token order.
Compute local THD output with Magi’s own KV communication.
Parameters:
CP-local queries [tokens, query_heads, head_dim].
CP-local keys [tokens, kv_heads, head_dim].
CP-local values [tokens, kv_heads, head_dim].
Sliding-window length, or zero for full causal attention.
Attention score scale.
Returns: torch.Tensor
Attention output [tokens, query_heads, head_dim] in the local token order.
Magi key fields consumed by the Muse integration.
Step-owned plans replicated by PP; a chunked index selects each plan.
Select without a mutable cursor, before entering checkpointed layers.
Parameters:
Int64 tensor [1], split by PP and possibly moved by FSDP.
Returns: MuseMagiPlan
The immutable microbatch plan retained by that forward’s AC graph.
Muse model state needed to build model-owned Magi CP inputs.
Return whether this module is a physical pipeline stage.
Build masks with one shared token partition for a packed microbatch.
Parameters:
CPU int32 padded document boundaries [documents + 1].
Muse attention configuration, shared across pipeline stages.
This pipeline stage’s context-parallel process group.
Returns: MuseMagiPlan
Full-causal and sliding-window keys with identical local token ownership.
Prepare model-owned packed CP, including independent pipeline microbatches.
Parameters:
Full Muse model or a local pipeline stage.
Global tokens/labels/positions [batch, sequence] and packed document lengths [batch, documents]. Each PP microbatch holds one pack.
Number of independent pipeline microbatches.
Returns: dict[str, ContextParallelSharder]
A model-owned CP sharder. In PP, token ids stay global [chunks, sequence];