Skip to content

Conversation

@yzh119
Copy link
Collaborator

@yzh119 yzh119 commented Oct 10, 2025

📌 Description

This is a bugfix to #1904.

🔍 Related Issues

#1904

🚀 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

  • I have installed pre-commit by running pip install pre-commit (or used your preferred method).
  • I have installed the hooks with pre-commit install.
  • I have run the hooks manually with pre-commit run --all-files and fixed any reported issues.

If you are unsure about how to set up pre-commit, see the pre-commit documentation.

🧪 Tests

  • Tests have been added or updated as needed.
  • All tests are passing (unittest, etc.).

Reviewer Notes

cc @bbartels

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @yzh119, 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 specific issue where the flashinfer CLI would fail to execute if the CUDA toolkit was not present. By removing a problematic environment variable assignment, the change ensures the CLI operates robustly across different system configurations, enhancing its usability in environments without CUDA dependencies.

Highlights

  • Bug Fix: Resolves a command-line interface (CLI) error that occurred when the CUDA toolkit was not installed on the system.
  • Code Change: Removed the 'CUDA_HOME' entry, which called get_cuda_path(), from the environment dictionary within flashinfer/__main__.py.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request aims to fix a crash in the CLI when the CUDA toolkit is not installed. The change correctly removes a direct call to get_cuda_path() which could raise an unhandled exception during module import. However, the fix is incomplete as there are other calls (get_cuda_version()) that can still cause the same crash. My review points out this remaining issue and suggests a more robust solution by handling all potentially failing calls in try-except blocks, similar to the pattern already applied for CUDA_HOME.

"FLASHINFER_CUDA_ARCH_LIST": current_compilation_context.TARGET_CUDA_ARCHS,
"FLASHINFER_CUDA_VERSION": get_cuda_version(),
"FLASHINFER_CUBINS_REPOSITORY": FLASHINFER_CUBINS_REPOSITORY,
"CUDA_HOME": get_cuda_path(),
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Removing this line is correct to prevent a crash when the CUDA toolkit is not installed. However, the calls to get_cuda_version() on lines 80 and 83 can still cause the same issue. They should also be handled gracefully, for example by moving them into a try-except block, similar to how CUDA_HOME is now handled. Additionally, get_cuda_version() is called twice; it would be more efficient to call it once and reuse the result.

Copy link
Member

Choose a reason for hiding this comment

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

Also, it seems like we want to print "CUDA_HOME" regardless of whether nvcc is there. Dropping it silently seems like it could cause confusion.

Maybe we need a refactor so we can separately print:

  • CUDA_HOME
  • Whether or not nvcc was found
  • Whether or not the other CUDA dependencies were found (like cudart)
  • CUDA_VERSION of whatever was found

Copy link
Member

Choose a reason for hiding this comment

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

Currently it looks like, if there's no nvcc, CUDA_HOME will show as "not found" even if the env var is set, which is confusing to me, because even if the user doesn't have nvcc, they still may want to point to a CUDA_HOME for other CUDA deps, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated according to suggestions:

  1. Use a standalone section displaying whether NVCC is found or not.
  2. When CUDA_HOME is not set, we will print "" for the environment variable.
  3. For CUDA runtime, we use torch.cuda.is_available() to determine whether it's available.

@yzh119 yzh119 merged commit fd03820 into flashinfer-ai:main Oct 11, 2025
3 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.

3 participants