bridge.models.kimi.modeling_kimi_k3.stack#
Split Kimi blocks into Hybrid layers without changing Core implementations.
Module Contents#
Classes#
One attention or FFN layer, sharing the existing Kimi component implementations. |
|
Bridge-owned depth-state composition using Core’s Hybrid stack/checkpoint interface. |
Functions#
API#
- bridge.models.kimi.modeling_kimi_k3.stack._residual_parameters(
- module: torch.nn.Module,
- config: Any,
- branch: str,
- class bridge.models.kimi.modeling_kimi_k3.stack.KimiK3Layer(
- config: Any,
- submodules: Any,
- *,
- layer_number: int,
- attention: bool,
- pg_collection: Any,
Bases:
megatron.core.transformer.module.MegatronModuleOne attention or FFN layer, sharing the existing Kimi component implementations.
Initialization
- forward(
- prefix: torch.Tensor,
- bank: torch.Tensor,
- *,
- attention_mask: Any = None,
- packed_seq_params: Any = None,
- padding_mask: Any = None,
Return the updated partial and snapshot tensors; never mutate depth state.
- class bridge.models.kimi.modeling_kimi_k3.stack.KimiK3Stack(
- config: Any,
- *,
- pattern: str,
- layer_config_list: Any,
- pp_layer_offset: int = 0,
- pre_process: bool = True,
- post_process: bool = True,
- post_layer_norm: bool = True,
- pg_collection: Any,
- **kwargs: Any,
Bases:
megatron.core.models.hybrid.hybrid_block.HybridStackBridge-owned depth-state composition using Core’s Hybrid stack/checkpoint interface.
Core owns embeddings, output/loss, pipeline allocation and sharded-state traversal. This stack reuses Bridge’s Kimi attention, MoE, activation and residual operations. Its two tensor outputs make checkpoint replay independent of mutable lists or state captured from a previous microbatch.
Initialization
- set_input_tensor(input_tensor: torch.Tensor) None#
Receive the packed partial/snapshot payload from the preceding stage.
- _run_layers(
- start: int,
- end: int,
- prefix: torch.Tensor,
- bank: torch.Tensor,
- **kwargs: Any,
- forward(
- hidden_states: torch.Tensor | None,
- attention_mask: Any = None,
- inference_context: Any = None,
- rotary_pos_emb: Any = None,
- *,
- packed_seq_params: Any = None,
- padding_mask: Any = None,
- **kwargs: Any,
Run layers and pass all differentiable depth state through recomputation.