Skip to content

Fix L2 failures: arctic RoPE and Phi4-MM rope standardization - #230

Merged
justinchuby merged 4 commits into
mainfrom
justinchu/fix-l2-v2
May 1, 2026
Merged

justinchuby merged 4 commits into
mainfrom
justinchu/fix-l2-v2

Conversation

@justinchuby

Copy link
Copy Markdown
Member

Summary

Fixes 8 L2 test failures (arctic ×2, phi4_multimodal ×3, phi4mm ×3).

Arctic (TypeError: rotary_emb is None)

Arctic's config JSON has rope_theta=10000 (the default) and rope_scaling=null. No signal triggers _extract_rope_config(), so rotary_emb is never created — but the model uses RoPE.

Fix: Add arctic to _IMPLICIT_ROPE_DEFAULTS with rope_theta=10000.0.

Phi4-MM (AttributeError: max_position_embeddings)

Newer transformers (convert_rope_params_to_dict → standardize_rope_params) accesses self.max_position_embeddings before it's set as an attribute on PretrainedConfig. This crashes even when max_position_embeddings is in the kwargs dict.

Fix: Two-layer defense in _dict_to_pretrained_config:

  1. Proactively strip rope fields from composite configs (those with nested text_config/thinker_config dicts) — the nested config carries its own rope_scaling
  2. For flat configs that still crash, catch the exception, strip rope fields, reconstruct, then restore rope fields as attributes so _extract_rope_config can still read them

- Add arctic to _IMPLICIT_ROPE_DEFAULTS (rope_theta=10000 default with
  rope_scaling=null provides no RoPE signal, but the model uses RoPE)
- Fix _dict_to_pretrained_config for newer transformers: proactively
  strip rope fields from composite configs, and fall back to strip +
  restore for flat configs where PretrainedConfig rope standardization
  crashes (Phi4-MM longrope format)

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
@github-actions

github-actions Bot commented May 1, 2026 •

Copy link
Copy Markdown

Performance Comparison

Comparing 4de6bb7 → b892491

Model Metric Baseline Current Delta
bert (feature-extraction) model_size_bytes 359 KB 359 KB +0.0% ⚪
bert (feature-extraction) num_nodes 60 60 +0.0% ⚪
falcon model_size_bytes 364 KB 364 KB +0.0% ⚪
falcon num_nodes 66 66 +0.0% ⚪
gemma2 model_size_bytes 428 KB 428 KB +0.0% ⚪
gemma2 num_nodes 107 107 +0.0% ⚪
gpt2 model_size_bytes 388 KB 388 KB +0.0% ⚪
gpt2 num_nodes 53 53 +0.0% ⚪
llama model_size_bytes 425 KB 425 KB +0.0% ⚪
llama num_nodes 61 61 +0.0% ⚪
llama (static-cache) model_size_bytes 425 KB 425 KB +0.0% ⚪
llama (static-cache) num_nodes 58 58 +0.0% ⚪
mamba (ssm-text-generation) model_size_bytes 296 KB 296 KB +0.0% ⚪
mamba (ssm-text-generation) num_nodes 98 98 +0.0% ⚪
phi3 model_size_bytes 421 KB 421 KB +0.0% ⚪
phi3 num_nodes 59 59 +0.0% ⚪
phi3 (static-cache) model_size_bytes 421 KB 421 KB +0.0% ⚪
phi3 (static-cache) num_nodes 56 56 +0.0% ⚪
qwen2 model_size_bytes 425 KB 425 KB +0.0% ⚪
qwen2 num_nodes 61 61 +0.0% ⚪
qwen2 (static-cache) model_size_bytes 425 KB 425 KB +0.0% ⚪
qwen2 (static-cache) num_nodes 58 58 +0.0% ⚪
qwen3_5_moe (hybrid-text-generation) model_size_bytes 506 KB 506 KB +0.0% ⚪
qwen3_5_moe (hybrid-text-generation) num_nodes 275 275 +0.0% ⚪
qwen3_5_text (hybrid-text-generation) model_size_bytes 458 KB 458 KB +0.0% ⚪
qwen3_5_text (hybrid-text-generation) num_nodes 129 129 +0.0% ⚪
qwen3_5_vl (hybrid-qwen-vl) model_size_bytes 977 KB 977 KB +0.0% ⚪
qwen3_5_vl (hybrid-qwen-vl) num_nodes 408 408 +0.0% ⚪
t5 (seq2seq) model_size_bytes 836 KB 836 KB +0.0% ⚪
t5 (seq2seq) num_nodes 166 166 +0.0% ⚪
whisper (speech-to-text) model_size_bytes 1008 KB 1008 KB +0.0% ⚪
whisper (speech-to-text) num_nodes 128 128 +0.0% ⚪

No performance regressions.

@codecov

codecov Bot commented May 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.95918% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/mobius/_config_resolver_test.py 93.75% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@github-actions

github-actions Bot commented May 1, 2026 •

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing 4de6bb7 → b892491

Model Sub-model Changes Status
bert (feature-extraction) model 0 ⚪
falcon model 0 ⚪
gemma2 model 0 ⚪
gemma4 (gemma4) decoder 0 ⚪
gemma4 (gemma4) embedding 0 ⚪
gemma4 (gemma4) vision_encoder 0 ⚪
gemma4_text model 0 ⚪
gpt2 model 0 ⚪
llama model 0 ⚪
llama (static-cache) model 0 ⚪
mamba (ssm-text-generation) model 0 ⚪
phi3 model 0 ⚪
phi3 (static-cache) model 0 ⚪
qwen model 0 ⚪
qwen (static-cache) model 0 ⚪
qwen2 model 0 ⚪
qwen2 (static-cache) model 0 ⚪
qwen2_moe model 0 ⚪
qwen2_moe (static-cache) model 0 ⚪
qwen3 model 0 ⚪
qwen3 (static-cache) model 0 ⚪
qwen3_5_moe (hybrid-text-generation) model 0 ⚪
qwen3_5_text (hybrid-text-generation) model 0 ⚪
qwen3_5_vl (hybrid-qwen-vl) decoder 0 ⚪
qwen3_5_vl (hybrid-qwen-vl) embedding 0 ⚪
qwen3_5_vl (hybrid-qwen-vl) vision_encoder 0 ⚪
qwen3_moe model 0 ⚪
qwen3_moe (static-cache) model 0 ⚪
qwen3_next (hybrid-text-generation) model 0 ⚪
t5 (seq2seq) decoder 0 ⚪
t5 (seq2seq) encoder 0 ⚪
whisper (speech-to-text) decoder 0 ⚪
whisper (speech-to-text) encoder 0 ⚪

No architecture changes detected. ✅


Legend: ⚪ No change · 🔵 Minor (attrs/inits) · 🟡 Moderate (nodes added/removed) · 🔴 Major (interface changed)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses RoPE-related config resolution issues that were causing L2 test failures for Arctic and Phi4-MM models by improving RoPE signal handling and making config dict → PretrainedConfig conversion more robust against transformers’ rope standardization changes.

Changes:

  • Add arctic to _IMPLICIT_ROPE_DEFAULTS so RoPE is initialized even when config JSON has only default rope_theta and rope_scaling=null.
  • Update _dict_to_pretrained_config to (a) strip top-level RoPE fields only for composite configs and (b) retry PretrainedConfig construction without RoPE fields on init failure, then restore them as attributes.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/mobius/_configs.py Adds an implicit RoPE default for arctic to avoid missing rotary embedding initialization.
src/mobius/_config_resolver.py Improves resilience to transformers RoPE standardization by stripping duplicate top-level rope fields for composite configs and adding a retry/restore fallback on config init errors.

Comment thread src/mobius/_config_resolver.py Resolved
Comment thread src/mobius/_config_resolver.py Resolved
Comment thread src/mobius/_configs.py Resolved
justinchuby and others added 3 commits May 1, 2026 10:36
- Add tests for composite rope stripping, flat config preservation,
  and retry/restore path in _config_resolver_test.py
- Add test for arctic implicit RoPE defaults in _configs_test.py
- Include caught exception in retry debug log message

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
@justinchuby
justinchuby merged commit 419467e into main May 1, 2026
5 checks passed
@justinchuby
justinchuby deleted the justinchu/fix-l2-v2 branch May 1, 2026 17:47
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