已关闭
[Requirement|需求建议]: CATLASS DSL 支持以类实例组织 Kernel #559
rxtfeng创建于 9月12日关闭于 5 天前
longjihui
9月12日 评论:
9月12日 评论:
/assign@rxtfeng


9月12日 将 rxtfeng 设为负责人
9月12日 添加了label:requirement
CheaterAbec
9月14日 评论:
9月14日 评论:
感谢您的关注,我们已经启动需求分析,并排期开发,具体需求拆解如下:
- 支持@tla.kernel封装类调用
- 提供@tla.jit拉起kernel的调用方式
以提供开发者友好的编程体验


9月17日 关联了pull request:feat(dsl): compile class-organized kernels with a compile-time receiver
9月17日 关联了pull request:feat(dsl): compile class-organized kernels with a compile-time receiver
9月17日 关联了里程碑:v2.2.0
5 天前 issue状态由 进行中 改变为 已完成
5 天前 关闭了 issue
5 天前 添加了label:resolved
Thanks for sending an requirement! Please fill in the following template to help quickly solve your problem.
Backgroud / 背景信息 (Mandatory / 必填)
背景
当前 CATLASS DSL 主要以模块级
@tla.kernel函数作为编译入口。对于包含较多编译期配置的复杂算子,kernel、配置校验、fake tensor 构造和编译缓存往往分散在不同的模块级函数或
全局变量中,难以表达“一个配置实例对应一个 kernel specialization”的关系。
CuteDSL 支持将编译期配置保存在实例中,由
@jit __call__选择实例
@kernel,再通过@cache @staticmethod compile创建并缓存编译结果。这种方式让配置、kernel 和编译入口形成清晰的单一抽象。
当前如下按照cutedsl的组织方式会导致编译报错
class VectorAdd: def __init__(self, hidden_size: int): self.hidden_size = hidden_size @tla.jit def __call__(self, lhs, rhs, output): self.kernel(lhs, rhs, output) @tla.kernel def kernel(self, lhs, rhs, output): seqlen = lhs.origin_shape[0] for token_index in tla.range(0, seqlen, 1): for hidden_index in tla.range(0, self.hidden_size, 1): output[token_index, hidden_index] = ( lhs[token_index, hidden_index] + rhs[token_index, hidden_index] ) @cache @staticmethod def compile(seqlen: int, hidden_size: int): fake = make_fake_tensor((seqlen, hidden_size)) kernel = VectorAdd(hidden_size) return tla.compile(kernel, fake, fake, fake, options="--npu-arch 3510") compiled = VectorAdd.compile(seqlen=4, hidden_size=16) compiled(lhs, rhs, output, block_num=1)报错截图
复现脚本
ea86006702364970bf4df41fb4c2b1c9.txt
Origin / 信息来源 (Mandatory / 必填)
客户支撑团队
Benefit and necessity / 价值及作用 (Optional / 选填)
提升复杂算子的封装性
shape、dtype、tile size、stage 数等编译期配置可以保存在实例中,并与唯一 kernel 和编译
入口放在一起,减少模块级可变状态、隐式依赖和跨函数参数传递。
对齐CuteDSL编程方式
更符合开发者使用习惯,提供与CuteDSL一致的编程体验
Design / 设计方案 (Optional / 选填)