Skip to content

misc: jit: Import jit_env as a module #1073

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2025
Merged

misc: jit: Import jit_env as a module #1073

merged 1 commit into from
May 22, 2025

Conversation

abcdabcd987
Copy link
Member

Part of AOT Refactor (#1064).

Change from

from .jit.env import FLASHINFER_XXX

to

from .jit import env as jit_env
jit_env.FLASHINFER_XXX

This allows the AOT script to override the env vars.

@abcdabcd987 abcdabcd987 requested a review from yzh119 May 20, 2025 19:08
@abcdabcd987 abcdabcd987 mentioned this pull request May 20, 2025
10 tasks
@abcdabcd987 abcdabcd987 force-pushed the lequn/remove-parallel-load-modules branch from 5ad71da to 20892f7 Compare May 21, 2025 20:33
@abcdabcd987 abcdabcd987 force-pushed the lequn/remove-parallel-load-modules branch from 20892f7 to ed480f6 Compare May 22, 2025 00:37
Base automatically changed from lequn/remove-parallel-load-modules to main May 22, 2025 00:42
@yzh119 yzh119 requested a review from Copilot May 22, 2025 00:44
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the way JIT environment variables and constants are imported by switching to a module‑based import (using jit_env) so that the AOT script can override environment variables.

  • Changed all direct imports of FLASHINFER_* constants from .jit.env to fetching them via jit_env
  • Adjusted import orders across multiple modules and updated associated file paths accordingly

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
flashinfer/sampling.py Updated imports to use jit_env and split FLASHINFER_CSRC_DIR usage.
flashinfer/rope.py Similar update: replaced direct FLASHINFER_CSRC_DIR with jit_env.
flashinfer/quantization.py Updated the import of FLASHINFER_CSRC_DIR via jit_env.
flashinfer/page.py Updated FLASHINFER_CSRC_DIR lookup to use jit_env.
flashinfer/norm.py Replaced direct FLASHINFER_CSRC_DIR usage with jit_env reference.
flashinfer/mla.py Updated both FLASHINFER_CSRC_DIR and CUTLASS_INCLUDE_DIRS to be accessed via jit_env.
flashinfer/jit/env.py Added documentation and note discouraging direct import from .jit.env.
flashinfer/jit/cpp_ext.py Updated FLASHINFER_DATA usage to jit_env reference.
flashinfer/jit/core.py Adjusted directory creation and file path construction to use jit_env.
flashinfer/jit/attention/tvm.py Updated constants access to use jit_env for source and generated path resolution.
flashinfer/jit/attention/pytorch.py Updated imports to reference jit_env for FLASHINFER_* constants.
flashinfer/jit/activation.py Updated FLASHINFER_GEN_SRC_DIR to be accessed via jit_env.
flashinfer/jit/init.py Removed wildcard import of .env and re-exported jit_env explicitly.
flashinfer/gemm.py Updated all FLASHINFER_CSRC_DIR calls to use jit_env.
flashinfer/custom_all_reduce.py Updated constants import to reference jit_env.
flashinfer/cascade.py Replaced FLASHINFER_CSRC_DIR usage with jit_env in module generation.

Copy link
Collaborator

@yzh119 yzh119 left a comment

Choose a reason for hiding this comment

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

We should check the codebase and avoid all from ... import constant patterns.
Do we have any lint tools to check this?

@yzh119 yzh119 merged commit 5667efc into main May 22, 2025
1 of 2 checks passed
@yzh119 yzh119 deleted the lequn/jit-env branch May 22, 2025 00:48
Edenzzzz pushed a commit to Edenzzzz/flashinfer that referenced this pull request Jun 6, 2025
Part of AOT Refactor (flashinfer-ai#1064).

Change from

```python
from .jit.env import FLASHINFER_XXX
```

to

```python
from .jit import env as jit_env
jit_env.FLASHINFER_XXX
```

This allows the AOT script to override the env vars.
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