Coverage for transformer_lens/model_bridge/supported_architectures/m2m100.py: 100%

3 statements  

« prev     ^ index     » next       coverage.py v7.10.1, created at 2026-08-11 18:50 +0000

1"""M2M100 architecture adapter. 

2 

3Covers Meta's M2M100 and NLLB-200 translation families 

4(``M2M100ForConditionalGeneration``). Same q/k/v/out_proj + fc1/fc2 layout as 

5Bart/Marian, but PRE-norm (LayerNorm before attention and MLP) with an extra 

6final LayerNorm after each stack, deterministic sinusoidal positions with a 

7padding-aware offset, and the sqrt(d_model) embedding scale baked into 

8``M2M100ScaledWordEmbedding`` itself — so unlike Marian, hooks on ``embed`` 

9observe the already-scaled output. 

10""" 

11 

12from transformer_lens.model_bridge.supported_architectures.bart import ( 

13 BartFamilyArchitectureAdapter, 

14) 

15 

16 

17class M2M100ArchitectureAdapter(BartFamilyArchitectureAdapter): 

18 """Architecture adapter for M2M100ForConditionalGeneration (M2M100 / NLLB) models.""" 

19 

20 has_final_stack_norm = True