Skip to content

Conversation

yzh119
Copy link
Collaborator

@yzh119 yzh119 commented Oct 1, 2025

📌 Description

Implement features mentioned in #1806 , now user can specify custom dependencies path (e.g. if they are installed as system library) via environment variables FLASHINFER_CUTLASS_INCLUDE_PATH etc.

User can run python -m flashinfer show-config to display these environment variables.

cc @BwL1289

🔍 Related Issues

#1806

🚀 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

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 enhances the flexibility of FlashInfer's build system by allowing users to define custom installation paths for critical external dependencies such as CUTLASS, SPDLOG, and NVSHMEM. This change simplifies integration into diverse development environments and system configurations, reducing potential conflicts and improving overall usability for advanced users who manage their own dependency installations. The update also ensures that configuration details are easily inspectable via the show-config utility.

Highlights

  • Custom Dependency Paths: Introduced the ability for users to specify custom paths for external dependencies like CUTLASS, SPDLOG, and NVSHMEM using new environment variables (e.g., FLASHINFER_CUTLASS_INCLUDE_PATH).
  • Backward Compatibility: Ensured backward compatibility for NVSHMEM-related environment variables by checking for the new FLASHINFER_ prefixed variables first, then falling back to the older NVSHMEM_ prefixed ones.
  • Configuration Visibility: Updated the python -m flashinfer show-config command to display the values of these new environment variables, providing better transparency for users.
  • Dynamic Path Resolution: Refactored the internal handling of CUTLASS and SPDLOG include paths to use getter functions, allowing dynamic resolution based on environment variables rather than static paths.
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 introduces a valuable feature by allowing users to specify custom paths for external dependencies like CUTLASS, spdlog, and nvshmem via environment variables. This greatly improves the flexibility of the build system, especially for users who have these dependencies installed system-wide. The implementation is clean and maintains backward compatibility by falling back to older environment variables or default paths. I have one suggestion to improve performance by caching the results of the new path-getter functions to avoid redundant work.

SPDLOG_INCLUDE_DIR = _package_root / "data" / "spdlog" / "include"


def get_cutlass_include_dirs():
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For performance and consistency, it's a good practice to cache the results of this getter function. Since environment variables are not expected to change during the program's execution, caching will prevent redundant lookups and path processing. You can use @functools.cache for this, which is already used elsewhere in the codebase (e.g., in cpp_ext.py).

Please apply this caching to get_spdlog_include_dir, get_nvshmem_include_dirs, and get_nvshmem_lib_dirs as well. You'll need to add import functools at the top of the file.

Suggested change
def get_cutlass_include_dirs():
@functools.cache
def get_cutlass_include_dirs():

def gen_nvshmem_module() -> JitSpec:
lib_dirs = jit_env.get_nvshmem_lib_dirs()
# Check new environment variable first, then fall back to old one for backward compatibility
ldflags_env = os.environ.get("FLASHINFER_NVSHMEM_LDFLAGS") or os.environ.get(
Copy link
Collaborator

Choose a reason for hiding this comment

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

shall we have documentation collecting these FLASHINFER* vars in some .md file, and briefly mention what they may affect and the order in which related vars are consulted. this could help both users and developers understand the expected behavior (which could otherwise run away after a few ppl modifying the same)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

currently user can run

python -m flashinfer show-config

do display these environment variables, but yes let's clearly document it.

Copy link
Collaborator

@aleozlx aleozlx left a comment

Choose a reason for hiding this comment

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

lgtm

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