forked from zhoulin/zl_bench
bench: ignore the switch's own annotations when fingerprinting the IR
FlagTree's _apply_musa_rlc_policy(mod) stamps the whole RLC policy onto the module as ttg.rlc-* attributes whenever the switch is on, regardless of whether the pass then changes anything. Hashing the raw text therefore carried a constant offset: every operator that compiles a kernel differed on that one line and screened as IR_CHANGED. A filter that excludes nothing is not filtering. The null control could not catch it. Both of its sides run with the switch off, so both carry the same attributes and the fingerprints match — it proved the dump is deterministic, which was true, and said nothing about this. Stripping ttg.rlc-* before hashing turns the screen back into a filter. Over the same 24 operators, recomputed from the artifacts already on disk: 23 IR_CHANGED becomes 16, with 7 falling back to NO_IR_DIFF — tanh, gelu, mul, softmax, mm, bmm, replication_pad3d, each byte-identical apart from that line. replication_pad3d is the PR's largest NVIDIA win at +124.6%; on MUSA this pass does not touch it. The counts also show why the convert_layout count fails as a criterion in both directions: addmm keeps cvt at 15 -> 15 while all 15 of its ttgir files differ in substance, and tanh has no conversions and no change.
This commit is contained in:
1 parent
4ac2a9acd8
commit
c6a7f834cb
2 files changed
+23
-7
No files matched your search
@@ -164,7 +164,14 @@ SWITCH=FLAGTREE_MUSA_RLC_ENHANCE ROUNDS=6 OPS="topk:topk" bash ab_repeat.sh
|
|||||||
两件容易做错的:
|
两件容易做错的:
|
||||||
|
|
||||||
- **判据是 ttgir 指纹,不是 `convert_layout` 计数。** cvt 数相同不等于生成代码
|
- **判据是 ttgir 指纹,不是 `convert_layout` 计数。** cvt 数相同不等于生成代码
|
||||||
相同,而要测的是"生成代码变了没有"。cvt 数照样记,它解释的是变化的性质。
|
相同,而要测的是"生成代码变了没有"。两个方向都会骗人:`addmm` 的 cvt 是 15→15
|
||||||
|
没变,15 个 ttgir 文件却实质全不同;`tanh`/`softmax` 的 cvt 是 0→0,生成代码也
|
||||||
|
真的没动。cvt 数照样记,它解释的是变化的性质。
|
||||||
|
- **指纹先抹掉开关自己盖的注解。** FlagTree 的 `_apply_musa_rlc_policy(mod)` 在开关
|
||||||
|
打开时把整套 RLC 策略旋钮盖成 module 属性(`ttg.rlc-*`),跟这个 pass 后面有没有
|
||||||
|
真的改动什么无关。不抹的话判据有个常量偏移——**凡是能编出 kernel 的算子都必然判成
|
||||||
|
"变了",筛选器谁都不排除**。24 个算子实测:抹之前 23 个 `IR_CHANGED`,抹之后 7 个
|
||||||
|
落回 `NO_IR_DIFF`。零对照抓不到这个,因为两侧同值时属性也相同。
|
||||||
- **不要全局写死一个 `DTYPES`。** `OPS` 元素支持 `OP:OP_FILE:DTYPES`,留空表示用
|
- **不要全局写死一个 `DTYPES`。** `OPS` 元素支持 `OP:OP_FILE:DTYPES`,留空表示用
|
||||||
该算子自己的全套。`fft` 只吃 complex64,被一刀切的 `DTYPES=float16` 判死过一次
|
该算子自己的全套。`fft` 只吃 complex64,被一刀切的 `DTYPES=float16` 判死过一次
|
||||||
——那是 harness 的问题,被记成了算子的问题。
|
——那是 harness 的问题,被记成了算子的问题。
|
||||||
|
|||||||
+15
-6
@@ -2,11 +2,18 @@
|
|||||||
# 由 ab_repeat.sh 与 screen.sh 共用;两处必须用同一个判据,否则筛选放行的算子
|
# 由 ab_repeat.sh 与 screen.sh 共用;两处必须用同一个判据,否则筛选放行的算子
|
||||||
# 到了 A/B 那步又被拦下,或者反过来。
|
# 到了 A/B 那步又被拦下,或者反过来。
|
||||||
|
|
||||||
# 一个 run 生成代码的指纹:只取 .ttgir 的相对路径 + 内容。
|
# 一个 run 生成代码的指纹:只取 .ttgir 的相对路径 + 内容,并先抹掉开关自己盖上去的
|
||||||
# 路径进指纹是因为"变体集合变了"与"某个变体内容变了"同样算改变,而只 cat 内容
|
# 注解。
|
||||||
# 会把前者洗掉。只认 .ttgir 则是因为 dump 目录里还有 index.tsv 和 naming.md:
|
#
|
||||||
# 一个 kernel 都没编出来的 run 只剩这两个文件、两侧完全相同,会把"什么都没生成"
|
# 只认 .ttgir:dump 目录里还有 index.tsv 和 naming.md,一个 kernel 都没编出来的 run
|
||||||
# 报成"开关没改变生成代码"——router_gemm 在 MUSA 上就是这样。
|
# 只剩这两个文件、两侧完全相同,会把"什么都没生成"报成"开关没改变生成代码"。
|
||||||
|
#
|
||||||
|
# 抹掉 ttg.rlc-*:FlagTree 的 _apply_musa_rlc_policy(mod) 在开关打开时把整套 RLC 策略
|
||||||
|
# 旋钮盖成 module 属性,跟这个 pass 后面有没有真的改动什么无关。不抹的话判据有个常量
|
||||||
|
# 偏移——凡是能编出 kernel 的算子都必然判成"变了",筛选器谁都不排除。实测 24 个算子
|
||||||
|
# 里有 7 个(tanh gelu mul softmax mm bmm replication_pad3d)除这行属性外逐字节相同。
|
||||||
|
# 零对照抓不到它:两侧同值时属性也相同。
|
||||||
|
#
|
||||||
# 零 kernel 返回非零,交给调用方当作"没有可比的 IR",而不是"一致"。
|
# 零 kernel 返回非零,交给调用方当作"没有可比的 IR",而不是"一致"。
|
||||||
ir_fingerprint() {
|
ir_fingerprint() {
|
||||||
local dir="$1/ttgir"
|
local dir="$1/ttgir"
|
||||||
@@ -16,7 +23,9 @@ ir_fingerprint() {
|
|||||||
(( n > 0 )) || return 1
|
(( n > 0 )) || return 1
|
||||||
local out
|
local out
|
||||||
out=$( { find "$dir" -name '*.ttgir' -type f | LC_ALL=C sort | while IFS= read -r f; do
|
out=$( { find "$dir" -name '*.ttgir' -type f | LC_ALL=C sort | while IFS= read -r f; do
|
||||||
printf '%s\n' "${f#"$dir"/}"; cat "$f"
|
printf '%s
|
||||||
|
' "${f#"$dir"/}"
|
||||||
|
sed -E 's/"ttg[.]rlc-[^"]*" = [0-9-]+ : i32, ?//g' "$f"
|
||||||
done; } | sha256sum | cut -d' ' -f1 )
|
done; } | sha256sum | cut -d' ' -f1 )
|
||||||
[[ -n "$out" ]] && printf '%s' "$out"
|
[[ -n "$out" ]] && printf '%s' "$out"
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user