forked from zhoulin/zl_bench
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.
32 lines
1.5 KiB
Bash
32 lines
1.5 KiB
Bash
#!/bin/bash
|
||
# 由 ab_repeat.sh 与 screen.sh 共用;两处必须用同一个判据,否则筛选放行的算子
|
||
# 到了 A/B 那步又被拦下,或者反过来。
|
||
|
||
# 一个 run 生成代码的指纹:只取 .ttgir 的相对路径 + 内容,并先抹掉开关自己盖上去的
|
||
# 注解。
|
||
#
|
||
# 只认 .ttgir:dump 目录里还有 index.tsv 和 naming.md,一个 kernel 都没编出来的 run
|
||
# 只剩这两个文件、两侧完全相同,会把"什么都没生成"报成"开关没改变生成代码"。
|
||
#
|
||
# 抹掉 ttg.rlc-*:FlagTree 的 _apply_musa_rlc_policy(mod) 在开关打开时把整套 RLC 策略
|
||
# 旋钮盖成 module 属性,跟这个 pass 后面有没有真的改动什么无关。不抹的话判据有个常量
|
||
# 偏移——凡是能编出 kernel 的算子都必然判成"变了",筛选器谁都不排除。实测 24 个算子
|
||
# 里有 7 个(tanh gelu mul softmax mm bmm replication_pad3d)除这行属性外逐字节相同。
|
||
# 零对照抓不到它:两侧同值时属性也相同。
|
||
#
|
||
# 零 kernel 返回非零,交给调用方当作"没有可比的 IR",而不是"一致"。
|
||
ir_fingerprint() {
|
||
local dir="$1/ttgir"
|
||
[[ -d "$dir" ]] || return 1
|
||
local n
|
||
n=$(find "$dir" -name '*.ttgir' -type f 2>/dev/null | wc -l)
|
||
(( n > 0 )) || return 1
|
||
local out
|
||
out=$( { find "$dir" -name '*.ttgir' -type f | LC_ALL=C sort | while IFS= read -r f; do
|
||
printf '%s
|
||
' "${f#"$dir"/}"
|
||
sed -E 's/"ttg[.]rlc-[^"]*" = [0-9-]+ : i32, ?//g' "$f"
|
||
done; } | sha256sum | cut -d' ' -f1 )
|
||
[[ -n "$out" ]] && printf '%s' "$out"
|
||
}
|