mirror of
https://github.com/deepseek-ai/DeepInfer.git
synced 2026-10-31 00:36:20 +08:00
docs(h20): the torch-reference path imports but does not yet run
Section 6.0 now states the status as a table, because the previous wording invited a wrong reading. Importing the torch references -- and even deepinfer itself -- succeeds without TileLang, and five operators are numerically validated. But the model forward still calls the compiled quantisation and MoE entry points, which raise ModuleNotFoundError, because the routing layer that would point them at the references does not exist. End to end has never run, so the performance regression is an expectation, not a measurement.
This commit is contained in:
parent
dca7f959cf
commit
d714c9aff0
35
TODO.md
35
TODO.md
@ -595,6 +595,20 @@ import 路径上。修完之后 `import deepinfer` 在纯 Triton 环境不再需
|
||||
把热路径逐个换成 Triton。§2.10b 说明了大头在哪(模型前向直接调 `tile_kernels` 的
|
||||
quant/MoE/MHC/engram,25 处模块级 import / 23 个 API)。
|
||||
|
||||
### 6.0 ⚠️ 当前到哪一步了(先说清楚,别误读成「已能跑」)
|
||||
|
||||
| # | 事项 | 状态 |
|
||||
|---|---|---|
|
||||
| 1 | `import tile_kernels.torch`(无 tilelang) | ✅ 通 |
|
||||
| 2 | `import deepinfer`(无 tilelang) | ✅ 通(lazy init 的副作用,不等于能跑) |
|
||||
| 3 | 算子数值等价(5 个) | ✅ 4 个 bitwise + rope 1 ULP |
|
||||
| 4 | **模型前向实际调用 `tile_kernels.quant.*`** | ❌ **仍然抛 `ModuleNotFoundError: tilelang`** |
|
||||
| 5 | **端到端推理** | ❌ **从未跑过** |
|
||||
| 6 | **性能** | ❓ **未测**(跑不起来就无从测,退化是推测) |
|
||||
|
||||
第 4 行是当前的断点:deepinfer 里 25 处 `import tile_kernels` 指向的还是**编译版**,
|
||||
`tk_compat` 路由层没写,所以调用一进去就要求 tilelang。**「导进去了」和「调得动」是两件事。**
|
||||
|
||||
### 6.1 第一步已通:`tile_kernels.torch` 能在无 TileLang 下导入
|
||||
|
||||
原本不行,因为三层 eager import 把纯 Python 的参考实现和编译栈绑在一起:
|
||||
@ -632,15 +646,18 @@ use_tma_aligned_col_major_sf=True`):
|
||||
|
||||
**这是整条桥的前提**:量化链 bitwise 相同意味着「先跑通」不会引入 token 级偏差。
|
||||
|
||||
### 6.3 还没做的(下一步)
|
||||
### 6.3 还没做的(下一步,按顺序)
|
||||
|
||||
1. **路由层**:把 deepinfer 里 25 处 `import tile_kernels` 改成走一个 compat 包
|
||||
(`deepinfer/tk_compat/{quant,moe,transform,mhc,engram,config}.py`),按「有无 tilelang /
|
||||
`DEEPINFER_KERNELS=ref`」选 CUDA 实现还是 `_ref`。改动最小形式是只换 import 那一行。
|
||||
2. **MHC 8 个 + MoE gate 未做 A/B**:`mhc_*` 与 `moe_topk_gate` 还没验证(语义更复杂),
|
||||
做之前不能假设等价。
|
||||
3. **性能**:纯 torch 的 `per_token_cast` 每层都过,预计是数量级退化。桥的作用是
|
||||
「先正确」,之后按 profile 换 Triton。
|
||||
4. **上游**:以上 3 个补丁应该提到 FlagOS,否则每次重装都要重跑脚本。
|
||||
1. **路由层(唯一的硬阻塞)**:把 deepinfer 里 25 处 `import tile_kernels` 改成走
|
||||
`deepinfer/tk_compat/`,按有无 tilelang 或 `DEEPINFER_KERNELS=ref` 选编译版还是 `_ref`。
|
||||
最小改法:只换 import 那一行(`import tile_kernels` → `from deepinfer import tk_compat as
|
||||
tile_kernels`),`tile_kernels.quant.xxx(...)` 的调用点一行都不用动。
|
||||
**ref 侧覆盖率已核对**:11 个主 API 里 8 个有直接对应(另 3 个是 `config` 开关,本来就在
|
||||
`tile_kernels.config` 里,不需要 ref);8 个 `mhc_*_ref` 全在。唯一不明的是
|
||||
`mhc_pre_big_fuse_fwd`(只有个 `reduce_fused` 名字像,未确认)。
|
||||
2. **MHC 8 个 + MoE gate 的数值 A/B**:ref 存在 ≠ 数值等价,还没验过,做之前不能假设。
|
||||
3. **端到端**:路由层 + 上面的 A/B 都过之后才能真正跑,然后再谈 token 一致性。
|
||||
4. **性能**:现在说「退化严重」只是推测,没测过。跑通后才有基准。
|
||||
5. **上游**:以上 3 个补丁应该提到 FlagOS,否则每次重装都要重跑脚本。
|
||||
|
||||
(`flag_gems` 不是替代品:903 个 ATen 级算子替换,没有这些定制融合算子。)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user