Skip to content

[None][chore] Relax Modeling V2 naming and select Modeling V2 tests by change scope - #21376

Closed
litaotju wants to merge 1 commit into
NVIDIA:mainfrom
litaotju:codex/modeling-v2-readme-alignment
Closed

litaotju wants to merge 1 commit into
NVIDIA:mainfrom
litaotju:codex/modeling-v2-readme-alignment

Conversation

@litaotju

@litaotju litaotju commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Modeling V2 lets each model family and target own its code, so one model can change without affecting others. CI should follow the same scope: a change runs the tests of the code it can affect, and nothing else. This PR does that, and keeps naming and layout as conventions instead of enforced rules.

Test selection follows the scope of the change

The CBTS ModelingV2Rule now selects tests by scope:

Changed file Selected tests
Any file in a target, native code included That target's unit and accuracy tests
Python family code (shared kernels, ops) Its mirrored unit tests, the unit test files that import it, and the tests of every target that imports it
routing.py, native or other non-Python family code The whole family
A catalog operation Its category's unit tests, the unit test files that import it, and the tests of every target that imports it
Code every model shares (_op.py, resolver, loader, native build) All Modeling V2 tests
  • The rule finds importers by parsing the package and the Modeling V2 unit tests with ast, once per run. It follows relative imports, package __init__ files, test helper modules and importlib calls. A computed importlib call counts as importing its whole directory. Imports of a deleted or moved module still count, so the targets that used it are tested.
  • A directory under models/<family>/ is a target when accuracy/modeling_v2/<family>/<target>/ exists.
  • When the rule cannot work out the scope, for example because a file does not parse, it selects more. It does not widen a target change when the test lists have no entry for that target.

Test layout mirrors the code

  • Accuracy tests move from one file per family to one directory per target: accuracy/modeling_v2/<family>/<target>/test_accuracy.py. Class and test names do not change. Helpers shared by a family's targets move to <family>/_common.py.
  • Eleven unit tests of the deepseek_v3, gpt_oss and qwen4_exp targets move from the family directory into their target directory.
  • Test-db, QA and waive lists, .test_durations and CODEOWNERS use the new paths.
  • l0_b300 replaces its one entry for the whole unittest/_torch/modeling_v2 tree, and its one MiniMax-M3 entry, with one entry per GPU-run top-level file, catalog category and target, as the other stages already have. Without this, every target change still ran the whole tree on B300. The stale waive for the old entry is removed.

Naming and layout are no longer enforced

  • _native.py finds a target by its position in the package path, not by __ in its name.
  • modeling_v2.cmake accepts any Python package name as a target name and uppercase family names. Family torch namespaces join the collision check.
  • test_modeling_v2_claims.py and test_modeling_v2_native_claims.py are deleted. They checked naming and file conventions.

Structure checks

Selection by path is safe only while the code and tests keep a few structural rules. If one breaks, a test is silently not selected. tests/unittest/_torch/modeling_v2/test_modeling_v2_ci_selection.py (CPU) checks them, and CBTS runs it for every Modeling V2 change.

  • Isolation, so a change cannot reach code outside the tests it selects:
    • Families do not import each other, and stock code does not import Modeling V2.
    • Within a family, only routing.py imports a target, and targets do not import each other.
    • Model code imports dynamically only in forms the import analysis can read: a literal module name, or a computed name relative to the caller's own package.
  • Layout, so the path of a change maps to the right tests:
    • Every test directory under models/ and accuracy/modeling_v2/ names an existing family.
    • Family-level unit test directories mirror source directories. Inside a target the layout is free, since a target change selects the whole target.
    • Every accuracy directory names an existing target and holds at least one test file.
  • Coverage, so every target has tests and every test is on a test list:
    • Every target that route can return has an accuracy test directory.
    • CI runs only the tests that a test-db entry lists. The check fails if a unit test file or a target's accuracy tests appear in no entry. It compares paths only, so it does not check that a cpu_only test sits on a CPU stage. Three known gaps are listed with reasons, and the check fails when a listed gap is fixed, so the list stays current.

Other changes

  • test_modeling_v2_env_scope.py scans the accuracy tests recursively and fails if it finds none.
  • agent-flow: the delivery check no longer requires the deleted claims test. It finds a target's accuracy test in the new layout and still supports the older ones. The new CI-selection test joins the always-run gates.
  • The Modeling V2 and CBTS READMEs describe the new selection and layout.

Known gaps

  • kimi_k3_vl keeps its unit tests at family level, so a change inside a K3 target selects no K3 tests. A follow-up PR moves them into the target directories.

Test Coverage

  • tests/unittest/scripts/cbts/test_modeling_v2.py and test_modeling_v2_rule.py: one case per selection row, plus transitive, relative and dynamic imports.
  • tests/unittest/_torch/modeling_v2/test_modeling_v2_ci_selection.py, test_modeling_v2_env_scope.py, test_modeling_v2_native_loader.py.
  • agent-flow/tests/workflows/trtllm_modeling_v2.

PR Checklist

  • Reviewed the applicable checklist items. CODEOWNERS paths for the accuracy tests change from files to directories, with the same owners. The Modeling V2 and CBTS READMEs are updated.

@litaotju litaotju changed the title [None][docs] Rewrite Modeling V2 developer guidelines [None][chore] Relax Modeling V2 naming and layout checks Nov 1, 2026
@litaotju

litaotju commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #81844 [ run ] triggered by Bot. Commit: 66d808b Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #81844 [ run ] completed with state SUCCESS. Commit: 66d808b
/LLM/main/L0_MergeRequest_PR pipeline #67496 completed with status: 'UNSTABLE'

CI Report

⚠️ Multi-GPU Label Required:
Multi-GPU tests require the ci: full pre-merge approved label on this PR. Either:

  • Wait for the PR to be fully approved — the label is added automatically once approval is complete. Having unresolved open comments is fine, or
  • If needed, ask a member of NVIDIA/trt-llm-ci-approvers to add the label manually.
    Then re-trigger CI with the same bot command (no rebase needed).

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@WeiHaocheng

WeiHaocheng commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Relaxing the naming and layout rules makes sense to me. The structure checks I suggest below don't have to be pre-merge blockers either. They could run post-merge or be triggered manually, and report problems instead of failing PRs. That would still help us keep the Modeling V2 code structure in line with the design over time.

Still, I think we need some tests that make it easy to check that the modeling code and its tests stay aligned. For example:

  • Code and test locations correspond. Each directory under tests/unittest/_torch/modeling_v2/models/ names an existing family. Each family has its unit test directory and a test_<family>.py accuracy file. Per-family CI selection depends on this, but today only the accuracy file name is checked. A misnamed unit test directory is silently never selected.
  • No untested target. Every target that a family's route can return has an accuracy test.
  • Tests actually run somewhere. Every modeling_v2 unit test is reached by a test-db list. A test that no list reaches never runs in CI.

The deleted test_every_target_has_the_accuracy_gate_of_its_name and test_every_unit_test_is_in_a_test_list covered part of this. They could be adapted so they don't depend on naming conventions, for example by identifying targets through the classes route can return instead of through directory names or import lines.

CBTS selects Modeling V2 tests by the scope of a change: a target change runs that target's tests, family and catalog code run the targets and unit tests that import it, and shared code runs everything. Accuracy tests move to one directory per target, l0_b300 gets one entry per target, and test_modeling_v2_ci_selection.py checks the structure that selection relies on. Naming and layout are no longer enforced.

Co-authored-by: Tao Li <[email protected]>
Signed-off-by: Eric Tsai <[email protected]>
@erictsai-nv
erictsai-nv force-pushed the codex/modeling-v2-readme-alignment branch from f98d07d to c232d2a Compare November 4, 2026 04:03
@erictsai-nv erictsai-nv changed the title [None][chore] Relax Modeling V2 naming and layout checks [None][chore] Relax Modeling V2 naming and Select Modeling V2 tests by change scope Nov 4, 2026
@erictsai-nv erictsai-nv changed the title [None][chore] Relax Modeling V2 naming and Select Modeling V2 tests by change scope [None][chore] Relax Modeling V2 naming and select Modeling V2 tests by change scope Nov 4, 2026
@erictsai-nv erictsai-nv closed this Nov 4, 2026
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