Skip to content

[KernelSwift算子优化] 程柯雷-Task03 norm_fn-571900729 - #190

Open
Lfan-ke wants to merge 3 commits into
DeepLink-org:mainfrom
Lfan-ke:ks-task03-norm-fn
Open

[KernelSwift算子优化] 程柯雷-Task03 norm_fn-571900729#190
Lfan-ke wants to merge 3 commits into
DeepLink-org:mainfrom
Lfan-ke:ks-task03-norm-fn

Conversation

@Lfan-ke

@Lfan-ke Lfan-ke commented Aug 31, 2026

Copy link
Copy Markdown

作品说明:沐曦 C500 上用 Clike 重写 KernelSwift 赛道二 Task03 norm_fn,文件内同时含与参考一致的 Model 与优化实现 ModelNewforward 内通过 python 调用自实现算子。

优化方案:一个 block 负责同一行的 6 个输出,residual 与 RMS 分母整块只过一遍、6 个点积在寄存器里并行累,访存走 float4/uint2 向量化;另外把宿主侧编译提到 -O3load_inline 默认不注入任何 -O,pybind 胶水一直是 -O0)。

性能结果(MetaX C500 / MACA 3.7.0.38 / torch 2.8.0+metax3.7.0.7,官方 benchmarks/ks/auto_bench.py 默认参数,连跑三次,均 PASS accuracy):

赛题 v0(torch 参考) v1(本提交) Speedup
Task03 norm_fn 0.2282 / 0.2211 / 0.2332 ms 0.0401 / 0.0392 / 0.0403 ms 5.70× / 5.64× / 5.79×

本作品为原创。

@CLAassistant

CLAassistant commented Aug 31, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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