Skip to content

[tests] Add per-backend testcase skipping config - #5735

Merged
tianyu-l merged 2 commits into
pytorch:mainfrom
lixing-he:test/integration-skip-logic-yaml
Nov 17, 2026
Merged

tianyu-l merged 2 commits into
pytorch:mainfrom
lixing-he:test/integration-skip-logic-yaml

Conversation

@lixing-he

@lixing-he lixing-he commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Replace the per-definition skip_rocm_test: bool on integration tests with a
single TOML file under tests/integration_tests/hardware_skips/:

  • one top-level key per backend, matched against utils.device_type; cuda /
    rocm are distinguished with torch.version.hip;
  • the loader merges every source; the runner filters during selection and logs
    the skip;
  • out-of-tree devices can register their own TOML through an entry point or by
    calling register_hardware_skips() explicitly, using the same format and
    parser as the in-tree file;
  • the default rules migrate the 24 ROCm skips in the core suites; the seven
    graph_trainer skips move to their own TOML, registered by that runner;
  • add a README, a rule, and unit tests.

Background

Integration tests currently have no unified skip mechanism: skipping is spread
across per-definition booleans, and some of them, such as skip_rocm_test, are
tightly coupled to specific hardware.

Design

Skip rules live under tests/integration_tests/hardware_skips/:

tests/integration_tests/hardware_skips/
  __init__.py        # parse, merge, validate, query
  skipped_tests.toml # default rules maintained by titan
  README.md          # format and registration

TOML format

rocm = [
  "sdc_replay_accelerator_graph",
  "fsdp_pp_deferred_gradient_reduction",
  "deepseek_v3_fused_mla_swiglu_fsdp+ep",
  "qwen3_5_moe_fsdp+tp+ep",
  "dist_gemm",   # symmetric memory is CUDA-only
]
  • keys are matched against the backend: xpu and so on compare directly with
    utils.device_type; cuda and rocm are special cases because both report
    device_type == "cuda", and are distinguished with torch.version.hip;
  • values are the test_names of IntegrationTestDefinition entries;
  • reasons are trailing comments on the entry; a value that is not an array of
    strings raises ValueError before any test starts.

Registering an out-of-tree device

Beyond the default file, an out-of-tree device can register its own TOML, using
the same schema, in two ways:

  1. entry point:

    [project.entry-points."torchtitan.integration_tests.hardware_skips"]
    device = "your_package.hardware_skips:register"
    # your_package/hardware_skips/__init__.py
    def register(): register_hardware_skips("path/to/your_toml")
  2. call register_hardware_skips(path) directly from the test bootstrap.

Migration

  • remove skip_rocm_test from IntegrationTestDefinition;
  • move the 24 skip_rocm_test=True entries in the core suites into
    tests/integration_tests/hardware_skips/skipped_tests.toml under rocm;
  • move the seven graph_trainer skip_rocm_test=True entries into
    torchtitan/experiments/graph_trainer/tests/hardware_skips/skipped_tests.toml,
    registered by that runner;
  • add tests/integration_tests/hardware_skips/README.md, link it from the Test
    Structure in tests/README.md, and add a rule to .claude/rules/tests.md;
  • the test cases themselves are unchanged; out-of-tree callers that still pass
    skip_rocm_test are incompatible and need to move to the TOML.

Validation

Selection over the current main inventory (86 definitions: features 51 /
models 26 / h100 9):

  • CUDA: 86 runnable / 0 filtered;
  • ROCm: 62 runnable / 24 filtered (features 14 / models 6 / h100 4), matching the
    current skip_rocm_test=True count;
  • tests/unit_tests/cpu/test_hardware_skips.py: 5 tests pass, covering parse
    errors, registration, hardware matching, entry-point registration/failure, and
    runner skipping by test name.

@meta-cla

meta-cla Bot commented Nov 2, 2026

Copy link
Copy Markdown

Hi @lixing-he!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@lixing-he
lixing-he marked this pull request as ready for review November 3, 2026 07:23
@lixing-he
lixing-he requested a review from tianyu-l as a code owner November 3, 2026 07:23
@pytorch-bot pytorch-bot Bot added the ciflow/fake-pg Run 1-GPU Fake PG integration tests label Nov 3, 2026
@pytorch-bot

pytorch-bot Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Workflows were awaiting approval. CI has now been triggered for the ciflow labels on this PR.

@tianyu-l

tianyu-l commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

@claude review

@claude

claude Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @tianyu-l's task in 1m 50s —— View job


Request changes: review -- nothing in the repo uses the new skip-plugin machinery, and removing disabled/skip_rocm_test breaks the graph_trainer integration tests.

@claude claude Bot 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.

Verdict: Request changes -- the PR adds a plugin system (entry points, a register API, two env vars) that nothing in the repo uses, and removing disabled/skip_rocm_test breaks the graph_trainer integration tests and a CPU unit test.

What this PR does. It deletes skip_rocm_test and disabled from IntegrationTestDefinition and moves the 24 ROCm skips into tests/integration_tests/skips/skip_cases.toml, keyed by backend section and then by suite. _filter_tests now looks up (suite, test_name) in a merged skip table. The table is built when the module is imported, from the default TOML, TORCHTITAN_SKIP_CASES paths, and torchtitan.skip_cases entry points.

Example.

# before (h100.py): skip and reason sit next to the test
IntegrationTestDefinition(..., test_name="deepseek_v3_fsdp+hybridep",
    # deep_ep/NVSHMEM is CUDA-only, so skip on ROCm.
    skip_rocm_test=True)
# after: reason deleted, name listed in another file
# skip_cases.toml
[rocm]
h100 = ["deepseek_v3_fsdp+hybridep", ...]

An out-of-tree NPU repo would ship its own TOML and register it with an entry point. That repo can already skip tests today with --exclude a,b,c.

Must fix

  1. The problem isn't concrete. The description says skipping "is spread across per-definition booleans" but doesn't show a workflow that fails on main, and it doesn't name an out-of-tree user. Please add the use case (which device repo, and why --exclude isn't enough), or drop the extension machinery.
  2. skips/__init__.py:68-104 -- plugin system with no consumer, two new env vars, and side effects at import time (inline).
  3. __init__.py:35 -- removing the fields breaks graph_trainer/tests/integration_tests.py (18 uses; TypeError on import) and test_integration_test_definitions.py:140,159. Graph_trainer suites also can't be listed in the TOML, because validate_suite only accepts _TEST_SUITES (inline).
  4. h100.py:194 -- the skip reasons are deleted, and the skips now live away from the test definitions (inline). Unrelated file-mode changes on h100.py and models.py.

Should consider

  • skips/__init__.py:108 -- the backend now comes from torch.version.hip, while --gpu_arch_type still selects the goldens (inline).
  • skips/__init__.py:120 imports _TEST_SUITES, a private name, from run_tests inside a function to avoid a circular import. Malformed files raise TypeError (lines 51, 57); ValueError is the convention for bad user input.
Details

Smaller alternative (about -20/+15 LoC instead of +158 net): replace skip_rocm_test: bool with skip_backends: frozenset[Literal["cuda", "rocm", "xpu", "npu"]] = frozenset() on IntegrationTestDefinition, keep the reason comment next to each entry, and filter on the backend in _filter_tests. Keep disabled (graph_trainer still uses it), or migrate those callers in the same PR. Out-of-tree devices keep using --exclude, which exists today. Add an extension point only once a named user needs one.

Not verified: the runnable/filtered counts in the description (requires running on CUDA and ROCm).

Comment on lines -35 to -36
disabled: bool = False
skip_rocm_test: bool = False

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.

This removes both fields, but some callers still use them:

  • torchtitan/experiments/graph_trainer/tests/integration_tests.py passes skip_rocm_test=True / disabled=... to IntegrationTestDefinition 18 times (e.g. lines 332, 345, 386, 514). Importing that module now raises TypeError: unexpected keyword argument, which breaks every graph_trainer integration workflow.
  • tests/unit_tests/cpu/test_integration_test_definitions.py:140,159 reads test.disabled, which now raises AttributeError.

Those graph_trainer skips also can't move to the TOML. Its suites (graph_trainer_default, graph_trainer_h100, ...) aren't in _TEST_SUITES, so validate_suite rejects any section that names them. The PR needs a migration path for every caller, or it should keep the fields.

Comment on lines +68 to +104
def register_skip_cases(source: str | Path) -> None:
"""Register an additional skip-cases file with the same schema.

Registration must happen before the runner starts filtering tests.
"""
path = Path(source)
_SECTIONS.extend(_parse(path.read_text(), str(path)))


def _import_skip_case_extensions() -> None:
"""Leverage the Python plugin mechanism to load out-of-the-tree skip cases."""
from importlib.metadata import entry_points

group_name = "torchtitan.skip_cases"
skip_case_extensions = entry_points(group=group_name)

for skip_case_extension in skip_case_extensions:
try:
entrypoint = skip_case_extension.load()
entrypoint()
except Exception as err:
raise RuntimeError(
f"Failed to load the skip-cases extension: "
f"{skip_case_extension.name}. You can disable extension "
"auto-loading with TORCHTITAN_SKIP_CASES_AUTOLOAD=0."
) from err


def _is_skip_case_autoload_enabled() -> bool:
return os.getenv("TORCHTITAN_SKIP_CASES_AUTOLOAD", "1") == "1"


_SECTIONS.extend(_parse(SKIP_CASES_FILE.read_text(), str(SKIP_CASES_FILE)))
for _path in os.environ.get("TORCHTITAN_SKIP_CASES", "").split(os.pathsep):
if _path.strip():
register_skip_cases(_path.strip())
if _is_skip_case_autoload_enabled():

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.

This adds three extension mechanisms: the torchtitan.skip_cases entry-point group, the register_skip_cases() API, and two env vars (TORCHTITAN_SKIP_CASES, TORCHTITAN_SKIP_CASES_AUTOLOAD). None of them has an in-repo consumer or a named out-of-tree user. .claude/rules/design.md says not to build plugin systems or registries before a second implementation exists, and to keep env vars to a minimum.

Out-of-tree CI can already skip tests without any of this: --exclude name1,name2 (run_tests.py:588). If a device repo needs more than that, please name the user and say why --exclude doesn't work for them.

Separately, lines 100-104 read files, read env vars and run third-party entry points when the module is imported. design.md asks that imports have no side effects.

Comment on lines -194 to -195
# deep_ep/NVSHMEM is CUDA-only, so skip on ROCm.
skip_rocm_test=True,

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.

The reason for each skip gets deleted along with the flag: "deep_ep/NVSHMEM is CUDA-only" here, "symmetric memory is CUDA-only" below, and the DeepSeek V4 sparse-attention and Qwen3.5 short_conv notes in models.py. skip_cases.toml keeps only a bare list of names. Nobody can tell which ROCm skips are permanent hardware limits and which are TODOs to re-validate, and a test rename now has to be made in two files.

Smallest fix: keep the skip next to the definition, e.g. skip_backends: frozenset[Literal["cuda", "rocm", "xpu", "npu"]] = frozenset() with the comment beside it. Also, this file and models.py change mode from 100755 to 100644, which looks unrelated to this PR. Please revert the mode change.

Comment on lines +108 to +115
def _section_applies(name: str) -> bool:
if name == "all":
return True
if name == "rocm":
return utils.device_type == "cuda" and torch.version.hip is not None
if name == "cuda":
return utils.device_type == "cuda" and torch.version.hip is None
return utils.device_type == name

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.

The ROCm skip used to follow --gpu_arch_type. Now it follows torch.version.hip, but --gpu_arch_type still picks gpu_arch and the golden files (run_tests.py:619) and is still passed to run_single_test. That leaves two sources of truth for the backend. Either derive the backend from one place, or drop --gpu_arch_type as an input. (Should consider; nothing in-repo breaks today, since ROCm CI runs a HIP build.)

@tianyu-l

tianyu-l commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

@claude review

@claude

claude Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @tianyu-l's task in 1m 52s —— View job


Request changes: review -- the follow-up commit fixes the graph_trainer breakage, but the PR now has two ROCm skip mechanisms, the transformers_modeling_backend runner crashes on args.test_suite, and the plugin system still has no named user.

@claude claude Bot 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.

Verdict: Request changes -- the plugin system still has no named user, the second commit leaves two ROCm skip mechanisms side by side, and the transformers_modeling_backend runner now crashes.

What changed since the last review (a3bddfc). disabled and skip_rocm_test are restored on IntegrationTestDefinition, along with their filter in _filter_tests. Skip reasons are now TOML comments, and the file-mode changes on h100.py and models.py are reverted.

Example.

# graph_trainer: skipped when --gpu_arch_type rocm, nothing logged
IntegrationTestDefinition(..., skip_rocm_test=True)
# core suites: skipped when torch.version.hip is set, a skip is logged
# skip_cases.toml
[rocm]
h100 = ["dist_gemm", ...]

On main there is one ROCm skip flag. With this PR there are two, and each uses a different backend check.

Earlier must-fix items

  • Resolved: the graph_trainer TypeError and the unit test AttributeError (the fields are back).
  • Resolved: the file-mode changes, and the lost skip reasons (now TOML comments for 7 of the 24 entries).
  • Still open: the problem isn't concrete. No out-of-tree user is named, and the description doesn't say why --exclude isn't enough.
  • Still open: skips/__init__.py:68-105. The entry points, register_skip_cases, and two env vars have no consumer, and the module has side effects at import time.

Must fix

  1. The PR description is stale. It still says the PR removes disabled and skip_rocm_test, and that the TOML is the single mechanism. The validation counts ("ROCm 62 runnable / 24 filtered") need to be rechecked against the current code.
  2. run_tests.py:389 -- args.test_suite is read unconditionally. transformers_modeling_backend/tests/integration_tests.py has no --test_suite, so its runner now raises AttributeError (inline).
  3. run_tests.py:406-416 -- skip_rocm_test (follows --gpu_arch_type, no log) and [rocm] (follows torch.version.hip, logged) are two ROCm skip mechanisms. Pick one, and migrate every caller (inline).

Should consider

  • skips/__init__.py:120 still imports the private _TEST_SUITES lazily to avoid a circular import, and _parse still raises TypeError for bad input where torchtitan uses ValueError.
  • skips/ holds only __init__.py and one TOML file. design.md says to flatten folders that hold one or two files.
Details

Smallest alternative, unchanged from the last review (about -20/+15 LoC instead of +165 net): replace skip_rocm_test with skip_backends: frozenset[Literal["cuda", "rocm", "xpu", "npu"]] = frozenset() on the definition, keep each reason next to its entry, filter against one backend source, and migrate the 18 graph_trainer uses. Out-of-tree devices keep using --exclude. Add a TOML or plugin layer only once a named device repo needs one.

Not verified: the runnable/filtered counts on CUDA and ROCm (needs GPU runs).

Comment thread tests/integration_tests/run_tests.py Outdated
if hasattr(args, "exclude") and args.exclude:
exclude_set = {name.strip() for name in args.exclude.split(",")}

validate_suite(args.test_suite, {test.test_name for test in test_list})

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.

This line, and the lookup at line 413, read args.test_suite unconditionally. torchtitan/experiments/transformers_modeling_backend/tests/integration_tests.py:58-74 builds its own parser with no --test_suite and calls run_tests(args, test_list). That runner now fails with AttributeError: 'Namespace' object has no attribute 'test_suite' before it runs any test, which breaks integration_test_8gpu_transformers_modeling_backend.yaml and validate_release_gpu.sh:337. Before this PR, run_tests only read test_suite behind hasattr(args, "test_suite") (line 532).

If the TOML stays, take the suite as an explicit argument (or skip the lookup when there is no suite), and check every external caller of run_tests.

@tianyu-l

tianyu-l commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

the plugin system still has no named user

seems we need more documentation

@lixing-he

Copy link
Copy Markdown
Contributor Author

the plugin system still has no named user

seems we need more documentation

Thanks for the review. First, the documentation changes:

  • New tests/integration_tests/skips/README.md: TOML schema, when to use the
    file vs disabled vs --exclude, and the two registration paths.
  • tests/README.md: added a skips/ entry and a link to that README under
    Test Structure.
  • .claude/rules/tests.md: added a rule for backend-specific integration-test
    skips.

Three decisions for your review:

  1. We removed skip_rocm_test but left --gpu_arch_type. It duplicates the
    torch.version.hip check to some extent, but it is used in many places in
    the CI configuration under .github/, so removing it is a broader change. I
    left it out of this PR; it may be worth a separate cleanup.

  2. We kept the entry point. It overlaps with --exclude and introduces an API
    with no in-repo consumer yet, but it lets a downstream repo register its own
    file from its own package, using the same format and parser as the in-tree
    file.

  3. We kept disabled. It overlaps with the new skip mechanism, but it covers
    skips not caused by hardware coupling and temporary one-off skips;
    large-scale, per-backend skips live in the config file.

Would you be comfortable with these three decisions, or would you prefer a
different split?

@tianyu-l

tianyu-l commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

@claude review again

@claude

claude Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @tianyu-l's task in 3m 8s —— View job


Request changes: review -- 942bd33 fixes the earlier crash and removes the second ROCm mechanism. Still open: the entry-point plugin has no named user, the PR description is stale, and the graph_trainer TOML has to list the same tests twice because it's keyed by suite.

@claude claude Bot 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.

Verdict: Request changes -- 942bd33 fixes most of the earlier findings. Three things are still open: the entry-point plugin has no named user, the description is stale, and keying the TOML by suite forces the same test to be listed twice in graph_trainer.

What changed since the last review. skip_rocm_test is now removed everywhere. graph_trainer's 8 uses move into graph_trainer/tests/skips/skip_cases.toml, which is loaded with register_skip_cases(..., suites=...). disabled stays. Loading is now lazy, the TORCHTITAN_SKIP_CASES env var is gone, and bad input raises ValueError. A runner without --test_suite skips the file check, and a README is added.

Example.

# graph_trainer/tests/skips/skip_cases.toml: the same tests, twice
[rocm]
graph_trainer         = ["sdc_replay", "aot_fx_trace_llama3_fsdp_tp_cp", ...]
graph_trainer_default = ["sdc_replay", "aot_fx_trace_llama3_fsdp_tp_cp", ...]

A new llama3 ROCm skip has to go into both lists. If one is missed, that suite runs the test on ROCm and nothing reports it.

Earlier must-fix items

  • Resolved: the transformers_modeling_backend AttributeError (run_tests.py:282).
  • Resolved: two ROCm skip mechanisms (skip_rocm_test is gone, and graph_trainer is migrated).
  • Resolved: import-time side effects, the private _TEST_SUITES import, and TypeError raised for bad input.
  • Still open: the entry point (torchtitan.skip_cases) and TORCHTITAN_SKIP_CASES_AUTOLOAD have no consumer, and no out-of-tree device repo is named. register_skip_cases now has an in-repo user (graph_trainer), and it already covers a downstream repo that has its own runner. On your decision 2: drop the entry point and the env var until a named repo needs them.
  • Still open: the description is stale (below).

Must fix

  1. The PR description doesn't match the code. It says disabled is removed (it's kept), lists the deleted TORCHTITAN_SKIP_CASES env var as a registration path, says main "has no disabled=True cases" (graph_trainer has several), and doesn't mention the graph_trainer migration. The "86 / 62 / 24" counts cover only the core suites.
  2. graph_trainer/tests/skips/skip_cases.toml:2-17 -- the suite keys force duplicated lists (inline).

Should consider

  • graph_trainer/tests/skips/skip_cases.toml:4-5 -- the "ditto" comments carry the disabled reason over to tests that aren't disabled (inline).
  • skips/__init__.py:122-134 -- the "never half-filled" claim is false (inline).
  • tests/unit_tests/cpu/test_skip_cases.py -- tests private loader state; a CPU check of the shipped TOMLs against the real suites would guard more (inline).
  • .claude/rules/tests.md:45-50 -- this adds a maintainer-owned rule that makes the torchtitan.skip_cases entry point the official interface. Leave it out until maintainers settle decision 2.

Questions

  • For maintainers (@tianyu-l): your three decisions. My recommendation: (1) handle --gpu_arch_type in a separate PR -- fine, since it now only picks goldens; (2) drop the entry point; (3) keep disabled -- agreed.
Details

Every graph_trainer workflow passes --gpu_arch_type cuda, and no ROCm workflow runs graph_trainer. So the migrated graph_trainer ROCm skips are never exercised in CI. They weren't on main either.

If the suite keys go away (skips keyed by test name, validated against the union of the runner's suites), the duplication goes away, and so do suites=, _OUTSIDE_SUITES, and the core_suites argument of validate_suite.

Not verified: the runnable/filtered counts on CUDA and ROCm (needs GPU runs).

Comment on lines +2 to +17
graph_trainer = [
"sdc_replay",
"aot_fx_trace_llama3_fsdp_tp_cp", # aot_fx_trace applies CUDA graphs; disabled via _FLEX_CP_INDUCTOR_DISABLED
"aot_fx_trace_llama3_spmd_gradient_accumulation", # ditto
"aot_fx_trace_llama3_ga_per_microbatch_fsdp_collectives", # ditto
"aot_fx_trace_llama3_ga_first_unshard_last_reduce_fsdp", # ditto
"aot_fx_trace_llama3_fsdp_tp_sac_and_offload", # ditto; disabled=True
]
graph_trainer_default = [
"sdc_replay",
"aot_fx_trace_llama3_fsdp_tp_cp", # aot_fx_trace applies CUDA graphs; disabled via _FLEX_CP_INDUCTOR_DISABLED
"aot_fx_trace_llama3_spmd_gradient_accumulation", # ditto
"aot_fx_trace_llama3_ga_per_microbatch_fsdp_collectives", # ditto
"aot_fx_trace_llama3_ga_first_unshard_last_reduce_fsdp", # ditto
"aot_fx_trace_llama3_fsdp_tp_sac_and_offload", # ditto; disabled=True
]

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.

The same six llama3 tests appear twice here, once under graph_trainer and once under graph_trainer_default. Both suites are built from _build_llama3_tests() (integration_tests.py:602-614). Because the file is keyed by suite, a test that belongs to N suites has to be listed N times. If one copy is forgotten, that suite runs the test on ROCm and nothing reports it: validate_suite only checks for unknown names, not for missing ones. With skip_rocm_test on the definition, this mistake wasn't possible.

If the TOML stays, key the skips by test name per runner instead of by suite, e.g. [rocm] tests = [...], validated against the union of the runner's suites. That removes the duplication and also removes the need for suites=.

Comment on lines +4 to +5
"aot_fx_trace_llama3_fsdp_tp_cp", # aot_fx_trace applies CUDA graphs; disabled via _FLEX_CP_INDUCTOR_DISABLED
"aot_fx_trace_llama3_spmd_gradient_accumulation", # ditto

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.

The comments mix up the ROCm reason with the disabled reason. "disabled via _FLEX_CP_INDUCTOR_DISABLED" only applies to aot_fx_trace_llama3_fsdp_tp_cp, but the "ditto" lines below inherit it, so they claim spmd_gradient_accumulation and the two GA tests are disabled, and they aren't. sdc_replay has no reason at all (the original reason, "aot_fx_trace applies CUDA graph by default", covered only the aot_fx_trace entries). Please write one ROCm reason per entry and leave disabled state out of this file; the definition already records it.

Comment on lines +122 to +134
# ``_loading`` covers re-entry (an entry point may call register_skip_cases);
# ``_loaded`` is only set once everything was read, so a malformed file
# leaves the state empty instead of half-filled.
_loading = True
try:
_SECTIONS.extend(
_parse(SKIP_CASES_FILE.read_text(encoding="utf-8"), str(SKIP_CASES_FILE))
)
if _is_skip_case_autoload_enabled():
_import_skip_case_extensions()
_loaded = True
finally:
_loading = False

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.

The comment says a malformed file "leaves the state empty instead of half-filled", but the code doesn't do that. The default file is appended to _SECTIONS before any entry point runs. If an entry point then raises, _SECTIONS keeps the default sections and whatever earlier entry points registered, and the next _load() appends the default file again. Today the runner just crashes, so this has no effect yet. Still, either build into a local list and extend _SECTIONS once at the end, or delete the claim. If the entry point is dropped (see review body), _loading and most of this function go away too.

Comment thread tests/unit_tests/cpu/test_skip_cases.py Outdated
Comment on lines +112 to +145
def test_entry_point_registration(monkeypatch, tmp_path) -> None:
entry_file = tmp_path / "entry.toml"
entry_file.write_text('[all]\nfeatures = ["entry_case"]\n', encoding="utf-8")

class FakeEntryPoint:
name = "fake"

def load(self):
return lambda: skips.register_skip_cases(entry_file, suites={"features"})

monkeypatch.setenv("TORCHTITAN_SKIP_CASES_AUTOLOAD", "1")
monkeypatch.setattr(
importlib.metadata,
"entry_points",
lambda group=None: [FakeEntryPoint()],
)
skips._load()
assert any(section.source == str(entry_file) for section in skips._SECTIONS)

class BrokenEntryPoint:
name = "broken"

def load(self):
raise RuntimeError("boom")

skips._SECTIONS.clear()
skips._loaded = False
monkeypatch.setattr(
importlib.metadata,
"entry_points",
lambda group=None: [BrokenEntryPoint()],
)
with pytest.raises(RuntimeError, match="broken"):
skips._load()

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.

These 161 lines test how the loader works internally. They monkeypatch private module state (_loaded, _loading, _SECTIONS, _OUTSIDE_SUITES) and use fake entry points. The regression that actually matters isn't covered on CPU: a shipped skip_cases.toml entry that goes stale after a test is renamed. Today that only fails when the suite runs on a GPU runner. .claude/rules/tests.md asks tests to guard real invariants and not snapshot private layouts.

Suggest replacing the file with one test in test_integration_test_definitions.py. It would parse both shipped TOML files and check every entry against the real suite builders (those builders are already called on CPU there). That catches renames before CI time is spent, and a parse error would surface there too.

@lixing-he

Copy link
Copy Markdown
Contributor Author

Verdict: Request changes -- 942bd33 fixes most of the earlier findings. Three things are still open: the entry-point plugin has no named user, the description is stale, and keying the TOML by suite forces the same test to be listed twice in graph_trainer.

What changed since the last review. skip_rocm_test is now removed everywhere. graph_trainer's 8 uses move into graph_trainer/tests/skips/skip_cases.toml, which is loaded with register_skip_cases(..., suites=...). disabled stays. Loading is now lazy, the TORCHTITAN_SKIP_CASES env var is gone, and bad input raises ValueError. A runner without --test_suite skips the file check, and a README is added.

Example.

# graph_trainer/tests/skips/skip_cases.toml: the same tests, twice
[rocm]
graph_trainer         = ["sdc_replay", "aot_fx_trace_llama3_fsdp_tp_cp", ...]
graph_trainer_default = ["sdc_replay", "aot_fx_trace_llama3_fsdp_tp_cp", ...]

A new llama3 ROCm skip has to go into both lists. If one is missed, that suite runs the test on ROCm and nothing reports it.

Earlier must-fix items

  • Resolved: the transformers_modeling_backend AttributeError (run_tests.py:282).
  • Resolved: two ROCm skip mechanisms (skip_rocm_test is gone, and graph_trainer is migrated).
  • Resolved: import-time side effects, the private _TEST_SUITES import, and TypeError raised for bad input.
  • Still open: the entry point (torchtitan.skip_cases) and TORCHTITAN_SKIP_CASES_AUTOLOAD have no consumer, and no out-of-tree device repo is named. register_skip_cases now has an in-repo user (graph_trainer), and it already covers a downstream repo that has its own runner. On your decision 2: drop the entry point and the env var until a named repo needs them.
  • Still open: the description is stale (below).

Must fix

  1. The PR description doesn't match the code. It says disabled is removed (it's kept), lists the deleted TORCHTITAN_SKIP_CASES env var as a registration path, says main "has no disabled=True cases" (graph_trainer has several), and doesn't mention the graph_trainer migration. The "86 / 62 / 24" counts cover only the core suites.
  2. graph_trainer/tests/skips/skip_cases.toml:2-17 -- the suite keys force duplicated lists (inline).

Should consider

  • graph_trainer/tests/skips/skip_cases.toml:4-5 -- the "ditto" comments carry the disabled reason over to tests that aren't disabled (inline).
  • skips/__init__.py:122-134 -- the "never half-filled" claim is false (inline).
  • tests/unit_tests/cpu/test_skip_cases.py -- tests private loader state; a CPU check of the shipped TOMLs against the real suites would guard more (inline).
  • .claude/rules/tests.md:45-50 -- this adds a maintainer-owned rule that makes the torchtitan.skip_cases entry point the official interface. Leave it out until maintainers settle decision 2.

Questions

  • For maintainers (@tianyu-l): your three decisions. My recommendation: (1) handle --gpu_arch_type in a separate PR -- fine, since it now only picks goldens; (2) drop the entry point; (3) keep disabled -- agreed.

Details
Every graph_trainer workflow passes --gpu_arch_type cuda, and no ROCm workflow runs graph_trainer. So the migrated graph_trainer ROCm skips are never exercised in CI. They weren't on main either.

If the suite keys go away (skips keyed by test name, validated against the union of the runner's suites), the duplication goes away, and so do suites=, _OUTSIDE_SUITES, and the core_suites argument of validate_suite.

Not verified: the runnable/filtered counts on CUDA and ROCm (needs GPU runs).

The PR description has updated.

@tianyu-l

tianyu-l commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

@claude review

@claude

claude Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @tianyu-l's task in 1m 25s —— View job


Request changes: review -- the description now matches the code. The code is unchanged since 942bd33, so the unused entry point and the duplicated suite-keyed graph_trainer lists are still open, and they wait on a maintainer decision.

@claude claude Bot 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.

Verdict: Request changes -- the code hasn't changed since the last review (HEAD is still 942bd33), and only the description was updated. It now matches the code, but the two design issues are still open: the entry point has no named user, and the suite-keyed TOML makes graph_trainer list the same tests twice.

What changed since the last review. Only the PR description. It now describes skip_rocm_test being replaced while disabled stays, drops the deleted TORCHTITAN_SKIP_CASES env var, covers the graph_trainer migration (7 skips on main, which matches integration_tests.py:332-628 there), and lists the 5 unit tests that actually exist.

Example. This is still the case at HEAD:

# graph_trainer/tests/skips/skip_cases.toml
[rocm]
graph_trainer         = ["sdc_replay", "aot_fx_trace_llama3_fsdp_tp_cp", ...]  # 6 entries
graph_trainer_default = ["sdc_replay", "aot_fx_trace_llama3_fsdp_tp_cp", ...]  # same 6 again

Both suites are built from _build_llama3_tests(). If a new llama3 ROCm skip is added to only one list, the other suite runs that test on ROCm, and validate_suite doesn't catch it (it only rejects unknown names, not missing ones).

Earlier must-fix items

  • Resolved: the description is stale. It now matches the code.
  • Still open: the torchtitan.skip_cases entry point and TORCHTITAN_SKIP_CASES_AUTOLOAD (skips/__init__.py:83-103) have no consumer, and neither the description nor the README names an out-of-tree device repo. graph_trainer shows that register_skip_cases() alone already covers a repo with its own runner. Either name the downstream user and explain why an explicit register_skip_cases() call isn't enough for them, or drop the entry point, the env var, and _loading.
  • Still open: graph_trainer/tests/skips/skip_cases.toml:2-17. Suite keys force the lists to be duplicated (see the earlier inline comment). Keying each runner's file by test name and validating against the union of that runner's suites removes the duplication, along with suites=, _OUTSIDE_SUITES, and the core_suites argument.

Should consider (still open, unchanged)

  • graph_trainer/tests/skips/skip_cases.toml:4-9: the "ditto" comments carry the _FLEX_CP_INDUCTOR_DISABLED reason over to tests that aren't disabled, and sdc_replay has no reason.
  • skips/__init__.py:122-124: the "never half-filled" comment is false.
  • tests/unit_tests/cpu/test_skip_cases.py: tests private loader state. One test in test_integration_test_definitions.py that checks both shipped TOMLs against the real suite builders would catch stale names on CPU.
  • .claude/rules/tests.md:45-50: names the torchtitan.skip_cases entry point as the official interface. Leave it out until decision 2 is settled.

Questions

  • @tianyu-l: the author's three decisions (comment of 11-04) still need a maintainer answer, especially (2), whether to keep the entry point. The fixes above depend on it.

Not verified: the CUDA/ROCm runnable and filtered counts (these need GPU runs).

@lixing-he
lixing-he requested a review from ydwu4 as a code owner November 9, 2026 11:17
@lixing-he

Copy link
Copy Markdown
Contributor Author

Verdict: Request changes -- the code hasn't changed since the last review (HEAD is still 942bd33), and only the description was updated. It now matches the code, but the two design issues are still open: the entry point has no named user, and the suite-keyed TOML makes graph_trainer list the same tests twice.

What changed since the last review. Only the PR description. It now describes skip_rocm_test being replaced while disabled stays, drops the deleted TORCHTITAN_SKIP_CASES env var, covers the graph_trainer migration (7 skips on main, which matches integration_tests.py:332-628 there), and lists the 5 unit tests that actually exist.

Example. This is still the case at HEAD:

# graph_trainer/tests/skips/skip_cases.toml
[rocm]
graph_trainer         = ["sdc_replay", "aot_fx_trace_llama3_fsdp_tp_cp", ...]  # 6 entries
graph_trainer_default = ["sdc_replay", "aot_fx_trace_llama3_fsdp_tp_cp", ...]  # same 6 again

Both suites are built from _build_llama3_tests(). If a new llama3 ROCm skip is added to only one list, the other suite runs that test on ROCm, and validate_suite doesn't catch it (it only rejects unknown names, not missing ones).

Earlier must-fix items

  • Resolved: the description is stale. It now matches the code.
  • Still open: the torchtitan.skip_cases entry point and TORCHTITAN_SKIP_CASES_AUTOLOAD (skips/__init__.py:83-103) have no consumer, and neither the description nor the README names an out-of-tree device repo. graph_trainer shows that register_skip_cases() alone already covers a repo with its own runner. Either name the downstream user and explain why an explicit register_skip_cases() call isn't enough for them, or drop the entry point, the env var, and _loading.
  • Still open: graph_trainer/tests/skips/skip_cases.toml:2-17. Suite keys force the lists to be duplicated (see the earlier inline comment). Keying each runner's file by test name and validating against the union of that runner's suites removes the duplication, along with suites=, _OUTSIDE_SUITES, and the core_suites argument.

Should consider (still open, unchanged)

  • graph_trainer/tests/skips/skip_cases.toml:4-9: the "ditto" comments carry the _FLEX_CP_INDUCTOR_DISABLED reason over to tests that aren't disabled, and sdc_replay has no reason.
  • skips/__init__.py:122-124: the "never half-filled" comment is false.
  • tests/unit_tests/cpu/test_skip_cases.py: tests private loader state. One test in test_integration_test_definitions.py that checks both shipped TOMLs against the real suite builders would catch stale names on CPU.
  • .claude/rules/tests.md:45-50: names the torchtitan.skip_cases entry point as the official interface. Leave it out until decision 2 is settled.

Questions

  • @tianyu-l: the author's three decisions (comment of 11-04) still need a maintainer answer, especially (2), whether to keep the entry point. The fixes above depend on it.

Not verified: the CUDA/ROCm runnable and filtered counts (these need GPU runs).

The comments have been updated based on the suggestions. But graph_trainer and graph_trainer_default remain as they are in the graph_trainer/tests/skips/skip_cases.toml, because a testcase here originally belongs to both suites.

@tianyu-l

tianyu-l commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

@claude review

@claude

claude Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @tianyu-l's task in 1m 18s —— View job


Request changes: review -- e39eac6 only changes comments. The entry point still has no named user, and the suite-keyed graph_trainer lists are still duplicated; both wait on a maintainer decision.

@claude claude Bot 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.

Verdict: Request changes -- e39eac6 only changes comments. Two design items are still open: the entry point has no named user, and keying the TOML by suite still makes graph_trainer list the same tests twice.

What changed since the last review. One commit, e39eac6, which only edits comments. The _load() comment now matches the code. The graph_trainer TOML drops the "ditto" and disabled notes and gives each aot_fx_trace_* entry its own reason.

Example. On your reply that "a testcase here originally belongs to both suites": that's true, but the ROCm skip belongs to the test, not to the suite. On main it was one skip_rocm_test=True on the definition, and every suite built from _build_llama3_tests() inherited it. With suite keys:

[rocm]
graph_trainer         = ["sdc_replay", "aot_fx_trace_llama3_fsdp_tp_cp", ...]  # 6 entries
graph_trainer_default = ["sdc_replay", "aot_fx_trace_llama3_fsdp_tp_cp", ...]  # the same 6

Suppose a seventh llama3 test is added to only one of these lists. The other suite then runs it on ROCm, and validate_suite passes, because it only rejects unknown names. It never checks for missing ones. Keyed by test name, the same file has one list:

[rocm]
tests = ["sdc_replay", "aot_fx_trace_llama3_fsdp_tp_cp", ..., "aot_fx_trace_llama3_fsdp_tp_asynctp"]

Each runner validates this list against the union of the test names in its own suites. That removes the duplication, and with it suites=, _OUTSIDE_SUITES, and the core_suites argument of validate_suite. The core suites lose nothing: features/models/h100 are disjoint lists, so the suite key there was never doing any disambiguation.

Earlier must-fix items

  • Resolved: the "never half-filled" comment (skips/__init__.py:122-124).
  • Resolved: the "ditto" comments that carried the disabled reason over to tests that aren't disabled (graph_trainer/tests/skips/skip_cases.toml).
  • Still open: the torchtitan.skip_cases entry point and TORCHTITAN_SKIP_CASES_AUTOLOAD (skips/__init__.py:83-106) have no consumer, and no out-of-tree device repo is named. graph_trainer already shows that an explicit register_skip_cases() call covers a runner that has its own bootstrap. Name the downstream repo and say why that call isn't enough for it, or drop the entry point, the env var, and _loading.
  • Still open: graph_trainer/tests/skips/skip_cases.toml:2-17, the duplicated suite-keyed lists (see the example above).

Should consider (still open)

  • graph_trainer/tests/skips/skip_cases.toml:3,11: sdc_replay still has no ROCm reason. The comment on main ("aot_fx_trace applies CUDA graph by default") covered only the aot_fx_trace_* entries.
  • .claude/rules/tests.md:45-50: still presents the torchtitan.skip_cases entry point as the official interface for out-of-tree repos. Leave it out until decision 2 is settled.
  • tests/unit_tests/cpu/test_skip_cases.py: still tests private loader state (_loaded, _loading, _SECTIONS, _OUTSIDE_SUITES). One test in test_integration_test_definitions.py that checks both shipped TOMLs against the real suite builders would catch stale names on CPU.

Questions

  • @tianyu-l: the author's decision 2 (keep the entry point) still needs a maintainer answer. The open items above depend on it.

Not verified: the CUDA/ROCm runnable and filtered counts (these need GPU runs).

@lixing-he

Copy link
Copy Markdown
Contributor Author

Verdict: Request changes -- e39eac6 only changes comments. Two design items are still open: the entry point has no named user, and keying the TOML by suite still makes graph_trainer list the same tests twice.

What changed since the last review. One commit, e39eac6, which only edits comments. The _load() comment now matches the code. The graph_trainer TOML drops the "ditto" and disabled notes and gives each aot_fx_trace_* entry its own reason.

Example. On your reply that "a testcase here originally belongs to both suites": that's true, but the ROCm skip belongs to the test, not to the suite. On main it was one skip_rocm_test=True on the definition, and every suite built from _build_llama3_tests() inherited it. With suite keys:

[rocm]
graph_trainer         = ["sdc_replay", "aot_fx_trace_llama3_fsdp_tp_cp", ...]  # 6 entries
graph_trainer_default = ["sdc_replay", "aot_fx_trace_llama3_fsdp_tp_cp", ...]  # the same 6

Suppose a seventh llama3 test is added to only one of these lists. The other suite then runs it on ROCm, and validate_suite passes, because it only rejects unknown names. It never checks for missing ones. Keyed by test name, the same file has one list:

[rocm]
tests = ["sdc_replay", "aot_fx_trace_llama3_fsdp_tp_cp", ..., "aot_fx_trace_llama3_fsdp_tp_asynctp"]

Each runner validates this list against the union of the test names in its own suites. That removes the duplication, and with it suites=, _OUTSIDE_SUITES, and the core_suites argument of validate_suite. The core suites lose nothing: features/models/h100 are disjoint lists, so the suite key there was never doing any disambiguation.

Earlier must-fix items

  • Resolved: the "never half-filled" comment (skips/__init__.py:122-124).
  • Resolved: the "ditto" comments that carried the disabled reason over to tests that aren't disabled (graph_trainer/tests/skips/skip_cases.toml).
  • Still open: the torchtitan.skip_cases entry point and TORCHTITAN_SKIP_CASES_AUTOLOAD (skips/__init__.py:83-106) have no consumer, and no out-of-tree device repo is named. graph_trainer already shows that an explicit register_skip_cases() call covers a runner that has its own bootstrap. Name the downstream repo and say why that call isn't enough for it, or drop the entry point, the env var, and _loading.
  • Still open: graph_trainer/tests/skips/skip_cases.toml:2-17, the duplicated suite-keyed lists (see the example above).

Should consider (still open)

  • graph_trainer/tests/skips/skip_cases.toml:3,11: sdc_replay still has no ROCm reason. The comment on main ("aot_fx_trace applies CUDA graph by default") covered only the aot_fx_trace_* entries.
  • .claude/rules/tests.md:45-50: still presents the torchtitan.skip_cases entry point as the official interface for out-of-tree repos. Leave it out until decision 2 is settled.
  • tests/unit_tests/cpu/test_skip_cases.py: still tests private loader state (_loaded, _loading, _SECTIONS, _OUTSIDE_SUITES). One test in test_integration_test_definitions.py that checks both shipped TOMLs against the real suite builders would catch stale names on CPU.

Questions

  • @tianyu-l: the author's decision 2 (keep the entry point) still needs a maintainer answer. The open items above depend on it.

Not verified: the CUDA/ROCm runnable and filtered counts (these need GPU runs).

I haven't made code changes for these points; here is my reasoning:

  1. I'd like to keep the entry point and related documentation as they are for now, and revisit their final shape after @tianyu-l replies.
  2. I'd prefer to keep the suite-keyed TOML. If we keyed entries by test name, a skip would apply to every suite containing that name, so we would lose the ability to distinguish same-named test cases in different suites. That does not happen today, but it could in the future.
  3. sdc_replay originally had no comment explaining why it is skipped on ROCm, so no comment is added here.
  4. I'd prefer to keep test_skip_cases.py self-contained and avoid depending on external files.

@lixing-he

Copy link
Copy Markdown
Contributor Author

@tianyu-l Thanks for the reviews. There are a few points I've been wanting to confirm with you:

  1. I removed skip_rocm_test but left --gpu_arch_type in place. It appears in many places in the CI configuration under .github/, so removing it would be a broader change. I'd prefer to handle it in a separate follow-up.

  2. The entry-point mechanism overlaps with --exclude and has no in-repo consumer yet, but it lets downstream repos register their own file automatically and keeps the configuration format consistent with the in-tree file.

  3. I kept disabled. It also overlaps with the config-file-based skips in this PR, but it is more flexible for skips not caused by hardware coupling and for temporary single-test skips.

Happy to adjust any of these based on your preference.

Comment thread tests/integration_tests/skips/README.md Outdated
|---|---|---|
| `skip_cases.toml` | permanent, backend-wide skips | this directory |
| `disabled=True` | skips not caused by hardware coupling, and temporary one-off skips | the definition |
| `--exclude a,b,c` | skipping a few cases for one invocation | the command line |

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.

there are in-repo usage for this

  • scripts/ci/pytorch_ci_test_runner.sh#L37
  • .github/scripts/validate_release_gpu.sh#L382
  • .github/scripts/run_8xgpu_integration_tests.sh#L81

maybe let's link them here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added in the latest commit.

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.

I imagine it'd be easier to make per-hardware files, when more and more hardware join CI.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in the latest commit — each backend now has its own file under tests/integration_tests/hardware_skips/

Comment thread tests/integration_tests/skips/README.md Outdated
Comment on lines +49 to +51
# pyproject.toml of the device repo
[project.entry-points."torchtitan.skip_cases"]
my_device = "my_device.tests:register_skips"

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.

device repo means your fork of torchtitan?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not a fork of torchtitan — by "device repo" I mean an out-of-tree downstream repo that provides an additional device backend to torchtitan. I've added this definition to the README in the latest commit.



def _is_skip_case_autoload_enabled() -> bool:
return os.getenv("TORCHTITAN_SKIP_CASES_AUTOLOAD", "1") == "1"

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.

can we remove this env for now? if not, what's the use case

if you have to use it, could you use an arg, instead of envvar?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed it in the latest commit, it's actually useless.

Comment on lines +127 to +129
_SECTIONS.extend(
_parse(SKIP_CASES_FILE.read_text(encoding="utf-8"), str(SKIP_CASES_FILE))
)

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.

can we not invent multiple ways of doing the same thing -- could we just use register_skip_cases for tests in the module as well

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in the latest commit — there is now a single registration path by using register_skip_cases

return sections


_SECTIONS: list[SkipSection] = []

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.

bad name, isn't it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed — renamed in the latest commit, also renamed some other variables, functions and directories

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.

Overall I believe this file can be made minimal and simpler

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've made some changes to this file, and it is indeed minimal and simpler now.

_OUTSIDE_SUITES: dict[str, frozenset[str]] = {}


def register_skip_cases(

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.

"skip case" is not clear about what it means, could you give it another try

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Renamed like above saying

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.

Still open: the torchtitan.skip_cases entry point and TORCHTITAN_SKIP_CASES_AUTOLOAD (skips/init.py:83-103) have no consumer, and neither the description nor the README names an out-of-tree device repo. graph_trainer shows that register_skip_cases() alone already covers a repo with its own runner. Either name the downstream user and explain why an explicit register_skip_cases() call isn't enough for them, or drop the entry point, the env var, and _loading.

I had the same impression. Right now it looks very complicated.

Still open: graph_trainer/tests/skips/skip_cases.toml:2-17. Suite keys force the lists to be duplicated (see the earlier inline comment). Keying each runner's file by test name and validating against the union of that runner's suites removes the duplication, along with suites=, _OUTSIDE_SUITES, and the core_suites argument.

I didn't understand this, but could you fix / improve.

the author's three decisions (comment of 11-04) still need a maintainer answer, especially (2), whether to keep the entry point. The fixes above depend on it.

I'm OK with the entry point.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review. In the latest commit, I've Simplified the entry-point mechanism and removed TORCHTITAN_SKIP_CASES_AUTOLOAD. And I fixed the problem with duplicate testcases in graph_trainer by using the testcase's name directly instead of the suite name + testcase's name.

There are also quite a few improvements in the latest commit, including documentation and code; I'd really appreciate it if you could take a look when you have time.

@lixing-he
lixing-he force-pushed the test/integration-skip-logic-yaml branch 2 times, most recently from 34fbd2b to 6a85727 Compare November 14, 2026 13:38
@tianyu-l

Copy link
Copy Markdown
Contributor

@claude review again

@claude

claude Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @tianyu-l's task in 2m 26s —— View job


Approve, please address the items below before merging: review. Your comments are addressed. Before merge: check that each TOML key matches its file name, delete the empty cuda.toml/xpu.toml files, and replace the private-state unit tests with a check that every shipped name exists in a real suite.

@claude claude Bot 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.

Verdict: Approve -- please address the items below before merging. The latest commits (6a85727, 7ab1947) address @tianyu-l's comments, and the design is now settled. The remaining items are small, local edits. A maintainer still needs to review, and @tianyu-l's change request is still in place.

What changed since the last review. Files are now one per backend (hardware_skips/<backend>.toml), and each holds a flat <backend> = [test names] list. Suite keys, suites=, _OUTSIDE_SUITES, validate_suite, TORCHTITAN_SKIP_CASES_AUTOLOAD and _loading are all gone. Everything goes through register_hardware_skips(), which accepts a file or a directory. The in-tree directory and the entry points are loaded the first time skips are queried. Names now use "hardware skips" instead of "skip cases", and the README links the in-repo --exclude callers.

Example.

# graph_trainer/tests/hardware_skips/rocm.toml: each test listed once
rocm = ["sdc_replay", "aot_fx_trace_llama3_fsdp_tp_cp", ..., "aot_fx_trace_llama3_fsdp_tp_asynctp"]

On ROCm (torch.version.hip set), every runner skips every listed name, whichever suite it is in. The duplicated lists are gone. The core file holds the 24 names from main, and the graph_trainer file holds the 7 (6 llama3 tests plus asynctp).

Earlier must-fix items

  • Resolved: the entry point. @tianyu-l is OK with keeping it, the env var is removed, and the README example is concrete.
  • Resolved: the duplicated suite-keyed graph_trainer lists. Skips are now matched by test name only.
  • Resolved: @tianyu-l's comments on naming, the env var, having a single registration path, per-hardware files, the README links, and the "device repo" definition.

Must fix

  1. hardware_skips/__init__.py:45-50: the file name and the top-level key name the backend twice, and nothing checks that they agree. A typo in the key silently disables every skip in that file. Require key == file.stem (inline).
  2. hardware_skips/cuda.toml, xpu.toml (in both directories): four empty placeholder files. Delete them (inline).
  3. tests/unit_tests/cpu/test_hardware_skips.py: name validation was removed in this revision, so a stale or misspelled name in a shipped TOML now goes unnoticed until a ROCm run. The new tests cover private loader state instead. Replace them with one CPU check that every shipped name exists in the real suite builders (inline).

Should consider

  • run_tests.py:385: the docstring says disabled is matched by name. It's --exclude that is (inline).
  • graph_trainer/tests/integration_tests.py:336-337: "which ROCm does not support" is a new claim that wasn't on main (inline).
Details

All registered sources are merged into one global set of names, so the graph_trainer and transformers_modeling_backend runners also apply the core rocm.toml, and the other way round when a runner registers more files. No names collide today. The test proposed in item 3 would make a collision visible if each file were checked against the runner that owns it, but that is optional.

tests/ is not an installed package (pyproject.toml only includes torchtitan* and torchtitan_recipes*). So the README's entry-point example, which imports tests.integration_tests.hardware_skips, only works when the runner is started from a torchtitan checkout. That is how the runners are launched today, so this is fine as is. It is worth one sentence in the README.

Decision 1 (--gpu_arch_type still picks the goldens, while skips follow torch.version.hip) is deferred to a follow-up, as agreed.

Not verified: the CUDA/ROCm runnable and filtered counts (these need GPU runs).

Comment on lines +45 to +50
for skip_hardware, tests in raw.items():
if not isinstance(tests, list) or not all(
isinstance(test, str) for test in tests
):
raise ValueError(f"{source}: {skip_hardware} must be an array of strings")
testcases.append(HardwareSkipTestCases(skip_hardware, frozenset(tests)))

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.

The backend is named twice, once by the file name and once by the top-level key, and nothing checks that they agree. The README says the key is what counts. So a rocm.toml that holds rocn = [...] or ROCm = [...] skips nothing, and one that holds cuda = [...] skips those tests on CUDA. Neither case raises an error. In both cases the misspelled key just falls through to utils.device_type == skip_hardware, which is False.

Since the maintainer asked for one file per backend, the smallest fix is to require that the key equals the file stem. Either raise in register_hardware_skips:

for file in files:
    testcases = _parse(file.read_text(encoding="utf-8"), str(file))
    if [t.skip_hardware for t in testcases] != [file.stem]:
        raise ValueError(f"{file}: must contain exactly one key, {file.stem!r}")
    _TESTCASES_TO_SKIP.extend(testcases)

or drop the key and take the backend from file.stem. With either fix, a file can't name a different backend from the one its file name says.

@@ -0,0 +1 @@
cuda = []

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.

cuda = [] and xpu = [], both here and under graph_trainer/tests/hardware_skips/, are four placeholder files with nothing in them. Loading an empty list has the same effect as having no file. Please delete them and add each file when it gets its first entry. The README already shows the format.

Comment on lines +14 to +16
from tests.integration_tests import IntegrationTestDefinition, hardware_skips
from tests.integration_tests.hardware_skips import HardwareSkipTestCases
from tests.integration_tests.run_tests import _filter_tests

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.

This revision removed validate_suite, so nothing checks a shipped name against a real test anymore. Today, if a test in rocm.toml is renamed or misspelled, its entry silently stops matching. The renamed test then runs on ROCm, and the failure only shows up on a ROCm runner, far from the rename.

These 168 lines don't catch that. They monkeypatch private state (_TESTCASES_TO_SKIP, _loaded, HARDWARE_SKIPS_DIR) and import the private _filter_tests from another module, which .claude/rules/tests.md and the naming rules ask us to avoid. Being self-contained is the reason the test misses the one regression that matters.

Suggest replacing the file with one CPU test, about 15 lines. It parses the shipped TOMLs in tests/integration_tests/hardware_skips/ and graph_trainer/tests/hardware_skips/, and asserts that every name appears in the union of the test_names from the suite builders (build_features_test_list, build_model_tests_list, build_h100_tests_list, the graph_trainer _TEST_SUITES_FUNCTION). test_integration_test_definitions.py already calls these builders on CPU, so the test fits there. A parse error in a shipped file would also fail that test, so test_parse_errors can go too.

Comment thread tests/integration_tests/run_tests.py Outdated
]:
"""Filter tests by name, scope, hardware skips, and GPU count.

Hardware skips are matched by test name, the same way ``disabled`` is.

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.

disabled is a field on the definition, so it isn't matched by name. --exclude is the one that matches by name.

Suggested change
Hardware skips are matched by test name, the same way ``disabled`` is.
Hardware skips are matched by test name, the same way ``--exclude`` is.

Comment on lines +336 to +337
# Note: aot_fx_trace applies CUDA graphs, which ROCm does not support;
# the ROCm skip lives in hardware_skips/rocm.toml.

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.

"which ROCm does not support" is a new claim that wasn't on main. PyTorch on ROCm does expose graph capture through torch.cuda.CUDAGraph (HIP graphs). The original note only said that aot_fx_trace turns CUDA graphs on by default. Please keep the original wording, or state the actual ROCm failure if someone has seen it. (unverified: I haven't checked whether these specific tests fail on ROCm.)

Suggested change
# Note: aot_fx_trace applies CUDA graphs, which ROCm does not support;
# the ROCm skip lives in hardware_skips/rocm.toml.
# Note: aot_fx_trace applies CUDA graph by default; the ROCm skip lives
# in hardware_skips/rocm.toml.

@tianyu-l tianyu-l 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.

looks nice, some remaining comments

return utils.device_type == skip_hardware


def get_testcases_should_skip_on_current_hardware() -> set[str]:

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.

Suggested change
def get_testcases_should_skip_on_current_hardware() -> set[str]:
def get_tests_to_skip_on_current_hardware() -> set[str]:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed the name in latest commit.

Comment on lines +64 to +68
files = sorted(path.glob("*.toml")) if path.is_dir() else [path]
for file in files:
_TESTCASES_TO_SKIP.extend(
_parse(file.read_text(encoding="utf-8"), str(file))
)

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.

It seems toml is native python and doesn't require extra package, correct?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's native since Python 3.11.

"fsdp_deferred_gradient_reduction",
"fsdp+varlen_attn+per_op_sac",
"deepseek_v3_fused_mla_swiglu_fsdp+ep",
"deepseek_v4_fsdp+tp+ep", # Sparse attention / indexer kernels are CUDA-only and unvalidated on ROCm.

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.

Initially I thought we don't need .toml, and maybe .txt would be enough. But here it seems to have the advantage of supporting comments easily.

Given you've simplified things, I think it's fine to have all the skips for all hardware in one file, per claude suggestion -- need a more general name though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

They're consolidated into one file now. I've named it skipped_tests.toml, so the file path is hardware_skips/skipped_tests.toml.

"""Leverage the Python plugin mechanism to load out-of-tree hardware skips."""
from importlib.metadata import entry_points

group_name = "torchtitan.hardware_skips"

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.

at least involve "test" in the name? e.g. torchtitan.tests.integration_tests.hardware_skips to be faithful to the path

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've renamed group_name to torchtitan.integration_tests.hardware_skips.

@meta-cla

meta-cla Bot commented Nov 17, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 17, 2026
@tianyu-l

Copy link
Copy Markdown
Contributor

@claude review again

@claude

claude Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @tianyu-l's task in 1m 56s —— View job


Approve, please address the items below before merging: review. 1d84b98 addresses the latest comments. Still open: the unit tests check private loader state, not that the shipped skip names exist in the real suites (@tianyu-l to decide), plus two small cleanups.

@claude claude Bot 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.

Verdict: Approve -- please address the items below before merging. 1d84b98 addresses @tianyu-l's latest comments and two of my three earlier items. What remains is local cleanup plus one test question that a maintainer should decide. A maintainer still needs to review, and @tianyu-l's 11-12 change request is still in place.

What changed since the last review. One commit, 1d84b98:

  • The per-backend files are merged into one skipped_tests.toml per runner, with one top-level key per backend.
  • The getter is renamed to get_tests_to_skip_on_current_hardware.
  • The entry-point group is now torchtitan.integration_tests.hardware_skips.
  • register_hardware_skips takes a single file again.
  • The run_tests.py docstring and the graph_trainer block comment now match main.

Example.

# tests/integration_tests/hardware_skips/skipped_tests.toml
rocm = ["sdc_replay_accelerator_graph", ..., "qwen3_fsdp+deepep"]  # 24 names
# a future backend adds a key to the same file:
# xpu = ["dist_gemm"]

On ROCm, every runner drops these names, plus anything its own file registers, and logs Skipping test <suite>/<name> (hardware-specific skip). I checked the 24 core names against the removed skip_rocm_test=True entries: all 24 exist, and they are the same set.

Earlier must-fix items

  • Resolved: the empty cuda.toml/xpu.toml placeholders are gone.
  • Resolved differently: the "key must equal the file stem" check. It no longer applies, because @tianyu-l asked for a single file with several keys. The leftover risk is in Details.
  • Still open: tests/unit_tests/cpu/test_hardware_skips.py. See must-fix 1.

Must fix

  1. tests/unit_tests/cpu/test_hardware_skips.py: still unaddressed. The author's reply is that the test should stay self-contained. But the regression that can happen silently is a shipped name going stale after a rename, and only a test that reads the shipped files can catch it. These 164 lines patch private state instead (_TESTCASES_TO_SKIP, _loaded, HARDWARE_SKIPS_DIR, and the private _filter_tests from another module). @tianyu-l, please decide. My recommendation: replace the file with one test in test_integration_test_definitions.py. It would parse both shipped TOMLs and assert that every name is in the test_names of the suite builders (core build_*_tests_list, graph_trainer _TEST_SUITES_FUNCTION). About 15 lines.

Should consider

  • hardware_skips/__init__.py:31-63: a dict keyed by backend can replace the HardwareSkipTestCases dataclass and the list (inline).
  • graph_trainer/tests/integration_tests.py:346,384,633: "Also skipped on ROCm" is on 3 of the 7 skipped tests and repeats the comment at line 336 (inline).
Details

A misspelled backend key (rocn = [...], ROCm = [...]) still skips nothing and raises no error: it falls through to utils.device_type == key. Allowlisting the in-tree keys doesn't work cleanly, because out-of-tree files use their own device_type. A shipped-names test like the one in must-fix 1 could also assert that the in-tree keys are in {"cuda", "rocm", "xpu"}. That check is optional.

The entry-point group is torchtitan.integration_tests.hardware_skips. @tianyu-l had suggested torchtitan.tests.integration_tests.hardware_skips, to match the path. Either name includes "test", which was the request.

Not verified: the CUDA/ROCm runnable and filtered counts (these need GPU runs).

Comment on lines +31 to +63
HARDWARE_SKIPS_DIR = Path(__file__).parent


@dataclass(frozen=True)
class HardwareSkipTestCases:
"""The test cases skipped on one hardware backend."""

skip_hardware: str
tests: frozenset[str]


def _parse(text: str, source: str) -> list[HardwareSkipTestCases]:
raw = tomllib.loads(text)
testcases: list[HardwareSkipTestCases] = []
for skip_hardware, tests in raw.items():
if not isinstance(tests, list) or not all(
isinstance(test, str) for test in tests
):
raise ValueError(f"{source}: {skip_hardware} must be an array of strings")
testcases.append(HardwareSkipTestCases(skip_hardware, frozenset(tests)))
return testcases


_TESTCASES_TO_SKIP: list[HardwareSkipTestCases] = []


def register_hardware_skips(source: str | Path) -> None:
"""Register a hardware-skip file.

Registration must happen before the runner starts filtering tests.
"""
path = Path(source)
_TESTCASES_TO_SKIP.extend(_parse(path.read_text(encoding="utf-8"), str(path)))

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.

Now that there is one file with one list per backend, HardwareSkipTestCases is a list of (backend, names) pairs that get_tests_to_skip_on_current_hardware merges again on every call. A dict keyed by backend holds the same thing, and it removes the public dataclass and the from __future__ import. HARDWARE_SKIPS_DIR is also only used to build one path now:

_SKIPPED_TESTS_FILE = Path(__file__).with_name("skipped_tests.toml")
_TESTS_TO_SKIP: dict[str, set[str]] = defaultdict(set)


def register_hardware_skips(source: str | Path) -> None:
    """Register a hardware-skip file. Must run before the runner filters tests."""
    path = Path(source)
    for hardware, tests in tomllib.loads(path.read_text(encoding="utf-8")).items():
        if not isinstance(tests, list) or not all(isinstance(t, str) for t in tests):
            raise ValueError(f"{path}: {hardware} must be an array of strings")
        _TESTS_TO_SKIP[hardware].update(tests)

and get_tests_to_skip_on_current_hardware becomes a union over the keys where _should_skip_current_hardware(hardware) is true. That is about 15 fewer lines, and it is the "minimal and simpler" shape @tianyu-l asked for.

test_name="aot_fx_trace_llama3_fsdp_tp_cp",
ngpu=8,
skip_rocm_test=True,
# Also skipped on ROCm; see hardware_skips/skipped_tests.toml.

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.

This note appears on 3 of the 7 skipped tests (here, line 384, and line 633), only on the ones that are also disabled. The other four don't have it, and the block comment at line 336 already says where the ROCm skips live. The note is incomplete and partly repeats that comment. Please delete all three; the TOML is the single place that records the skip.

@tianyu-l

Copy link
Copy Markdown
Contributor

@lixing-he please rebase so that I can trigger CI.

Also please see what's worth fixing from claude's comment; no blocker from me.

@lixing-he
lixing-he force-pushed the test/integration-skip-logic-yaml branch from 1d84b98 to ebb05c9 Compare November 17, 2026 10:38
@lixing-he

Copy link
Copy Markdown
Contributor Author

@lixing-he please rebase so that I can trigger CI.

Also please see what's worth fixing from claude's comment; no blocker from me.

Rebased onto the latest main, and applied claude's suggestions of comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/fake-pg Run 1-GPU Fake PG integration tests CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants