Fix [Spark unit test CI]: defer torch._dynamo.disable to avoid import-time crash in CI#3290
Conversation
… in CI The @torch._dynamo.disable decorator on current_cuda_stream() triggered torch._dynamo import at module load time, which initializes torch._inductor's cache directory via getpass.getuser(). This fails in CI containers running with -u $(id -u):$(id -g) when the UID has no /etc/passwd entry (KeyError: 'getpwuid(): uid not found: 996'). Use a self-replacing lazy wrapper so torch._dynamo.disable is applied on first call rather than at import time. Co-authored-by: Cursor <cursoragent@cursor.com>
📝 WalkthroughWalkthroughOptimizes module initialization by deferring ChangesLazy torch._dynamo Initialization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
/bot run |
There was a problem hiding this comment.
Code Review
This pull request refactors the current_cuda_stream function in flashinfer/cute_dsl/utils.py to implement a lazy wrapper for the torch._dynamo.disable decorator. This change prevents torch._dynamo from being imported at module load time, which addresses potential failures in container environments running with unmapped UIDs. I have no feedback to provide as no review comments were submitted.
nv-yunzheq
left a comment
There was a problem hiding this comment.
Approve, please merge it after CI comes clean
📌 Description
🔍 Related Issues
🚀 Pull Request Checklist
Thank you for contributing to FlashInfer! Before we review your pull request, please make sure the following items are complete.
✅ Pre-commit Checks
pre-commitby runningpip install pre-commit(or used your preferred method).pre-commit install.pre-commit run --all-filesand fixed any reported issues.🧪 Tests
unittest, etc.).Reviewer Notes
Summary by CodeRabbit