Merge blocked
Hi @Will_09, welcome to submitting your first PR to CANN!
PR Merge Steps
1. CLA Signing
If the current PR label includes cann-cla/yes, it means you have signed the CLA and can proceed to the next step. If the label includes cann-cla/no, please sign the CLA first. If you have any questions, please refer to the FAQ.
2. CI Check
Please comment /compile to trigger the CI pipeline check. If the CI run is successful, the PR will be tagged with ci-pipeline-passed and you can proceed to the next step. If the CI run fails, the PR will be tagged with ci-pipeline-failed, please check the CI logs to fix the issues in the PR. If you have any questions, please refer to the FAQ.
3. Code Review
After CI passes, please refer to the PR Approval Progress and proactively @ the committers in the table to review the code. After approval, committers will comment /lgtm and /approve. Once the lgtm and approved labels are successfully added, the PR will be merged automatically.
%!(EXTRA string=https://atomgit.com/cann/community/blob/master/en/sig-infrastructure/command.md)


Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.
PR Approval Progress
⚠️ This PR does not yet meet the following requirements:lgtm (requires ≥ 2 person(s) per module)、approve (requires ≥ 1 person(s) per module)
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| repo-cann/ops-tilelang | ❌ (0/2)(You can also ask: 俞郑中, jiawei_zhuang, 马兵, kevin365, 黄俊健) | ❌ (0/1)(You can also ask: ChaoyangJi, 蒋礼锐, 俞郑中, 黄俊健, 马兵) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
Will_09, thanks for your pull request. All authors of the commits have signed the CLA. 👍


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


PR功能描述 / 为什么需要这个合入:
新增 vocab-parallel embedding_lookup 算子,按 README 与 docs/adding_an_operator.md 的组织方式落入
tensor业务域:src/cann_ops_tilelang/tensor/embedding_lookup.py:公共接口与契约校验。src/cann_ops_tilelang/tensor/embedding_lookup_kernel.py:get_embedding_lookup_kernel与调度配置。cann_ops_tilelang包入口导出embedding_lookup。语义与接口:
[vocab_start_index, vocab_end_index)做 gather;区间外 id 输出零行,因此各 TP rank 的分片结果相加可重建全表。int32/int64ids(任意 rank,含 rank-0)、bfloat16/float16/float32权重、连续输入;支持可选out=;空输入不启动kernel。
out形状/dtype/别名不合法等均给出明确异常,不做静默拷贝或回退。Kernel 设计:
tail_rows个 core 各存一行,输出严格为input_ids.shape + (H,),无 host 侧 reshape/pad/slice。context)规划。
为什么需要:生产推理使用 TP 切分的词表 embedding lookup;现有
tensor/gather不提供分片区间零行语义和精确输出形状/尾行处理,本 PR补齐该算子。
该PR关联的issue
fixes #(如无对应 issue,可填写 N/A)
希望检视人员了解:
torch.equal位精确比较;reference 使用torch.where产生 +0.0,避免 miss 行 ±0.0 的字节差异。valid_rows截断,避免越界读;块存储只在网格填满且尾行可分配时启用。--refresh-baseline/--refresh-mem在本地生成。性能证据
测试环境
计时与带宽口径
tilelang.profiler.bench.do_bench(backend='msprof')(warmup=0、rep=30 ms),只计设备端 kernel 时间;msprof 对多次 kernel 时长取平均,轮间 flush L2。(ids + 输出 + 命中行读) / 时延;命中行读 =shard_rows / vocab_size × num_tokens × hidden × element_size(本 rank 外的 id 在 UB 置零,不读表)。msprof op的Memory.csv实测 HBM 流量对比,h7168 / h4096 / tp8_h4096 / fp32 / small 五个场景偏差 0.2–0.4%。实测性能(仓库 benchmark)
F.embedding(nt=32768, H=7168)流水利用率(
msprof op,56 block)采集口径说明
PipeTimeline不与PipeUtilization写在同一条msprof op命令里:56 block 超过 108 个 sub-block 的插桩上限,计数会失真(实测 MTE2 记为 0%、时长翻倍)。trace.json只采样部分 lane(h7168 为 12/56),核利用率以PipeUtilization.csv的 Block Dim(56)为准。复现命令
# 时延/带宽(仓库 benchmark) OPS_TILELANG_TEST_LEVEL=2 python -m pytest tests/tensor/test_embedding_lookup.py -m benchmark --run-benchmark -q # 流水占比(driver 侧) msprof op --kernel-name=embedding_lookup_kernel_kernel --aic-metrics=PipeUtilization,Memory,L2Cache --output=/tmp/oprof <launch_script>改动类型 / Change Type
测试信息 / Testing
复现命令:
OPS_TILELANG_TEST_LEVEL=2 pytest tests/tensor/test_embedding_lookup.py -m 'not benchmark' pytest tests/tensor/test_embedding_lookup.py -m benchmark --run-benchmark ./scripts/check.sh 检查清单 / Checklist - [x] 代码符合规范 / Code follows style guide - [x] 测试添加并通过 / Tests added and passed - [x] 文档已更新 / Docs updated if needed(接口 docstring 写明支持范围、限制与空输入语义) - [x] 无硬编码敏感信息 / No secrets hardcoded - [x] 提交信息符合规范 / Commit message follows convention