transformer_lens.model_bridge.supported_architectures.bd3lm module¶
BD3LM (Block Diffusion Language Model) architecture adapter.
- class transformer_lens.model_bridge.supported_architectures.bd3lm.BD3LMArchitectureAdapter(cfg: Any)¶
Bases:
ArchitectureAdapterArchitecture adapter for BD3LM (Block Diffusion LM, ICLR 2025).
BD3LM uses adaLN conditioning on diffusion timesteps, a custom Rotary embedding, joint QKV projections, and non-causal block-diffusion masking. Because adaLN modulation varies per-timestep, it cannot be folded into weights — the adapter uses
DelegatedAttentionBlockBridgeto delegate eachDDiTBlock.forward()wholesale to the original HF module. Hooks fire at block boundaries and on mapped submodules.- applicable_phases: list[int] = [1, 2, 3]¶
- component_mapping: ComponentMapping | None¶
- convert_weights() dict[str, Tensor]¶
Return empty dict — delegation means no weight rearrangement.
- prepare_loading(model_name: str, model_kwargs: dict) None¶
Patch BD3LM dynamic class before from_pretrained runs.
Modeling code has a custom __getattr__ that fails to delegate back to PreTrainedModel, raising AttributeError on all_tied_weights_keys.
- prepare_model(hf_model: Any) None¶
Patch BD3LM quirks that prevent standard bridge construction.
Three issues must be fixed before the bridge can wrap the model:
vocab_embedis annn.Parameter, notnn.Embedding, so it lacks a.weightattribute thatEmbeddingBridgeexpects.The
flexattention backend crashes on CPU; fall back tosdpaand regenerateblock_diff_maskfor the new backend.The HF
forward()does not acceptoutput_attentionsand other kwargs the bridge unconditionally injects; patch at runtime because no other hook point allows filtering them before HF’s forward call.
- supports_generation: bool = False¶
- uses_split_attention: bool¶
- weight_processing_conversions: Dict[str, ParamProcessingConversion | str] | None¶