Skip to content

Add Starcoder2 architecture adapter - #1533

Merged
jlarson4 merged 2 commits into
TransformerLensOrg:devfrom
SanjidMzi:feat/starcoder2-adapter
Jul 28, 2026
Merged

Add Starcoder2 architecture adapter#1533
jlarson4 merged 2 commits into
TransformerLensOrg:devfrom
SanjidMzi:feat/starcoder2-adapter

Conversation

@SanjidMzi

Copy link
Copy Markdown
Contributor

Adds a TransformerBridge adapter for Starcoder2 (Starcoder2ForCausalLM), which had no support (StarCoder1 / gpt_bigcode is already supported).

Starcoder2 is a Llama-shaped decoder (sequential pre-norm, GQA, rotary) that differs from Llama in three ways it shares with GPTBigCode: LayerNorm+bias instead of RMSNorm, a non-gated GELU MLP (c_fc/c_proj), and biases on all projections.

  • Adapter + four-place registration (factory, __init__, model registry, report).
  • Verified numerically: bridge logits match HuggingFace on tiny-random-Starcoder2ForCausalLM (max abs diff ~1e-7, 100% argmax agreement).
  • Unit tests (config, component mapping, GQA weight/bias conversions) + an integration test asserting the forward pass matches HuggingFace.

make format, uv run mypy ., and unit + integration + registry tests pass locally.

SanjidMzi and others added 2 commits July 22, 2026 20:15
dev gained an independently-written Starcoder2 adapter in TransformerLensOrg#1542 while this
PR was open, so the two collided on every file here. Reconciled onto the
TransformerLensOrg#1542 base, keeping the parts of this PR that TransformerLensOrg#1542 was missing:

- ARCHITECTURE_DESCRIPTIONS entry for Starcoder2 (TransformerLensOrg#1542 registered the
  adapter but never described it in the model registry report).
- Unit coverage for the attention mapping, the exact weight-conversion key
  set (including the absence of a per-head o.bias reshape), the ln2 norm,
  and the MHA fallback when n_key_value_heads is absent.
- The GPTBigCode contrast in the module docstring.

Dropped as superseded by TransformerLensOrg#1542's implementation: the hand-rolled q/k/v bias
conversions (base _qkvo_weight_conversions(include_biases=True) emits the
same kv-head-aware reshapes), the setup_component_testing override (the
_testing_eager class attribute drives the shared base wiring and also
forces eager attention), and the default_config block (dead — the base
class merges default_cfg, so nothing ever read it).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@jlarson4

Copy link
Copy Markdown
Collaborator

Hey @SanjidMzi! Thanks for putting this together. A Starcoder2 adapter was added independently from this, but I have rebased your PR dev and preserved the unique components of your adapter that will benefit TransformerLens. It'll be merged shortly

@jlarson4
jlarson4 merged commit c553891 into TransformerLensOrg:dev Jul 28, 2026
25 checks passed
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