Repository navigation
[0.48.0] Narrow bare except around optional deepspeed import - #3090
Conversation
A bare except also swallowed SystemExit and KeyboardInterrupt (SonarQube python:S5754). main no longer imports deepspeed here (#2727); this is the minimal equivalent for release/0.48.0. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Keval Morabia <[email protected]>
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
DeepSpeed import handling modelopt/torch/utils/network.py |
The import handler catches Exception instead of using a bare except. The fallback assignment to DeepSpeedEngine is unchanged. |
Priority:
Estimated code review effort: 1 (Trivial) | ~2 minutes
Change: Bug fix
Suggested reviewers: realasma
Merge Risk: 
Minimal · up to 377cd
-
No concrete merge-blocking risk was identified in this focused import-handling change.
Pre-merge checks: 
6
-
Full details: Docstring Coverage
-
Explanation
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files.
Full details: Security Anti-Patterns
-
Explanation
PASS. The pull request changes only
modelopt/torch/utils/network.py, replacingexcept: # noqa: E722withexcept Exceptionand an explanatory comment. It adds notorch.load(..., weights_only=False),numpy.load(..., allow_pickle=True), hardcodedtrust_remote_code=True,eval,exec,# nosec, or dependency changes. No listed security anti-pattern is introduced.
-
Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- 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.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release/0.48.0 #3090 +/- ##
==================================================
+ Coverage 72.18% 78.67% +6.49%
==================================================
Files 649 647 -2
Lines 72638 72578 -60
==================================================
+ Hits 52431 57099 +4668
+ Misses 20207 15479 -4728
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
meenchen
left a comment
There was a problem hiding this comment.
Bot review (gpt-6.1-sol) — DM the bot to share feedback.
Nudge: the supplied change looks correct, but targeted regression coverage is absent and the requested pinned revisions could not be verified.
Needs action:
- Add parameterized import regression tests in
tests/unit/torch/utils/test_network.py: preserve fallback forImportError/RuntimeError, propagateSystemExit/KeyboardInterrupt, and retain wrapper registration on success. - Confirm the surrounding source and tests against the requested base/head SHAs using SHA-aware retrieval; the available branch-file tools return no commit metadata.
- Correct the generated PR summary: ordinary import errors already fell back; this change stops swallowing process-control exceptions.
What does this PR do?
Type of change: Bug fix (release branch only)
modelopt/torch/utils/network.pywrapped the optionaldeepspeedimport in a bareexcept:, which also swallowedSystemExitandKeyboardInterruptduringimport modelopt(SonarQubepython:S5754onrelease/0.48.0). It now catchesException.ImportErroralone is not enough: deepspeed can fail at import with other errors (e.g. CUDA/op-builder checks), and those should keep falling back to "no deepspeed" rather than breakimport modelopt.mainno longer has this code: #2727 replaced the import with asys.moduleslookup as part of a larger CI speed-up PR, so this is a minimal release-only equivalent instead of a cherry-pick.Testing
tests/unit/torch/utils/test_network.py: 50 passed.import modelopt.torch.utils.networkwith deepspeed installed still registersDeepSpeedEngine.🤖 Generated with Claude Code
Summary by CodeRabbit