Skip to content

Skip the PyTorch Geometric plugin tests without torch_geometric - #3023

Merged
kevalmorabia97 merged 1 commit into
NVIDIA:mainfrom
ConnorBaker:skip-geometric-tests-without-torch-geometric
Oct 26, 2026
Merged

kevalmorabia97 merged 1 commit into
NVIDIA:mainfrom
ConnorBaker:skip-geometric-tests-without-torch-geometric

Conversation

@ConnorBaker

@ConnorBaker ConnorBaker commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Type of change: Bug fix

The PyTorch Geometric quantization plugin is optional: modelopt/torch/quantization/plugins/__init__.py loads it under import_plugin("torch_geometric"). But tests/unit/torch/quantization/plugins/test_pytorch_geometric_plugin.py imports torch_geometric unconditionally, so in an environment without it, pytest stops at collection and runs nothing else:

E   ModuleNotFoundError: No module named 'torch_geometric'
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

The other tests in that directory that need an optional package (accelerate, diffusers, peft, transformers) skip when it's missing. This skips these the same way, with pytest.importorskip("torch_geometric").

torch-geometric is in the dev-test extra, so CI, which installs it, isn't affected. This is for environments without it, such as a distribution's package build.

Usage

N/A

Testing

The file together with tests/unit/torch/test_import.py, on main at efda42c:

  • Without torch_geometric, main: Interrupted: 1 error during collection, nothing runs. With this PR: 1 passed, 1 skipped.
  • With torch_geometric 2.8.1 installed, with this PR: the three geometric tests run and pass.
  • pre-commit run with this repository's configuration (ruff 0.15.20, mypy 2.1.0) passes on the changed file.

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
  • Did you update Changelog?: N/A
  • Did you get Claude approval on this PR?: N/A

Additional Information

Found while packaging 0.47.0 for Nixpkgs (NixOS/nixpkgs#577198). The file is the same in 0.47.0 and release/0.48.0.

AI disclosure: this change, the testing described above and this description were produced with Claude Code (Claude Opus 5.5).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Tests for PyTorch Geometric now skip when the optional package is unavailable.

The PyTorch Geometric quantization plugin is optional: it registers
only when torch_geometric imports. Its tests import torch_geometric
unconditionally, so without it pytest stops collecting:

    ModuleNotFoundError: No module named 'torch_geometric'

The other tests in tests/unit/torch/quantization/plugins that need an
optional package (accelerate, diffusers, peft, transformers) skip when
it's missing. Skip these the same way.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Connor Baker <[email protected]>
@ConnorBaker
ConnorBaker requested a review from a team as a code owner October 26, 2026 17:08
@copy-pr-bot

copy-pr-bot Bot commented Oct 26, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between efda42c and 9e07937.

Files selected for processing: 1
  • tests/unit/torch/quantization/plugins/test_pytorch_geometric_plugin.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review.

Walkthrough

The PyTorch Geometric test module now skips during import when torch_geometric is unavailable. When the dependency is available, the module continues to import its layers.

Changes: PyTorch Geometric test dependency guard

Layer / File(s) Summary
Skip tests when PyG is unavailable
tests/unit/torch/quantization/plugins/test_pytorch_geometric_plugin.py
The module calls pytest.importorskip("torch_geometric") before importing PyG layers.

Priority: Low

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Bug fix

Suggested reviewers: kevalmorabia97

Merge Risk: Minimal · up to 9e079

The optional PyTorch Geometric tests now skip cleanly when the dependency is unavailable.

Pre-merge checks: Passed 6
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: skipping PyTorch Geometric plugin tests when the optional torch_geometric dependency is unavailable.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
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 PASS. The pull request changes only tests/unit/torch/quantization/plugins/test_pytorch_geometric_plugin.py. It adds pytest.importorskip("torch_geometric") before the PyTorch Geometric imports. It …
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files.

Full details: Security Anti-Patterns

Explanation

PASS. The pull request changes only tests/unit/torch/quantization/plugins/test_pytorch_geometric_plugin.py. It adds pytest.importorskip("torch_geometric") before the PyTorch Geometric imports. It does not change modelopt or examples Python code, add security-sensitive calls, add # nosec, or modify dependency files.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@kevalmorabia97

Copy link
Copy Markdown
Collaborator

Please fix the code quality issues and merge the PR

@kevalmorabia97
kevalmorabia97 enabled auto-merge (squash) October 26, 2026 17:13
@codecov

codecov Bot commented Oct 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.50%. Comparing base (a382b8e) to head (9e07937).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3023   +/-   ##
=======================================
  Coverage   77.49%   77.50%           
=======================================
  Files         661      661           
  Lines       74949    74949           
=======================================
+ Hits        58085    58086    +1     
+ Misses      16864    16863    -1     
Flag Coverage Δ
unit 61.15% <ø> (+<0.01%) ⬆️

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.

@ConnorBaker

Copy link
Copy Markdown
Contributor Author

Thanks for the review! The code-quality failure isn't from this change: the pre-commit step's npm install got a 404 for @typescript-eslint/[email protected], which npm published at 17:08:21Z, a few minutes before the job ran (17:11Z). The tarball resolves now, so a re-run of code-quality should pass.

I don't have write access to this repository, so I can't re-run the job or merge the PR myself. Could a maintainer re-run it and merge?

AI disclosure: this comment was drafted with Claude Code (Claude Opus 5.5).

@kevalmorabia97

Copy link
Copy Markdown
Collaborator

/ok to test 9e07937

@kevalmorabia97
kevalmorabia97 merged commit 1d9ec87 into NVIDIA:main Oct 26, 2026
46 of 47 checks passed
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