bridge.diffusion.conversion.llada15.llada15_bridge#

Megatron Bridge for LLaDA1.5 (GSAI-ML/LLaDA-*) masked-diffusion LLMs.

Converts between the trust_remote_code LLaDAModelLM HF class and a Megatron-Core GPTModel. The model is a dense LLaMA-style block with OLMo-style parameter naming and full RoPE.

Key mapping decisions, anchored to the reference implementation (modeling_llada.py):

  • QKV is separate (q_proj, k_proj, v_proj — see LLaDALlamaBlock.__init__), not fused. Use :class:QKVMapping, not

    class:

    ConcatenatedQKVMapping.

  • The SwiGLU MLP computes act(ff_proj(x)) * up_proj(x) (see LLaDALlamaBlock.forward), so ff_proj is the gate and up_proj is the up input for Megatron’s fused linear_fc1.

  • The LM head is model.transformer.ff_out (LLaDA1.5 has weight_tying: false).

  • Attention output projection is named attn_out, not o_proj.

  • Layer norms are attn_norm (pre-attention) and ff_norm (pre-MLP), fused into Megatron’s TE linear_qkv/linear_fc1 layer_norm_weight.

Module Contents#

Classes#

LLaDA15Bridge

HF LLaDAModelLM ↔ Megatron GPTModel bridge.

API#

class bridge.diffusion.conversion.llada15.llada15_bridge.LLaDA15Bridge#

Bases: megatron.bridge.models.conversion.model_bridge.MegatronModelBridge

HF LLaDAModelLM ↔ Megatron GPTModel bridge.

.. rubric:: Example

from megatron.bridge import AutoBridge bridge = AutoBridge.from_hf_pretrained(“GSAI-ML/LLaDA-1.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,
) → dict[str, Any]#

Convert a Hugging Face LLaDA-1.5 config to builder config kwargs.

The layer spec swaps in the bidirectional LLaDA15TEDotProductAttention.

hf_config_to_provider_kwargs(
hf_config: transformers.PretrainedConfig,
) → dict[str, Any]#

Adapt the canonical builder mapping to the deprecated provider path.

mapping_registry() → megatron.bridge.models.conversion.mapping_registry.MegatronMappingRegistry#