bridge.models.kimi_vl.kimi_k25_vl_bridge#
Module Contents#
Classes#
Megatron Bridge for Kimi K2.5 VL. |
API#
- class bridge.models.kimi_vl.kimi_k25_vl_bridge.KimiK25VLBridge#
Bases:
megatron.bridge.models.conversion.model_bridge.MegatronModelBridgeMegatron Bridge for Kimi K2.5 VL.
Converts HuggingFace Kimi K2.5 VL models (KimiK25ForConditionalGeneration) to Megatron format (KimiK25VLModel) and vice versa.
The language backbone shares the same architecture as Kimi K2 (MoE with MLA).
.. rubric:: Example
from megatron.bridge import AutoBridge bridge = AutoBridge.from_hf_pretrained(“moonshotai/Kimi-K2.5”, trust_remote_code=True) model_config = bridge.get_model_config()
- MODEL_CONFIG_CLASS#
None
- USE_MODEL_CONFIG_FOR_CONVERSION#
True
- hf_config_to_model_config_kwargs(
- hf_config: transformers.PretrainedConfig,
Map the Kimi K2 language config and the vision-language fields of the top-level config.
The model loads its vision tower and projector from the checkpoint’s code, so the kwargs also record the checkpoint and whether the bridge’s source may run its code.
- hf_config_to_provider_kwargs(
- hf_config: transformers.PretrainedConfig,
Return the builder kwargs plus the provider’s decoder block spec.
- provider_bridge(
- hf_pretrained: megatron.bridge.models.hf_pretrained.causal_lm.PreTrainedCausalLM,
Build the deprecated provider with the settings that the Hugging Face source carries.
- _load_and_dequantize(
- key: str,
- hf_state_dict: Mapping[str, torch.Tensor],
Load a weight, dequantizing INT4 packed tensors when present.
- maybe_modify_loaded_hf_weight(
- hf_param: str | dict[str, str],
- hf_state_dict: Mapping[str, torch.Tensor],
Load HF weights, dequantizing INT4 quantized tensors when present.
- _is_quantized_expert_key(key: str) bool#
- maybe_modify_converted_hf_weight(
- task: megatron.bridge.models.conversion.model_bridge.WeightConversionTask,
- converted_weights_dict: Dict[str, torch.Tensor],
- hf_state_dict: Mapping[str, torch.Tensor],
Re-quantize converted expert weights to INT4 format.
- build_conversion_tasks(
- hf_pretrained,
- megatron_model,
- weight_dtype=None,
- *,
- exclude_module_types: tuple[type[torch.nn.Module], ...] = (),
- exclude_param_patterns: tuple[str, ...] = (),
Override to synthesize virtual weight keys from INT4 quantized triplets.
The HF checkpoint stores quantized expert weights as triplets (weight_packed, weight_scale, weight_shape) without a plain ‘weight’ key. We synthesize virtual ‘weight’ keys so the mapping registry can find them, then maybe_modify_loaded_hf_weight handles dequantization at load time.
- mapping_registry() megatron.bridge.models.conversion.mapping_registry.MegatronMappingRegistry#