Fix Customize Optimization tutorial import error #18584#18697
Fix Customize Optimization tutorial import error #18584#18697AshwiniBokka wants to merge 14 commits intoapache:mainfrom
Conversation
- Add prerequisite note about building TVM with CUDA support - Add error handling for 'tvm_ffi' import failure - Print helpful error messages to stderr - Provide link to build instructions Fixes apache#18584
Summary of ChangesHello @AshwiniBokka, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a common Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request addresses an import error in the 'Customize Optimization' tutorial that occurs when TVM is not built with CUDA support. The changes include adding a note about the CUDA dependency and implementing a try-except block to catch the ImportError and provide a user-friendly error message. The changes are well-aligned with the problem description. My review includes a critical fix for a Byte Order Mark (BOM) character that was introduced, and a suggestion to make the error handling more robust by checking for CUDA feature availability directly instead of parsing the exception message.
- Provide better solution: suggest pip install tvm-ffi first - Only fall back to full TVM build if needed - Clearer error message with numbered options - Thanks @yongwww for the insights on tvm_ffi installation
|
@yongwww Thanks for the insights! Updated to:
|
CI was failing with: SyntaxError: invalid non-printable character U+FEFF Re-saved file as UTF-8 without BOM in VS Code.
- Remove broken 'else: raise' that always raised even on success - Remove unreachable sys.exit(1) after raise - Keep single clean try-except for CUDA check - Restore simple import for tutorial code - All syntax and formatting checks pass
|
Thank you @yongwww @tqchen for the guidance. This PR is now ready for merge:
The tutorial now:
Ready for final review/merge! 🙏 |
## Summary Adds Windows-specific build notes to the TVM installation documentation (`docs/install/from_source.rst`). ## Changes - Added "Windows-Specific Build Notes" section after "Step 5. Extra Python Dependencies" - Covers common Windows issues and solutions based on contributor experience ## Content Includes: 1. **File Encoding**: UTF-8 without BOM (prevents `SyntaxError: invalid non-printable character U+FEFF` in CI) 2. **Path Conventions**: Forward vs backslash usage in Python/CMake 3. **CUDA Configuration**: Environment setup for CUDA builds on Windows 4. **CMake & Compiler**: Visual Studio generator setup and Python path configuration 5. **Common Issues**: Solutions for frequent Windows build problems 6. **Development Tips**: Git configuration for line endings, VS Code settings 7. **WSL2 Alternative**: Linux-like environment option for Windows users ## Motivation As a Windows contributor to TVM, I encountered several platform-specific issues that could be prevented with better documentation. These notes will help future Windows users: - Avoid BOM character errors that cause CI failures - Configure paths correctly for TVM's build system - Set up CUDA development environment on Windows - Troubleshoot common Windows-specific build failures ## Testing - Verified RST syntax and formatting - Checked logical placement within document flow - Content based on actual Windows development experience with TVM ## Related - Previous contribution: #18697 (improved tutorial error handling) - Addresses undocumented Windows-specific considerations in build process
Fixes #18584
Problem
The tutorial
docs/how_to/tutorials/customize_opt.pyfails with "No module named 'tvm_ffi'" when TVM is not built. This happens because the tutorial importstvm.relax.backend.cuda.cublaswhich requires TVM to be built with CUDA support.Solution
Changes
Testing
Before