Add generic reduction domains and Triton row-vector scheduling - #208
Open
whjthu wants to merge 3 commits into
Open
Add generic reduction domains and Triton row-vector scheduling#208whjthu wants to merge 3 commits into
whjthu wants to merge 3 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pytestoutput:背景
当前 SSA 编译链路对 reduction 的调度主要依赖启发式判断,缺少对归约域、并行域和结果使用关系的结构化分析。这带来两个问题:
本 PR 从 SSA 类型、归约轴和 use-def 链中提取通用的 Reduction Domain,并据此完成调度。
主要修改
通用 Reduction Domain
新增不可变的
ReductionDomain,用于描述:sum/max/min类型;分析同时覆盖:
scf.if、scf.for、scf.yield和 loop-carried value;mem.store与mem.atomic_add等 effect sink;Triton Row-Vector 调度
当 Reduction Domain 满足约束时,Triton 使用 row-vector 调度:
tl.arange()覆盖 reduction axis;tl.sum、tl.max或tl.min完成归约;不满足条件时进入明确的 scalar fallback,无法保证语义时直接报错,不生成可疑代码。
调优接入
复用现有
LaunchPlan和 AutoTuner,不引入第二套调优系统:num_warps候选为4、8、1;num_stages=1;max_num_configs=1使用安全的 4-warps 配置;后端隔离
Row-vector value semantics 仅由 Triton 后端消费。CUDA 和 TileLang 保持原有 lowering 行为,后续 PR 再做更新。
正确性覆盖
新增测试集中覆盖以下高价值场景:
sum/max/min生成;没有为每个内部 helper 增加独立测试,测试主要保持在 IR 契约、生成源码和公共执行路径三个层次。
测试结果
三个后端分别执行完整并行测试:
两个 skip 均为已有的多 GPU 测试,当前测试服务器只有一张 GPU:
性能结果
测试平台为 NVIDIA L20。基准为历史 master:
c9ebd4950a185beed8d4c1db9ff4a1fd133934ae覆盖:
4096 × {128, 256, 512, 1024, 2048, 4096}4096 × {128, 256, 512, 1024, 2048, 4096}127、781、1127、4097共 12 个主性能点和 8 个 held-out 点,全部数值正确。
下表中的比值为:
本 PR 延迟 / 历史 master 延迟因此小于 1 表示本 PR 更快。
所有主测试点均不超过历史 master 10%,整体性能优于历史 master。
改动范围
本 PR 只完成通用 Reduction Domain 和 Triton row-vector 物化。CUDA、TileLang 的并行归约物化与后端专属性能优化将通过后续独立 PR 完成。