feat(meta_schedule): expand CUDA unroll steps for SM70 optimization#18927
feat(meta_schedule): expand CUDA unroll steps for SM70 optimization#18927jianhua1724 wants to merge 1 commit intoapache:mainfrom
Conversation
Summary of ChangesHello, 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 MetaSchedule's CUDA optimization capabilities by refining the loop unrolling strategy. By introducing a broader range of unroll steps, the system can now discover more efficient execution paths, particularly benefiting SM70 (V100) GPUs. This targeted adjustment aims to boost performance without impacting compatibility or stability across different CUDA architectures. 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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request expands the unroll_max_steps array in the DefaultCUDA schedule rule for ParallelizeVectorizeUnroll in src/s_tir/meta_schedule/schedule_rule/schedule_rule.cc, adding intermediate unroll steps (32, 128, 256) to the search space. The feedback suggests that while this expansion is beneficial for newer CUDA architectures (SM70+), applying it universally could increase auto-tuning time for older architectures. It is recommended to make the unroll_max_steps conditional on the target's compute capability to optimize tuning time.
| /*max_jobs_per_core=*/-1, | ||
| /*max_vectorize_extent=*/-1, | ||
| /*unroll_max_steps=*/ffi::Array<Integer>{0, 16, 64, 512, 1024}, | ||
| /*unroll_max_steps=*/ffi::Array<Integer>{0, 16, 32, 64, 128, 256, 512, 1024}, |
There was a problem hiding this comment.
This change expands the unroll search space for all CUDA targets, which can increase auto-tuning time for architectures where these new unroll steps are not beneficial.
To make this optimization more targeted to SM70+ GPUs as intended, I suggest making the choice of unroll steps conditional on the target's compute capability. This avoids slowing down tuning on older architectures. This can be done cleanly using an immediately-invoked lambda expression.
The condition can be sm_version >= 70 if the optimization is beneficial for SM70 and newer, or sm_version == 70 if it's specific to V100.
/*unroll_max_steps=*/[]() -> ffi::Array<Integer> {
auto target = tvm::Target::Current(true);
if (target.defined() && target->kind->name == "cuda") {
if (const auto* sm_ptr = target->GetAttr<Integer>("sm")) {
if (sm_ptr->value() >= 70) {
return {0, 16, 32, 64, 128, 256, 512, 1024};
}
}
}
return {0, 16, 64, 512, 1024};
}(),
Motivation
Expand CUDA unroll search space to support optimal loop unrolling sizes for SM70 (V100) GPUs.
Add missing critical unroll steps: 32, 128, 256.
Changes
Only modify 1 line:
Extend
unroll_max_stepsinScheduleRule::DefaultCUDA()From: {0, 16, 64, 512, 1024}
To: {0, 16, 32, 64, 128, 256, 512, 1024}
Benefits
Test
Compiled and tested on SM70 (V100), no regression.