bridge.models.kimi.kimi_k3_config#
Architecture translation for the native Kimi K3 model.
Module Contents#
Classes#
MLA transformer config with the settings that Kimi K3’s KDA, MLA and AttnRes layers read. |
|
HF-derived layers with Bridge-owned Kimi computation and depth state. |
Functions#
Translate one-based KDA indices and a per-block MoE mask into layers. |
|
Partition complete HF blocks into native pipeline stages, preserving block order. |
|
Compose the existing Bridge Kimi components through HybridModel’s stack API. |
|
Reject conflicting Kimi and Hybrid geometry before construction or export. |
API#
- class bridge.models.kimi.kimi_k3_config.KimiK3TransformerConfig#
Bases:
megatron.bridge.models.transformer_config.MLATransformerConfigMLA transformer config with the settings that Kimi K3’s KDA, MLA and AttnRes layers read.
- variable_seq_lengths: bool#
True
A pipeline stage passes the AttnRes snapshot bank packed with its hidden states, so the tensor width depends on the stage boundary and pipeline communication exchanges shapes.
- kimi_kda_layers: tuple[int, ...]#
()
1-based numbers of the layers that use Kimi Delta Attention (KDA); the other layers use MLA.
- kimi_linear_num_heads: int#
96
- kimi_linear_head_dim: int#
128
- kimi_linear_conv_kernel_size: int#
4
- kimi_kda_gate_lower_bound: float#
None
- kimi_attn_res_block_size: int#
12
Number of layers whose outputs each AttnRes snapshot covers.
- bridge.models.kimi.kimi_k3_config.kimi_k3_layer_pattern(
- *,
- num_layers: int,
- kda_layers: collections.abc.Sequence[int],
- moe_layers: collections.abc.Sequence[int],
Translate one-based KDA indices and a per-block MoE mask into layers.
Each source block contributes its attention followed by its feed-forward layer. Depth and dense/expert placement always come from the source model.
- bridge.models.kimi.kimi_k3_config.kimi_k3_pipeline_pattern(
- pattern: str,
- *,
- pipeline_size: int,
- blocks_per_stage: tuple[int, ...] | None = None,
Partition complete HF blocks into native pipeline stages, preserving block order.
- bridge.models.kimi.kimi_k3_config.kimi_k3_stack_spec(config)#
Compose the existing Bridge Kimi components through HybridModel’s stack API.
- bridge.models.kimi.kimi_k3_config.validate_kimi_k3_geometry(config) None#
Reject conflicting Kimi and Hybrid geometry before construction or export.
- class bridge.models.kimi.kimi_k3_config.KimiK3ModelConfig#
Bases:
megatron.bridge.models.hybrid.BridgeHybridMLAModelConfigHF-derived layers with Bridge-owned Kimi computation and depth state.
- transformer_config_class: ClassVar[type]#
None
- hybrid_stack_spec: Any#
None
- pipeline_block_counts: tuple[int, ...] | None#
None
- finalize() None#
Partition complete source blocks before finalizing the Hybrid stack.