Skip to content

test: add adapter unit tests for Phi-3 and Granite (+ GraniteMoe)#1399

Merged
jlarson4 merged 1 commit into
TransformerLensOrg:devfrom
mukund1985:feat/adapter-tests-phi3-granite
Jun 18, 2026
Merged

test: add adapter unit tests for Phi-3 and Granite (+ GraniteMoe)#1399
jlarson4 merged 1 commit into
TransformerLensOrg:devfrom
mukund1985:feat/adapter-tests-phi3-granite

Conversation

@mukund1985

Copy link
Copy Markdown

Adds focused test suites for three architecture adapters per issue #1302.

What this adds

test_phi3_adapter.py (33 tests)

  • Component mapping: bridge types and HF module paths for all top-level and block-level components
  • Weight conversion keys and source keys for fused qkv_proj and gate_up_proj
  • _SizedSplitConversion numerical correctness: Q/K/V GQA splits along dim=0 and dim=1, value correctness, three-slice reconstruction
  • Config flags: normalization_type="RMS", positional_embedding_type="rotary", gated_mlp=True, supports_fold_ln=False
  • preprocess_weights: LN scale folded into QKV and gate/up weights, LN set to ones afterwards, skipped when _fold_ln_requested=False

test_granite_adapter.py (22 tests)

  • GraniteArchitectureAdapter: component mapping, weight conversion key set, config flags (final_rms=True, default_prepend_bos=False, GQA head propagation)
  • GraniteMoeArchitectureAdapter: MoE bridge replaces dense MLP with block_sparse_moe; all other components and config flags match the dense variant

All 55 tests pass locally.

Checklist

  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes
  • I have not rewritten tests relating to key interfaces which would affect backward compatibility

Adds focused test suites for three architecture adapters per the
proposal in issue TransformerLensOrg#1302.

tests/unit/model_bridge/supported_architectures/test_phi3_adapter.py
- Component mapping structure (bridge types and HF module paths)
- Weight conversion key set and source keys for fused qkv/gate_up
- _SizedSplitConversion numerical correctness (Q/K/V GQA splits)
- Config flags (RMS norm, rotary, gated MLP, supports_fold_ln=False)
- preprocess_weights LN folding into QKV and gate/up projections

tests/unit/model_bridge/supported_architectures/test_granite_adapter.py
- Component mapping for dense GraniteArchitectureAdapter
- Weight conversion key set (standard QKVO rearrangements)
- Config flags (final_rms=True, default_prepend_bos=False, GQA heads)
- GraniteMoeArchitectureAdapter: MoE bridge replaces dense MLP,
  all other components and config flags match dense Granite

Closes part of TransformerLensOrg#1302.
@jlarson4 jlarson4 merged commit f21898e into TransformerLensOrg:dev Jun 18, 2026
25 checks passed
@jlarson4

Copy link
Copy Markdown
Collaborator

Excellent work on this! Merging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants