Skip to content

Add KernelSwift optimized inference kernels for T1-T4 - #105

Open
chenweihan02 wants to merge 4 commits into
InfiniTensor:masterfrom
chenweihan02:kernelswift-competition-operators
Open

Add KernelSwift optimized inference kernels for T1-T4#105
chenweihan02 wants to merge 4 commits into
InfiniTensor:masterfrom
chenweihan02:kernelswift-competition-operators

Conversation

@chenweihan02

Copy link
Copy Markdown

KernelSwift 算子创新大赛

项目 内容
参赛队伍 NULL
队长 陈伟汉
参赛成员 陈健勇
所选赛题 T1、T2、T3、T4
修改部分 A:NineToothed 算子实现;与关联 B 部分统一评测

概述

本 PR 实现并优化 KernelSwift 算子创新大赛 T1-T4 的 NineToothed 算子、Torch wrapper、正确性测试、性能 benchmark、一键远程评测脚本和技术报告。

编译器与后端 B 部分由关联的 ninetoothed#215 提供。两部分作为同一作品统一构建和评测。

  • upstream base:9ae4166
  • 本 PR 验证锚点:080910d
  • ninetoothed 验证锚点:6b79203

提交与赛题映射

赛题 commit 算子
T1 ec8f4e1 MXFP4 W4A16 分组专家 GEMM
T2 8a5be7a Block-scaled FP8 GEMM
T3 7fc8074 Gated RMSNorm 融合算子
T4 080910d MLA RoPE 与压缩 KV Cache 写入融合

主要实现

T1:MXFP4 W4A16 分组专家 GEMM

  • 实现 vLLM/OCP 语义兼容的 MXFP4 解码。
  • 融合专家路由、tile reduction 和 FP32 累加。
  • 支持 BF16/FP16 activation、非均衡 routing 和边界 shape。

T2:Block-scaled FP8 GEMM

  • 支持独立的行、列 block-scale 布局。
  • 对 K 维分块执行 FP8 dot,并使用 FP32 累加。
  • 根据目标工具链能力配合 ninetoothed 后端执行 FP16/BF16 operand 合法化。

T3:Gated RMSNorm

  • 融合 RMSNorm、门控激活、affine 和 residual 更新。
  • 对静态语义变体进行专门化,保持公开接口和数学语义不变。
  • 使用未修改的 vLLM RMSNormGated 调用链作为性能 baseline。

T4:MLA RoPE 与压缩 KV Cache 写入

  • 融合 RoPE、no-PE/PE 拼接和 paged KV Cache 写入。
  • 提供 scalar/pair kernel,并按后端能力进行通用分派。
  • 使用未修改的 vLLM RoPE.forward_cuda + concat_and_cache_mla 调用链作为 baseline。

A/B 架构边界

本 PR 只包含算子实现、Torch wrapper、测试、benchmark 和复现材料。通用 SSA、runtime 和目标平台 lowering 位于关联的 ninetoothed PR。

算子数学接口、测试输入语义和 baseline 实现未被修改。benchmark 不被 submission kernel 导入,也没有按公开 case、隐藏数据或答案表选择实现路径。

正确性与编译器回归

pytest output:

Unified validation at ntops@080910d and ninetoothed@6b79203:

Hygon BW, DTK 25.04
T1: 15 passed; compiler regression: 98 passed
T2: 30 passed; compiler regression: 120 passed
T3: 32 passed; compiler regression: 94 passed
T4: 26 passed; compiler regression: 122 passed

Iluvatar CoreX Tiangai 150
T1: 15 passed; compiler regression: 98 passed
T2: 30 passed; compiler regression: 120 passed
T3: 32 passed; compiler regression: 94 passed
T4: 26 passed; compiler regression: 122 passed

A+B 性能结果

所有 speedup 均按 baseline_latency / submission_latency 计算,不使用 PyTorch eager latency。

赛题 海光 BW DTK25.04 天数智芯天垓150 timed baseline
T1 5 case 平均 5.892741×,最低 2.659205× 5 case 平均 2.970092×,最低 1.504281× vllm_semantic_fallback_predecoded
T2 6 case 平均 3.316458×,最低 1.777644× 6 case 平均 1.508378×,最低 1.202633× vllm_portable
T3 3 case 平均 1.2626×,最低 1.2403× 3 case 平均 1.3436×,最低 1.3295× 未修改 vLLM RMSNormGated
T4 6 case 平均 2.199483×,最低 1.4298× 6 case 平均 1.5766×,最低 1.1648× 未修改 vLLM MLA 调用链

T1/T2 目标镜像中的原生 PyTorch 接口不能执行相同语义工作负载,因此采用报告中明确披露的兼容 baseline。上述结果不表述为原生 PyTorch 或未经修改的上游 vLLM binary。

文档与复现

关联 PR

Implement a NineToothed MXFP4 W4A16 grouped expert GEMM with vLLM/OCP-compatible decoding, routed expert mapping, tiled reduction, and FP32 accumulation.

Expose a minimal Torch wrapper and public exports while preserving the operator semantics and validating dtype, shape, layout, and routing contracts.

Add correctness tests, a disclosed portable reference benchmark, a remote-only reproduction script, and the dual-platform technical report.
Implement block-scaled FP8 GEMM with independent row and column scale layouts, masked K tiles, FP32 accumulation, and explicit output dtype handling.

Expose a Torch-compatible wrapper and portable PyTorch/vLLM baseline capability probes without changing the submission kernel's mathematical behavior.

Cover correctness, baseline disclosure, benchmark execution, remote-only reproduction, and dual-platform results.
Fuse RMS normalization, gated activation, optional affine scaling, and residual updates in NineToothed while specializing static semantic variants without changing the public API.

Expose the Torch wrapper and public exports, and benchmark the fused operator against vLLM RMSNormGated with a focused runtime ablation.

Add correctness tests, a remote-only reproduction script, and the dual-platform technical report.
Fuse MLA RoPE transformation, no-PE/PE concatenation, and paged KV cache writes with scalar and paired NineToothed kernels selected by backend capability.

Expose minimal Torch wrappers while preserving vLLM-compatible cache semantics, slot mapping, data types, and fallback behavior.

Add correctness tests, unmodified vLLM baseline benchmarks, warp ablation, remote-only reproduction material, dual-platform results, and the unified submission manifest.
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.

1 participant