Skip to content

Fix --models flag being silently ignored by e2e golden tests - #217

Merged
tadani3 merged 11 commits into
mainfrom
tommasoadani/more_detection_fixes
May 7, 2026
Merged

tadani3 merged 11 commits into
mainfrom
tommasoadani/more_detection_fixes

Conversation

@tadani3

@tadani3 tadani3 commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Problem

The --models flag passed from CI workflows (gpu_l4_golden_parity.yml, gpu_l5_generation_e2e.yml) was silently ignored by the e2e golden tests. All ~214 golden tests ran every time, regardless of which models were actually affected.

Root cause: The pytest_collection_modifyitems hook in tests/conftest.py filters tests by checking for a model_type parameter in item.callspec.params. But golden tests are parametrized with a case object (GoldenTestCase), not model_type. The hook hit continue and skipped filtering entirely.

Fix

Added an explicit model_type field to the golden test YAML schema and wired it through to the filtering hook.

Changes:

File Change
testdata/cases/schema.json Added model_type to required and properties
src/mobius/_testing/golden.py Added model_type: str field to GoldenTestCase, extracted in load_test_case()
tests/conftest.py Extended --models hook to check case.model_type for golden test items
testdata/cases/**/*.yaml (214 files) Added model_type line to each YAML case file

Why this approach

  • Declarative, not runtime: model_type is a static YAML field — no reverse-map lookups, no registry imports in test infra, no network calls at collection time.
  • Fails closed: Missing model_type causes a schema validation error (yaml_schema_test.py) and a load_test_case() ValueError. New YAML cases can't silently bypass the filter.
  • Consistent: Same pattern as model_id, task_type, dtype — already-required fields in the schema.

Verification

Test Result
pytest tests/yaml_schema_test.py 218 passed — all YAMLs valid
--models qwen2 343 skipped, only qwen2 tests ran
--models nonexistent 345 skipped — all golden tests filtered out
--models llama on build_graph_test.py Existing filtering unchanged

@tadani3 tadani3 self-assigned this Apr 24, 2026
@codecov

codecov Bot commented Apr 24, 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 [email protected] with any questions.

@github-actions

github-actions Bot commented Apr 24, 2026 •

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing 41d2641 → f42b6bb

Model Sub-model Changes Status

No architecture changes detected. ✅


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

@tadani3
tadani3 marked this pull request as ready for review April 27, 2026 22:52
@tadani3
tadani3 requested review from a team and Copilot April 27, 2026 22:52

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

Fixes the --models pytest selection flag so it correctly filters the e2e golden tests (which are parametrized by a case object rather than a model_type parameter).

Changes:

  • Extend pytest_collection_modifyitems to read case.model_type for golden-test items and skip non-selected models.
  • Add model_type to the golden test case schema and to GoldenTestCase / load_test_case().
  • Populate model_type in all golden YAML case files so the selection mechanism can work deterministically at collection time.

Reviewed changes

Copilot reviewed 217 out of 217 changed files in this pull request and generated no comments.

File Description
tests/conftest.py Updates --models filtering to also handle golden tests via case.model_type.
src/mobius/_testing/golden.py Adds model_type to GoldenTestCase and makes it a required YAML field in load_test_case().
testdata/cases/schema.json Makes model_type required in the JSON schema and documents its intent.
testdata/cases/**/*.yaml Adds model_type to each case so golden tests can be filtered by --models.
Comments suppressed due to low confidence (1)

src/mobius/_testing/golden.py:214

  • load_test_case() now requires model_type, but the unit tests in src/mobius/_testing/golden_test.py still build YAML strings (e.g. MINIMAL_YAML, VL_YAML, SKIP_YAML) without a model_type field. With this change, those tests will raise ValueError: Missing required fields and fail. Update the test YAML fixtures to include a valid model_type value for each case (and add assertions for case.model_type where appropriate).
    # Validate required top-level fields
    _required = ("model_id", "model_type", "revision", "task_type", "dtype", "level")
    missing = [k for k in _required if k not in data]
    if missing:
        raise ValueError(f"Missing required fields in {yaml_path}: {missing}")

@github-actions

github-actions Bot commented May 6, 2026 •

Copy link
Copy Markdown

Performance Comparison

Comparing 41d2641 → f42b6bb

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.

@tadani3
tadani3 enabled auto-merge (squash) May 7, 2026 22:31
@tadani3
tadani3 merged commit 4f7524b into main May 7, 2026
18 of 20 checks passed
@tadani3
tadani3 deleted the tommasoadani/more_detection_fixes branch May 7, 2026 23: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.

3 participants