Skip to content

CI: Narrow affected-models detection by resolving __init__.py re-exports - #182

Merged
tadani3 merged 10 commits into
mainfrom
tommasoadani/model_detection_fixes
Apr 21, 2026
Merged

CI: Narrow affected-models detection by resolving __init__.py re-exports#182
tadani3 merged 10 commits into
mainfrom
tommasoadani/model_detection_fixes

Conversation

@tadani3

@tadani3 tadani3 commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

CI: Narrow affected-models detection by resolving init.py re-exports

Changes

  1. src/mobius/tasks/ reclassified from shared_infratraceable.
    Task files no longer trigger run_all unconditionally; they are now traced
    through the import graph.
  2. Re-export resolution for __init__.py hubs. A new _build_reexport_map()
    walks every __init__.py and builds a (package, symbol) → source_module
    map. _parse_imports() resolves from mobius.components import Foo to the
    actual source module (mobius.components._attention) instead of recording a
    dependency on the package itself. The package name is only added when a
    symbol can't be resolved (wildcards, missing entries).

The result: changes to a re-export hub (e.g. components/__init__.py) no
longer invalidate every importer — only models whose actually-used symbol's
source changed are affected.

Before vs. after (Gemma4 + Qwen test scenario)

Same input file list:

Detector Affected models run_all
Before 193 false
After 2 (gemma4, gemma4_text) false

Verification

# Gemma4 + Qwen test scenario
cat <<'EOF' | python scripts/detect_affected_models.py --stdin
src/mobius/components/__init__.py
src/mobius/components/_gemma4_audio.py
src/mobius/models/gemma4.py
EOF
# → {"affected": ["gemma4", "gemma4_text"], "run_all": false}

# Attention component → all causal-LMs / VLMs that use shared Attention
echo "src/mobius/components/_attention.py" | python scripts/detect_affected_models.py --stdin
# → 154 models (vision-only / audio-only models correctly excluded)

# MoE component → only MoE architectures
echo "src/mobius/components/_moe.py" | python scripts/detect_affected_models.py --stdin
# → 33 models (Mixtral, DeepSeek V2/V3, Qwen MoE, Granite MoE, Jamba, ...)

All 49 tests in scripts/detect_affected_models_test.py pass.

Caveat

Tasks aren't directly imported by model files, so a task change currently
produces an empty affected set (no run_all). If you want task changes to
trigger specific models, a task → model_type mapping would need to be added.

@tadani3 tadani3 self-assigned this Apr 21, 2026
@tadani3
tadani3 requested review from a team and Copilot April 21, 2026 17:53
@github-actions

github-actions Bot commented Apr 21, 2026

Copy link
Copy Markdown

Performance Comparison

Comparing 8be8155c28b703

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 360 KB 360 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 Apr 21, 2026

Copy link
Copy Markdown

The author of this PR, tadani3, is not an activated member of this organization on Codecov.
Please activate this user on Codecov to display this PR comment.
Coverage data is still being uploaded to Codecov.io for purposes of overall coverage calculations.
Please don't hesitate to email us at support@codecov.io with any questions.

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 tightens CI affected-model detection by improving import-graph precision, especially for packages that act as re-export hubs (e.g., mobius.components), so CI runs model tests for the models actually impacted by a change.

Changes:

  • Treat src/mobius/tasks/ as traceable (import-graph traced) instead of always triggering run_all.
  • Add __init__.py re-export resolution: from mobius.components import X is attributed to the underlying defining module for X when resolvable.
  • Update detector unit tests to reflect the new task classification and run-all behavior.

Reviewed changes

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

File Description
scripts/detect_affected_models.py Implements re-export resolution for from pkg import sym and reclassifies tasks/ as traceable.
scripts/detect_affected_models_test.py Updates unit tests for the new tasks/ classification and detector behavior.

Comment thread scripts/detect_affected_models.py
Comment thread scripts/detect_affected_models.py
Comment thread scripts/detect_affected_models_test.py Outdated
Comment thread scripts/detect_affected_models_test.py Fixed
Comment thread scripts/detect_affected_models_test.py Fixed
tadani3 and others added 3 commits April 21, 2026 11:47
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Signed-off-by: Tommaso Adani <83273681+tadani3@users.noreply.github.com>
@tadani3
tadani3 enabled auto-merge (squash) April 21, 2026 19:00
Comment thread scripts/detect_affected_models_test.py Fixed
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Signed-off-by: Tommaso Adani <83273681+tadani3@users.noreply.github.com>
Comment thread scripts/detect_affected_models_test.py Fixed
…rt' and 'import from''

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Signed-off-by: Tommaso Adani <83273681+tadani3@users.noreply.github.com>
@tadani3
tadani3 disabled auto-merge April 21, 2026 20:13
@tadani3
tadani3 merged commit b75eb1d into main Apr 21, 2026
18 of 19 checks passed
@tadani3
tadani3 deleted the tommasoadani/model_detection_fixes branch April 21, 2026 20:22
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.

4 participants