Skip to content

Conversation

@zufayu
Copy link
Contributor

@zufayu zufayu commented Dec 1, 2025

Motivation

Technical Details

Test Plan

Test Result

Submission Checklist

Copilot AI review requested due to automatic review settings December 1, 2025 04:45
Copilot finished reviewing on behalf of zufayu December 1, 2025 04:48
Copy link
Contributor

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 fixes bugs related to the PREBUILD_KERNELS functionality in the setup process. The changes refactor the kernel exclusion logic, add environment variable support for specifying the AITER metadata directory, and extend prebuild support from just PREBUILD_KERNELS=1 to all non-zero values.

Key Changes:

  • Refactored exclude_ops logic into a cleaner get_exclude_ops() function
  • Extended prebuild kernel support to work with PREBUILD_KERNELS values 1, 2, and 3 (not just 1)
  • Added AITER_META_DIR environment variable support with validation fallback

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
setup.py Refactors prebuild kernel exclusion logic, sets AITER_META_DIR environment variable, extends prebuild support to all non-zero PREBUILD_KERNELS values, and adds preprocessor flags to build configuration
aiter/jit/core.py Adds environment variable override mechanism for AITER_META_DIR with validation fallback to ensure the directory contains required csrc subdirectory

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

"module_mha_varlen_bwd",
]
elif PREBUILD_KERNELS == 3:
return []
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

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

The get_exclude_ops() function does not return a value when PREBUILD_KERNELS is not 1, 2, or 3. This will cause exclude_ops to be None on line 104, leading to a potential error when passed to core.get_args_of_build().

Add a default return statement:

def get_exclude_ops():
    if PREBUILD_KERNELS == 1:
        return [...]
    elif PREBUILD_KERNELS == 2:
        return [...]
    elif PREBUILD_KERNELS == 3:
        return []
    else:
        return []
Suggested change
return []
return []
else:
return []

Copilot uses AI. Check for mistakes.
setup.py Outdated
Comment on lines 116 to 125
flags_cc = list(one_opt_args["flags_extra_cc"]) + (
[f"-DPREBUILD_KERNELS={PREBUILD_KERNELS}"]
if PREBUILD_KERNELS != 0
else []
)
flags_hip = list(one_opt_args["flags_extra_hip"]) + (
[f"-DPREBUILD_KERNELS={PREBUILD_KERNELS}"]
if PREBUILD_KERNELS != 0
else []
)
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

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

The condition if PREBUILD_KERNELS != 0 is redundant inside the build_one_module() function. This function is only called when PREBUILD_KERNELS != 0 (line 106), so the conditional expressions on lines 117-119 and 122-124 will always append the flag.

Simplify to:

flags_cc = list(one_opt_args["flags_extra_cc"]) + [f"-DPREBUILD_KERNELS={PREBUILD_KERNELS}"]
flags_hip = list(one_opt_args["flags_extra_hip"]) + [f"-DPREBUILD_KERNELS={PREBUILD_KERNELS}"]
Suggested change
flags_cc = list(one_opt_args["flags_extra_cc"]) + (
[f"-DPREBUILD_KERNELS={PREBUILD_KERNELS}"]
if PREBUILD_KERNELS != 0
else []
)
flags_hip = list(one_opt_args["flags_extra_hip"]) + (
[f"-DPREBUILD_KERNELS={PREBUILD_KERNELS}"]
if PREBUILD_KERNELS != 0
else []
)
flags_cc = list(one_opt_args["flags_extra_cc"]) + [f"-DPREBUILD_KERNELS={PREBUILD_KERNELS}"]
flags_hip = list(one_opt_args["flags_extra_hip"]) + [f"-DPREBUILD_KERNELS={PREBUILD_KERNELS}"]

Copilot uses AI. Check for mistakes.
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