Skip to content

Fix 2-GPU test_model_load_utils hang; test import and fixture cleanup - #2079

Merged
kevalmorabia97 merged 7 commits into
mainfrom
kmorabia/test-fix-and-opt
Aug 5, 2026
Merged

Fix 2-GPU test_model_load_utils hang; test import and fixture cleanup#2079
kevalmorabia97 merged 7 commits into
mainfrom
kmorabia/test-fix-and-opt

Conversation

@kevalmorabia97

@kevalmorabia97 kevalmorabia97 commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

Type of change: Bug fix + new tests (test-suite only; changes are confined to tests/)

  • Fix test_parallel_load_and_export hang on 2 GPUs. The temp paths were built from os.getpid() inside the workers, so each rank got a different ckpt_dir; rank 1 then took _resolve_checkpoint_dir's Hub branch and blocked on an extra barrier while rank 0 ran the loader's broadcasts. The checkpoint is now built once in the parent under tmp_path and passed in, so all ranks agree on the path.
  • Imports moved to module top across tests/gpu* and tests/examples; function-local imports kept only where guarded (importorskip/try), where the import is the test (JIT compile), or where it must follow sys.path setup.
  • Reuse _test_utils instead of local copies: added get_tiny_mixtral; deduped assert_nodes_are_quantized (5 copies), the accelerate-offload/layerwise config helpers, make_quant_attention, get_dflash_config, the NVFP4 amax assertions, and 3 copies of the tiny_wan22_path fixture.
  • Shared model-dir fixtures assert they were not modified (assert_unmodified_tree): a file manifest is compared on teardown, so a test that writes into a session-scoped fixture directory fails instead of silently changing what later tests see.
  • Dropped dependency guards the CI env already guarantees (diffusers, tensorrt_llm in gpu_trtllm, transformer_engine in gpu_megatron, transformers in examples) so a missing dep fails loudly instead of skipping.
  • test_heterogenous_sharded_state_dict is skipped on Blackwell (sm_120), matching the existing marker and its TE/CUDA-13 rationale — same tracking issue as CI: CUDA build/test hygiene + fix Puzzletron Nemotron test failures #1901.

Testing

Local, 2x RTX 6000 Ada: tests/gpu/torch/utils/test_model_load_utils.py passes on 2 GPUs and on 1 GPU (previously hung on 2). Also ran the touched files in tests/unit (608 passed) and tests/gpu (~340 passed).

Before your PR is "Ready for review"

  • Is this change backward compatible?: ✅
  • If you copied code from any other sources or added a new PIP dependency, did you follow guidance in CONTRIBUTING.md: N/A
  • Did you write any new necessary tests?: N/A — test-only PR
  • Did you update Changelog?: N/A
  • Did you get Claude approval on this PR?: ❌ — not yet run

Summary by CodeRabbit

  • Tests
    • Added reusable validation utilities for generated files, quantization behavior, attention modules, model fixtures, offloading, and speculative decoding.
    • Expanded coverage for tiny Wan, Mixtral, Llama, and related model scenarios.
    • Consolidated duplicated setup and assertions across ONNX, GPU, quantization, export, and sparsity tests.
    • Improved fixture integrity checks, NVFP4 validation, and handling of identity inputs.
    • Reduced unnecessary dependency-based skips and isolated known platform-specific flakiness.

Signed-off-by: Keval Morabia <28916987+kevalmorabia97@users.noreply.github.com>
Signed-off-by: Keval Morabia <28916987+kevalmorabia97@users.noreply.github.com>
@kevalmorabia97
kevalmorabia97 requested review from a team as code owners August 5, 2026 11:02
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 0be5ca06-3677-4ff7-84fd-157ca5333c71

📥 Commits

Reviewing files that changed from the base of the PR and between 3022924 and 687f66c.

📒 Files selected for processing (3)
  • tests/_test_utils/fs_utils.py
  • tests/_test_utils/torch/transformers_models.py
  • tests/unit/torch/opt/plugins/test_hf_patching.py
💤 Files with no reviewable changes (2)
  • tests/_test_utils/torch/transformers_models.py
  • tests/_test_utils/fs_utils.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/unit/torch/opt/plugins/test_hf_patching.py

📝 Walkthrough

Walkthrough

The PR centralizes filesystem, model, quantization, offload, and DFlash test utilities. Fixtures and tests use these helpers, share model builders, validate generated directories, and standardize import and dependency handling.

Changes

Test infrastructure and validation

Layer / File(s) Summary
Shared model and quantization utilities
tests/_test_utils/...
Adds filesystem manifests, ONNX assertions, quantized attention and offload factories, NVFP4 checks, DFlash configuration, and a tiny Mixtral builder.
Read-only fixture lifecycle
tests/conftest.py, tests/examples/..., tests/gpu/torch/kernels/conftest.py, tests/gpu_megatron/conftest.py
Validates generated model and tokenizer directories with assert_unmodified_tree and shares the Wan 2.2 fixture.
Shared model and offload adoption
tests/gpu/torch/export/..., tests/gpu/torch/quantization/..., tests/gpu/torch/utils/..., tests/unit/torch/export/...
Replaces duplicated model, attention, offload, checkpoint, Mixtral, and NVFP4 setup with shared helpers.
Shared ONNX quantization assertions
tests/gpu/onnx/..., tests/unit/onnx/...
Uses the shared assert_nodes_are_quantized helper and ignores Identity-produced inputs where configured.
Shared DFlash configuration adoption
tests/gpu/torch/speculative/..., tests/unit/torch/speculative/...
Replaces local DFlash configuration builders with get_dflash_config across conversion, masking, save/restore, and export tests.
Test import and execution cleanup
tests/examples/..., tests/gpu_megatron/..., tests/gpu_trtllm/..., tests/gpu/torch/..., tests/unit/torch/opt/...
Moves imports to module scope, removes selected availability skips, and adds a Blackwell-specific flaky-test skip.

Estimated code review effort: 4 (Complex) | ~45 minutes

🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 64.12% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the primary fix for the 2-GPU test hang and accurately summarizes the related test cleanup.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Security Anti-Patterns ✅ Passed PR adds test-only code with no security anti-patterns. All new test utilities avoid dangerous deserialization, have properly-configurable trust_remote_code (default False), and contain no eval/exec...
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch kmorabia/test-fix-and-opt

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.00%. Comparing base (2d4be28) to head (687f66c).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2079       +/-   ##
===========================================
+ Coverage   67.17%   78.00%   +10.83%     
===========================================
  Files         521      521               
  Lines       59857    59857               
===========================================
+ Hits        40206    46693     +6487     
+ Misses      19651    13164     -6487     
Flag Coverage Δ
examples 43.04% <ø> (-0.21%) ⬇️
gpu 58.57% <ø> (+37.41%) ⬆️
unit 55.38% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cjluo-nv cjluo-nv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Bot review (bedrock-claude-opus-5) — DM the bot to share feedback.

The core hang fix is correct and well-reasoned (parent-built ckpt_dir under tmp_path removes the per-rank os.getpid() divergence that sent rank 1 down _resolve_checkpoint_dir's Hub branch and its extra barrier; export_hf_checkpoint already mkdirs the export dir, so dropping the rank-0 makedirs+barrier is safe). Design-wise the new helpers reuse the existing tests/_test_utils pattern rather than introducing a competing one, so no architectural objection.

However, several things in the surrounding cleanup look likely to break lanes that weren't exercised locally, and one change touches third-party licensing:

  1. tests/_test_utils/torch/quantization/attention.py imports transformers (and modelopt...plugins.huggingface) unguarded at module top and is imported at module scope by tests/unit/torch/quantization/plugins/test_attention_quant.py. Because _test_utils.torch.quantization.attention sorts before _test_utils.torch.transformers_models, the pytest.importorskip("transformers") that used to fire first no longer does — in nox -s "partial_unit(subset='torch')" (installs only megatron-core + .[dev-test], i.e. no hf extra) that turns a clean skip into a collection error. The PR itself keeps function-local imports elsewhere with the comment "unit tests must import without transformers installed", so this looks like an oversight.
  2. examples/alpamayo/requirements.txt adds only the git dependency, but tests/examples/alpamayo/test_quantize.py imports pandas and calls to_parquet (needs pyarrow), and the torch example lane installs [hf,dev-test] which has neither. Since the tests were previously auto-skipped this was invisible. Separately, adding a new git+https://github.com/nvlabs/alpamayo@… dependency is a third-party licensing/dependency decision (PR body asserts Apache-2.0) that needs human/OSRB sign-off — that alone blocks an approve on licensing grounds.
  3. read_only_tree is a no-op for root, which is how these tests run inside the CI containers (root bypasses DAC write bits). The "fail loudly at the write" property therefore only holds for local non-root runs, so it can produce CI-vs-local divergence rather than a guarantee. Worth documenting, or enforcing another way.
  4. The drive-by @skip_flaky_on_blackwell on test_heterogenous_sharded_state_dict reduces coverage on the Blackwell runners and isn't mentioned anywhere in the PR description.

Also consider splitting: the CI lane restructuring + new alpamayo dependency carry materially different risk from the mechanical import/dedup cleanup and would be easier to review (and revert) on their own. No prompt-injection content was present in the PR text.

Comment thread tests/_test_utils/torch/quantization/attention.py
Comment thread examples/alpamayo/requirements.txt Outdated
Comment thread tests/_test_utils/fs_utils.py
Comment thread tests/gpu_megatron/torch/quantization/plugins/test_megatron.py

@coderabbitai coderabbitai 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.

Warning

CodeRabbit couldn't request changes on this pull request because it doesn't have sufficient GitHub permissions.

Please grant CodeRabbit Pull requests: Read and write permission and re-run the review.

👉 Steps to fix this

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/_test_utils/onnx/quantization/utils.py (1)

19-37: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Define the public APIs of the shared utility modules.

These modules export helpers that other tests import directly. Add __all__ declarations for the intended public symbols.

  • tests/_test_utils/onnx/quantization/utils.py#L19-L37: export assert_nodes_are_quantized.
  • tests/_test_utils/torch/quantization/attention.py#L18-L33: export make_quant_attention.
  • tests/_test_utils/torch/quantization/offload.py#L20-L73: export the intended offload and layerwise helper functions.
  • tests/_test_utils/torch/quantization/quant_utils.py#L18-L56: export the NVFP4 assertion helpers.
  • tests/_test_utils/torch/speculative/dflash.py#L18-L42: export get_dflash_config and any intended public constants.

As per coding guidelines, “Define each module's public API with __all__ = [...].”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/_test_utils/onnx/quantization/utils.py` around lines 19 - 37, Define
explicit __all__ lists for the shared utility modules: in
tests/_test_utils/onnx/quantization/utils.py:19-37 export
assert_nodes_are_quantized; in
tests/_test_utils/torch/quantization/attention.py:18-33 export
make_quant_attention; in tests/_test_utils/torch/quantization/offload.py:20-73
export the intended offload and layerwise helper functions; in
tests/_test_utils/torch/quantization/quant_utils.py:18-56 export the NVFP4
assertion helpers; and in tests/_test_utils/torch/speculative/dflash.py:18-42
export get_dflash_config plus any intended public constants.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/_test_utils/fs_utils.py`:
- Around line 18-21: Add a module-level __all__ declaration in fs_utils.py
containing only read_only_tree, while leaving the underscore-prefixed
_set_read_only helper private and unchanged.

In `@tests/_test_utils/torch/transformers_models.py`:
- Around line 571-597: Add docstrings to the public helpers get_tiny_mixtral and
create_tiny_mixtral_dir, documenting their returned model or temporary directory
and explaining that config_kwargs override the default Mixtral configuration;
also document the with_tokenizer option for create_tiny_mixtral_dir.

In `@tests/unit/onnx/quantization/test_qdq_rules_int8.py`:
- Line 71: Update the quantization assertion around assert_nodes_are_quantized
to remove the unrestricted ignore_identity_inputs=True bypass; use the default
validation, or only permit identity inputs after verifying each is ultimately
produced by DequantizeLinear. Keep concat-elimination handling scoped to
build_conv_concat_model.

In `@tests/unit/torch/export/test_quant_aware_conversion.py`:
- Line 359: Add a brief explanatory comment immediately above the local
get_tiny_mixtral import, stating that it remains local because the helper
requires the optional Transformers dependency; do not substitute a
pytest.importorskip() comment.

---

Outside diff comments:
In `@tests/_test_utils/onnx/quantization/utils.py`:
- Around line 19-37: Define explicit __all__ lists for the shared utility
modules: in tests/_test_utils/onnx/quantization/utils.py:19-37 export
assert_nodes_are_quantized; in
tests/_test_utils/torch/quantization/attention.py:18-33 export
make_quant_attention; in tests/_test_utils/torch/quantization/offload.py:20-73
export the intended offload and layerwise helper functions; in
tests/_test_utils/torch/quantization/quant_utils.py:18-56 export the NVFP4
assertion helpers; and in tests/_test_utils/torch/speculative/dflash.py:18-42
export get_dflash_config plus any intended public constants.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: e701fd98-c966-44a4-8638-dd127119f6eb

📥 Commits

Reviewing files that changed from the base of the PR and between 7afbfbc and b79cee8.

📒 Files selected for processing (46)
  • .github/workflows/example_tests.yml
  • examples/alpamayo/requirements.txt
  • tests/_test_utils/fs_utils.py
  • tests/_test_utils/onnx/quantization/utils.py
  • tests/_test_utils/torch/quantization/attention.py
  • tests/_test_utils/torch/quantization/offload.py
  • tests/_test_utils/torch/quantization/quant_utils.py
  • tests/_test_utils/torch/speculative/dflash.py
  • tests/_test_utils/torch/transformers_models.py
  • tests/conftest.py
  • tests/examples/alpamayo/test_quantize.py
  • tests/examples/conftest.py
  • tests/examples/diffusers/conftest.py
  • tests/examples/diffusers/sparsity/test_sparsity.py
  • tests/examples/diffusers/test_export_diffusers_hf_ckpt.py
  • tests/examples/gpt-oss/test_gpt_oss_qat.py
  • tests/examples/specdec_bench/test_redaction.py
  • tests/examples/speculative_decoding/conftest.py
  • tests/gpu/onnx/quantization/test_concat_elim.py
  • tests/gpu/onnx/quantization/test_quantize_fp8.py
  • tests/gpu/torch/export/test_quant_aware_conversion_gpu.py
  • tests/gpu/torch/export/test_quant_utils.py
  • tests/gpu/torch/export/test_vllm_fakequant_hf_export.py
  • tests/gpu/torch/kernels/conftest.py
  • tests/gpu/torch/kernels/sparsity/attention/test_diffusers_triton_attention.py
  • tests/gpu/torch/quantization/plugins/test_accelerate_gpu.py
  • tests/gpu/torch/quantization/plugins/test_attention_quant.py
  • tests/gpu/torch/quantization/test_fsdp2.py
  • tests/gpu/torch/quantization/test_lsq_cuda.py
  • tests/gpu/torch/quantization/test_nvfp4_fp8_sweep_kernel.py
  • tests/gpu/torch/sparsity/attention_sparsity/test_wan22_skip_softmax.py
  • tests/gpu/torch/speculative/plugins/test_hf_dflash.py
  • tests/gpu/torch/utils/test_model_load_utils.py
  • tests/gpu_megatron/conftest.py
  • tests/gpu_megatron/torch/export/test_unified_export_megatron.py
  • tests/gpu_megatron/torch/quantization/plugins/test_megatron.py
  • tests/gpu_megatron/torch/quantization/plugins/test_transformer_engine.py
  • tests/gpu_trtllm/torch/export/test_export_compressed_nvfp4.py
  • tests/gpu_trtllm/torch/quantization/backends/test_nvfp4_gemm.py
  • tests/unit/onnx/quantization/test_qdq_rules_int8.py
  • tests/unit/onnx/quantization/test_quantize_int8.py
  • tests/unit/onnx/test_autocast_quantize.py
  • tests/unit/torch/export/test_quant_aware_conversion.py
  • tests/unit/torch/quantization/plugins/test_attention_quant.py
  • tests/unit/torch/speculative/plugins/test_hf_dflash.py
  • tests/unit/torch/speculative/plugins/test_hf_dflash_offline.py
💤 Files with no reviewable changes (4)
  • tests/examples/gpt-oss/test_gpt_oss_qat.py
  • tests/examples/specdec_bench/test_redaction.py
  • tests/gpu_trtllm/torch/export/test_export_compressed_nvfp4.py
  • tests/gpu/torch/kernels/sparsity/attention/test_diffusers_triton_attention.py

Comment thread tests/_test_utils/fs_utils.py Outdated
Comment thread tests/_test_utils/torch/transformers_models.py Outdated
Comment thread tests/unit/onnx/quantization/test_qdq_rules_int8.py
Comment thread tests/unit/torch/export/test_quant_aware_conversion.py
Signed-off-by: Keval Morabia <28916987+kevalmorabia97@users.noreply.github.com>
…dified

- _test_utils/torch/quantization/attention.py: importorskip transformers at import
  time; isort orders it before transformers_models, so its guard no longer ran
  first and the partial-install unit lane hit a collection error.
- fs_utils: replace the chmod-based read_only_tree with assert_unmodified_tree,
  a file-manifest comparison on teardown. chmod is a no-op under root, which is
  how the CI containers run, so it never checked anything there.
- test_quant_aware_conversion.py: note why the import stays function-local.

Signed-off-by: Keval Morabia <28916987+kevalmorabia97@users.noreply.github.com>
@kevalmorabia97
kevalmorabia97 force-pushed the kmorabia/test-fix-and-opt branch from b79cee8 to 2ed5db0 Compare August 5, 2026 12:30
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@kevalmorabia97 kevalmorabia97 changed the title Fix 2-GPU test_model_load_utils hang; test import/fixture cleanup and CI lane fixes Fix 2-GPU test_model_load_utils hang; test import and fixture cleanup Aug 5, 2026
@kevalmorabia97

Copy link
Copy Markdown
Collaborator Author

Update — force-pushed 2ed5db0

Scope narrowed: this PR is now tests/-only. The CI workflow changes (single merged TRT-LLM lane, gpt-oss moved to the TRT-LLM image) are out and will come as a separate PR, along with the tests/examples/gpt-oss guard removal that only makes sense once that lane moves. The alpamayo lane is dropped: alpamayo_r1 requires flash-attn>=2.8.3, which has no PyPI wheels, so pip builds it from source and the build backend can't see torch under build isolation — that needs --no-build-isolation (not expressible in a requirements.txt, which is all the shared example runner consumes) plus a much longer timeout, for three CPU-only helper tests.

Both red jobs fixed:

  • partial-install (torch)_test_utils/torch/quantization/attention.py imported transformers unguarded, and isort sorts it before transformers_models, so the importorskip that used to make test_attention_quant.py skip cleanly no longer ran first. It now guards at the top of the helper itself.
  • torch (alpamayo) — lane removed, per above.

Review feedback:

  • The shared-fixture guard no longer uses chmod. Root has CAP_DAC_OVERRIDE and the CI containers run as root, so the permission bits checked nothing where it mattered. read_only_tree is now assert_unmodified_tree, which compares a file manifest (path -> size + mtime_ns) on teardown and therefore holds under root too.
  • Added the missing __all__ and the local-import rationale comment.
  • Two findings I did not apply, with replies in-thread: the ignore_identity_inputs=True bypass is load-bearing (removing it fails test_resnet_residual_connections and test_resnet_residual_connection_with_downsample — those ResNet builders do feed conv inputs through Identity), and the Mixtral docstrings are skipped for consistency with the 30 other undocumented factories in that file.
  • The Blackwell skip is now called out in the PR description, linked to CI: CUDA build/test hygiene + fix Puzzletron Nemotron test failures #1901.

@coderabbitai coderabbitai 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.

Warning

CodeRabbit couldn't request changes on this pull request because it doesn't have sufficient GitHub permissions.

Please grant CodeRabbit Pull requests: Read and write permission and re-run the review.

👉 Steps to fix this

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/_test_utils/fs_utils.py`:
- Around line 47-50: Update the context manager around the yield in the fixture
helper so the post-yield manifest comparison always runs from a finally block,
including when the with-block raises. Preserve the original test exception when
possible while retaining the existing path existence check and manifest
comparison behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 8961109f-2e08-420c-9681-ce6a1084f8ee

📥 Commits

Reviewing files that changed from the base of the PR and between 7afbfbc and 2ed5db0.

📒 Files selected for processing (41)
  • tests/_test_utils/fs_utils.py
  • tests/_test_utils/onnx/quantization/utils.py
  • tests/_test_utils/torch/quantization/attention.py
  • tests/_test_utils/torch/quantization/offload.py
  • tests/_test_utils/torch/quantization/quant_utils.py
  • tests/_test_utils/torch/speculative/dflash.py
  • tests/_test_utils/torch/transformers_models.py
  • tests/conftest.py
  • tests/examples/conftest.py
  • tests/examples/diffusers/conftest.py
  • tests/examples/diffusers/sparsity/test_sparsity.py
  • tests/examples/diffusers/test_export_diffusers_hf_ckpt.py
  • tests/examples/specdec_bench/test_redaction.py
  • tests/gpu/onnx/quantization/test_concat_elim.py
  • tests/gpu/onnx/quantization/test_quantize_fp8.py
  • tests/gpu/torch/export/test_quant_aware_conversion_gpu.py
  • tests/gpu/torch/export/test_quant_utils.py
  • tests/gpu/torch/export/test_vllm_fakequant_hf_export.py
  • tests/gpu/torch/kernels/conftest.py
  • tests/gpu/torch/kernels/sparsity/attention/test_diffusers_triton_attention.py
  • tests/gpu/torch/quantization/plugins/test_accelerate_gpu.py
  • tests/gpu/torch/quantization/plugins/test_attention_quant.py
  • tests/gpu/torch/quantization/test_fsdp2.py
  • tests/gpu/torch/quantization/test_lsq_cuda.py
  • tests/gpu/torch/quantization/test_nvfp4_fp8_sweep_kernel.py
  • tests/gpu/torch/sparsity/attention_sparsity/test_wan22_skip_softmax.py
  • tests/gpu/torch/speculative/plugins/test_hf_dflash.py
  • tests/gpu/torch/utils/test_model_load_utils.py
  • tests/gpu_megatron/conftest.py
  • tests/gpu_megatron/torch/export/test_unified_export_megatron.py
  • tests/gpu_megatron/torch/quantization/plugins/test_megatron.py
  • tests/gpu_megatron/torch/quantization/plugins/test_transformer_engine.py
  • tests/gpu_trtllm/torch/export/test_export_compressed_nvfp4.py
  • tests/gpu_trtllm/torch/quantization/backends/test_nvfp4_gemm.py
  • tests/unit/onnx/quantization/test_qdq_rules_int8.py
  • tests/unit/onnx/quantization/test_quantize_int8.py
  • tests/unit/onnx/test_autocast_quantize.py
  • tests/unit/torch/export/test_quant_aware_conversion.py
  • tests/unit/torch/quantization/plugins/test_attention_quant.py
  • tests/unit/torch/speculative/plugins/test_hf_dflash.py
  • tests/unit/torch/speculative/plugins/test_hf_dflash_offline.py
💤 Files with no reviewable changes (3)
  • tests/gpu/torch/kernels/sparsity/attention/test_diffusers_triton_attention.py
  • tests/gpu_trtllm/torch/export/test_export_compressed_nvfp4.py
  • tests/examples/specdec_bench/test_redaction.py
🚧 Files skipped from review as they are similar to previous changes (34)
  • tests/gpu_megatron/torch/quantization/plugins/test_megatron.py
  • tests/_test_utils/onnx/quantization/utils.py
  • tests/gpu/onnx/quantization/test_concat_elim.py
  • tests/gpu_trtllm/torch/quantization/backends/test_nvfp4_gemm.py
  • tests/unit/onnx/quantization/test_quantize_int8.py
  • tests/gpu_megatron/torch/quantization/plugins/test_transformer_engine.py
  • tests/_test_utils/torch/quantization/attention.py
  • tests/examples/diffusers/test_export_diffusers_hf_ckpt.py
  • tests/gpu/torch/utils/test_model_load_utils.py
  • tests/_test_utils/torch/quantization/quant_utils.py
  • tests/unit/torch/speculative/plugins/test_hf_dflash_offline.py
  • tests/_test_utils/torch/speculative/dflash.py
  • tests/gpu/onnx/quantization/test_quantize_fp8.py
  • tests/gpu_megatron/conftest.py
  • tests/gpu/torch/kernels/conftest.py
  • tests/gpu/torch/speculative/plugins/test_hf_dflash.py
  • tests/gpu_megatron/torch/export/test_unified_export_megatron.py
  • tests/unit/onnx/quantization/test_qdq_rules_int8.py
  • tests/unit/torch/quantization/plugins/test_attention_quant.py
  • tests/unit/onnx/test_autocast_quantize.py
  • tests/examples/diffusers/sparsity/test_sparsity.py
  • tests/examples/diffusers/conftest.py
  • tests/gpu/torch/export/test_vllm_fakequant_hf_export.py
  • tests/_test_utils/torch/quantization/offload.py
  • tests/gpu/torch/export/test_quant_utils.py
  • tests/conftest.py
  • tests/_test_utils/torch/transformers_models.py
  • tests/gpu/torch/quantization/test_nvfp4_fp8_sweep_kernel.py
  • tests/gpu/torch/quantization/test_lsq_cuda.py
  • tests/gpu/torch/export/test_quant_aware_conversion_gpu.py
  • tests/gpu/torch/quantization/test_fsdp2.py
  • tests/gpu/torch/quantization/plugins/test_accelerate_gpu.py
  • tests/unit/torch/speculative/plugins/test_hf_dflash.py
  • tests/unit/torch/export/test_quant_aware_conversion.py

Comment thread tests/_test_utils/fs_utils.py
@kevalmorabia97
kevalmorabia97 removed the request for review from a team August 5, 2026 12:38

@cjluo-nv cjluo-nv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Bot review (bedrock-claude-opus-5) — DM the bot to share feedback.

Re-review of the now tests/-only PR (41 files, +542/-588). Design protocol applied: the new helpers (fs_utils.py, torch/quantization/{attention,offload}.py, torch/speculative/dflash.py, additions to onnx/quantization/utils.py and torch/quantization/quant_utils.py) extend the existing tests/_test_utils package rather than introducing a competing helper layer, and each one replaces 2–5 verbatim copies, so there is no second system being introduced and no in-repo/dependency alternative that would do this better.

Verification of the previous round's blockers — all resolved:

  • tests/_test_utils/torch/quantization/attention.py now runs pytest.importorskip("transformers") before the transformers / HF-plugin imports, so partial_unit(subset='torch') skips instead of erroring at collection.
  • The alpamayo lane, examples/alpamayo/requirements.txt and all CI-workflow changes are out; no licensing/OSRB surface remains (no LICENSE/header/vendoring changes, new files carry the standard NVIDIA Apache-2.0 header).
  • The root-bypassable chmod guard is gone; read_only_treeassert_unmodified_tree (size+mtime_ns manifest compared on teardown), which works under root.
  • Dropped dependency guards check out against the lanes: gpu installs .[all,dev-test] (diffusers comes via hf), gpu_trtllm/gpu_megatron get tensorrt_llm / transformer_engine from their containers.

Spot-checks of the mechanical parts look right: _MIXTRAL_KWARGS / _LLAMA_KWARGS preserve the old shapes and (where it matters for tolerances) the old fp32 dtype; ignore_identity_inputs defaults to False so the three files whose local helper did not skip Identity keep their stricter assertion, and only the ResNet/concat call sites opt in; removed module-top imports (LlamaConfig, gs, diffusers) are still used or genuinely unused. The core hang fix (parent-built ckpt_dir/export_dir under tmp_path, one path for all ranks) is unchanged and correct.

The pytest process dies with STATUS_ILLEGAL_INSTRUCTION (0xC000001D) partway
through this test on windows-latest, taking the whole unit run with it. Use the
existing skip_on_windows fixture, matching test_quantize_cpu.py::test_save_restore.

Signed-off-by: Keval Morabia <28916987+kevalmorabia97@users.noreply.github.com>
assert_unmodified_tree returned silently if the tree was gone at teardown, which
is the loudest mutation it should report, not the one it should ignore.

Signed-off-by: Keval Morabia <28916987+kevalmorabia97@users.noreply.github.com>
@kevalmorabia97

Copy link
Copy Markdown
Collaborator Author

Update — c7e696e + 3022924

  • Windows crash fixed. tests/unit/torch/opt/plugins/test_hf_patching.py::test_nested_model_save_restore takes the skip_on_windows fixture, matching test_quantize_cpu.py::test_save_restore. The pytest process was dying there with STATUS_ILLEGAL_INSTRUCTION (0xC000001D) and taking the whole unit run with it, which is why the failure looked anonymous — the last line printed was the preceding file's test.
  • assert_unmodified_tree now fails when the fixture root is deleted outright, instead of returning silently. That was the loudest mutation it could see and the one case it ignored.

On the re-review's other two points:

  • Example/megatron lane coverage: covered. The lanes that exercise the guarded fixtures (torch (llm_qat), (llm_distill), (llm_sparsity), (specdec_bench), onnx (diffusers)) all ran green on 2ed5db0, which already had the guard active on tiny_llama_path / tiny_qwen3_path / tiny_gpt_oss_path — so it fired on nothing. @kevalmorabia97 additionally ran examples/megatron_bridge and tests/gpu_megatron locally, both passing.
  • Blackwell skip: signed off by @kevalmorabia97 as repo owner/codeowner.

The finally-on-generator-close suggestion is still not applied, for the reason in that thread: pytest doesn't throw test failures into a fixture's generator, so the comparison already runs after ordinary failures; the only paths it would add are GeneratorExit / KeyboardInterrupt, where the session is already aborting and no later tests remain to protect.

@cjluo-nv cjluo-nv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Bot review (bedrock-claude-opus-5) — DM the bot to share feedback.

Re-review #3 of this tests/-only PR (42 files, +544/-589). Design protocol re-applied: the new helpers (fs_utils.py, torch/quantization/{attention,offload}.py, torch/speculative/dflash.py, additions to onnx/quantization/utils.py and torch/quantization/quant_utils.py) extend the existing tests/_test_utils package rather than introducing a competing layer, and each replaces 2–5 verbatim copies — no second system, no in-repo/dependency alternative that fits better. Core hang fix unchanged and correct (parent-built ckpt_dir/export_dir under tmp_path gives every rank one path, removing the os.getpid() divergence into _resolve_checkpoint_dir's Hub branch and the mismatched barrier).

Verified closed since the last pass:

  • assert_unmodified_tree now raises on a deleted fixture root (3022924); __all__ present, manifest is size+mtime_ns so it works under root in the CI containers.
  • tests/_test_utils/torch/quantization/attention.py runs pytest.importorskip("transformers") before the transformers/HF-plugin imports, and it still sorts ahead of the modelopt...plugins.huggingface import in tests/unit/torch/quantization/plugins/test_attention_quant.py, so the torch-only unit lane skips instead of erroring at collection.
  • Lane coverage for the guarded fixtures and the Blackwell skip are signed off by the owner.
  • Spot-checks hold: _MIXTRAL_KWARGS/_LLAMA_KWARGS preserve the old shapes and the fp32 dtype where tolerances depend on it; ignore_identity_inputs defaults to False so only the ResNet/concat call sites relax; LlamaConfig/LlamaAttention/_QuantAttention are still used by test_kitchen_fa after the local-helper removal; test_wan22_calibrated_export only reads the now-session-scoped tiny_wan22_path and exports into tmp_path.
  • No licensing surface: no LICENSE/NOTICE/vendoring changes; new files carry the project's standard Apache-2.0 NVIDIA header (year reads 2024 vs. the canonical LICENSE_HEADER's 2026 — cosmetic only).

Nudging rather than approving only because of one drive-by that no reviewer has looked at yet (see reason) plus the overall size of the mechanical cleanup.

- Remove create_tiny_mixtral_dir (added for symmetry, never called) and the
  pre-existing unused create_tiny_bert_dir; get_tiny_bert stays, it is used by
  test_attention_quant.py. No create_tiny_*_dir helper is unused now.
- Drop __all__ from fs_utils.py; test utils do not declare it.
- test_hf_patching.py: the comment claimed flakiness, but what we observed is a
  hard STATUS_ILLEGAL_INSTRUCTION crash. Say that instead, and note the root
  cause may be in the KD save/restore path rather than the test.

Signed-off-by: Keval Morabia <28916987+kevalmorabia97@users.noreply.github.com>
@kevalmorabia97

Copy link
Copy Markdown
Collaborator Author

Update — 687f66c

Re-review #3 points:

  • Windows skip. Fair catch that "Flaky on Windows" didn't match a STATUS_ILLEGAL_INSTRUCTION crash. Comment corrected. Deliberately not tracked: Windows is a supported platform for modelopt.onnx only, so a torch KD save/restore crash there is out of scope — confirmed by @kevalmorabia97, who also confirmed masking it is intended.
  • create_tiny_mixtral_dir unused. Correct — removed. Also removed the pre-existing unused create_tiny_bert_dir; get_tiny_bert stays (used by test_attention_quant.py:120). No create_tiny_*_dir helper is unused now.
  • __all__ only on fs_utils.py. Resolved in the other direction: __all__ isn't a convention in tests/_test_utils (3 of ~38 modules, all pre-existing), so it was dropped from fs_utils.py rather than added to the other new modules.

@cjluo-nv cjluo-nv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Bot review (bedrock-claude-opus-5) — DM the bot to share feedback.

Re-review #4 of this tests/-only PR (42 files, +531/-593). Design protocol re-applied: the helpers (fs_utils.py, torch/quantization/{attention,offload}.py, torch/speculative/dflash.py, additions to onnx/quantization/utils.py and torch/quantization/quant_utils.py) extend the existing tests/_test_utils package rather than standing up a competing helper layer, and each replaces 2–5 verbatim copies — no second system, no better in-repo/dependency alternative. Core hang fix unchanged and correct: the checkpoint/export dirs are built once in the parent under tmp_path and passed into the workers, so all ranks agree on the path and rank 1 no longer takes _resolve_checkpoint_dir's Hub branch and its extra barrier.

Verified closed in this pass:

  • Windows skip on test_nested_model_save_restore — owner-signed-off; Windows support is scoped to modelopt.onnx, so masking a torch KD save/restore crash there is intentional and acceptable.
  • __all__ intentionally dropped from the new test-util modules, matching the package convention (only 3 of ~38 pre-existing modules define it); confirmed absent from fs_utils.py.
  • create_tiny_bert_dir and create_tiny_mixtral_dir are gone from transformers_models.py, get_tiny_bert retained (still used by test_attention_quant.py); no dangling references anywhere in the tree.
  • assert_unmodified_tree raises on a deleted fixture root; manifest is size + mtime_ns, so it works under root in the CI containers.
  • tests/_test_utils/torch/quantization/attention.py runs pytest.importorskip("transformers") before the transformers/HF-plugin imports and still sorts ahead of the modelopt...plugins.huggingface import in the unit test, so the torch-only unit lane skips instead of erroring at collection.
  • Spot-checks hold: no now-unused module-top imports (gs still used in the ONNX tests, LlamaConfig/LlamaAttention/_QuantAttention still used by test_kitchen_fa); _MIXTRAL_KWARGS/_LLAMA_KWARGS preserve the old shapes and the fp32 dtype where tolerances depend on it; ignore_identity_inputs defaults to False so only the ResNet/concat call sites relax (load-bearing there, per the author's reproduction).
  • No licensing surface: no LICENSE/NOTICE/vendoring changes; new files carry the project's standard Apache-2.0 NVIDIA header (year reads 2024 vs. the canonical header's later year — cosmetic only).

The remaining size concern is a soft guideline on a cohesive, mechanical test-only cleanup, and the last open drive-by is now explicitly signed off by the codeowner. Approving.

Complex PR: 36 files changed (≥ 20); 1124 lines changed (≥ 1000); spans 27 directories (≥ 5); 36 existing test files modified or removed. Looping in a human for approval.

@kevalmorabia97
kevalmorabia97 merged commit 19e0121 into main Aug 5, 2026
60 checks passed
@kevalmorabia97
kevalmorabia97 deleted the kmorabia/test-fix-and-opt branch August 5, 2026 15:30
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-08-05 15:30 UTC

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants