Built an inference framework:
The official tilelang code has been replaced with a homegrown torch + HIP implementation, and end-to-end validation passes on a small model (5 layers / 1024 dims).
Speed comparison (same small model):
| Before | Now | Speedup | |
|---|---|---|---|
| prefill(128) | 515 ms | 66 ms | 7.8× |
| decode(1) | 362 ms | 40 ms | 9.1× |
Homegrown HIP kernels (quant.hip / fused.hip, gfx906, loaded via ctypes):
: act_quant, fp4_act_quant, fp8/fp4 GEMM (matrix-vector, decode path), RMSNorm, RoPE, SwiGLU, Sinkhorn, hc_mixes, hc_pre/hc_post, sparse_attn. The quant kernels are 4–38× faster than torch; the rest are bit-exact or only differ by bf16 rounding.
Right now decode is CPU-bound (the GPU sits idle most of the time): it used to be ~100ms CPU / 33ms CUDA. I've gotten it down to ~21ms CPU by doing MoE dispatch sort-and-group, a single sync, and fused kernels. The remaining overhead is torch's per-operator
model-00048-of-00048.safetensors: 5%|▍ | 5.07G/102G [04:39<1:23:33, 19.2MB/s]
model-00048-of-00048.safetensors: 5%|▍ | 5.08G/102G [04:39<1:24:48, 19.0MB/s]47
381G /AI/DeepSeek-V4.1-Flash-1017/
But the model itself is still downloading
47/48 shards are in place (381GB), the last one 00048 (102GB) is at 12% and will finish in about 1.2 hours.
Only then can I do real inference testing
做了一个推理框架:
官方 tilelang 代码已替换为自研 torch + HIP 实现,小模型(5 层/1024 维)端到端验证通过。
速度对比(同一小模型):
| 优化前 | 当前 | 提速 | |
|---|---|---|---|
| prefill(128) | 515 ms | 66 ms | 7.8× |
| decode(1) | 362 ms | 40 ms | 9.1× |
自研 HIP 内核(quant.hip / fused.hip,gfx906,ctypes 加载)
:act_quant、fp4_act_quant、fp8/fp4 GEMM(矩阵-向量,decode 路径)、RMSNorm、RoPE、SwiGLU、Sinkhorn、hc_mixes、hc_pre/hc_post、sparse_attn。量化类内核比 torch 快 4–38×,其余逐位对齐或仅 bf16 舍入差异。
当前decode 是 CPU 瓶颈(GPU 大量空转):原先约 100ms CPU / 33ms CUDA。已通MoE 派发排序分组、单次同步、融合内核压到约 21ms CPU。剩余开销是 torch 逐算子
model-00048-of-00048.safetensors: 5%|▍ | 5.07G/102G [04:39<1:23:33, 19.2MB/s]
model-00048-of-00048.safetensors: 5%|▍ | 5.08G/102G [04:39<1:24:48, 19.0MB/s]47
381G /AI/DeepSeek-V4.1-Flash-1017/
但是目前模型本身仍然在下载
47/48 分片就位(381GB),最后一片 00048(102GB)下载至 12%,约 1.2 小时后完成。
才能真实推理测试
Translated by AI from 简体中文Original (简体中文)

可以共享、可以push的免费邮箱,更可使用自定义域名,完美契合您的各项需求。
2 replies
Sort order