Files
aituner/docs/harness-ablation/knob-conditional-effects-20260705.md

193 lines
8.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Knob conditional effect 证据整理
本文整理 2026-07-01 到 2026-07-03 在 `dash1` 上跑的 interaction screening 结果,用来支持一个具体论点:
> Serving tuning knobs 不是彼此独立的。一个 knob 的收益方向和收益大小依赖当前 topology、admission/concurrency 和 scheduler context因此不能假设“逐个 knob tune 到最好”一定可靠。
## Presentation review: 应该怎么展示
原来的 delta summary 能证明 `Delta_knob(context)` 不同,但它不够直观,因为它没有展示 tuning algorithm 会怎么失败。更适合作为 paper 主图的是:
1. **主图OAT path counterexample**
在同一个 measured response surface 上画两条 one-knob-at-a-time 路径。读者能直接看到:同一个起点、不同单维 tuning 顺序,会停在不同点,而且其中一个是 coordinate-wise local optimum。
2. **补充图interaction residual**
用 additive model residual 形式说明:如果 TP 和 MNS 是独立贡献,残差应接近 0实际残差有结构性正负块。
3. **补充图delta/context summary**
保留为形式化证据,但不作为主图,因为它不能直接展示 OAT 的路径依赖。
因此本文推荐把 `knob-oat-counterexample-c1-qwen30b` 作为主文图,把 C3 crossed lines 和 residual/delta 放在 appendix 或机制分析图中。
## 图 1OAT path counterexample
![OAT counterexample](figures/knob-oat-counterexample-c1-qwen30b.png)
数据来源:
- `interaction-mixed-qwen30b-tp-mns-surface-high1-dash1-d8899c5-20260701T095858Z`
- `interaction-mixed-qwen30b-tp4-mns-nocap-qps20-dash1-d8899c5-20260701T161900Z`
这张图直接展示为什么“逐个维度独立 tune”不可靠。我们从同一个起点 `TP=1, MNS=8` 出发:
| Strategy | Path | Final req/s/GPU |
|---|---|---:|
| tune MNS first, then TP | `TP1,MNS8 -> TP1,MNS16 -> TP4,MNS16` | `2.44` |
| tune TP first, then MNS | `TP1,MNS8 -> TP2,MNS8 -> TP2,MNS32` | `3.28` |
`TP4,MNS16` 是一个 measured coordinate-wise local optimum
- 固定 `TP=4``MNS``MNS16/32/64` 都是 `2.44`,没有 strictly improving move
- 固定 `MNS=16``TP``TP4=2.44` 高于 `TP1=2.35``TP2=2.27`
- 但全局最好点 `TP2,MNS32=3.28` 比它高 `25.6%`
这比单纯说 “MNS 的 delta 依赖 TP” 更有力:它展示了一个实际 tuning path 如何被独立维度假设带到次优点。要从 `TP4,MNS16` 逃到 `TP2,MNS32`tuner 必须允许非独立的 context-aware move或者至少维护 frontier/plateau 上的反事实 anchor单维 greedy OAT 不够。
这里的结论不是“所有 workload 都有强 interaction”而是更严格地说
1. 在真实 case 中确实存在明显 conditional effect
2. 这个现象足以否定 naive one-knob-at-a-time/OAT 作为通用 tuning strategy
3. harness 需要维护 mechanism-aware context而不是把 knobs 当作独立维度。
## Formal definition
记某个 engine config 的 SLO-feasible objective 为:
```text
f(config) = max request_rate_per_gpu subject to pass_rate >= target
```
对 knob `x` 的一个 intervention `x_low -> x_high`,在 context `c` 下的效果定义为:
```text
Delta_x(c) = f(x_high, c) - f(x_low, c)
```
如果存在两个 context `c1, c2`,使得:
```text
Delta_x(c1) != Delta_x(c2)
```
则说明 knob `x` 存在 conditional effect。若符号也变化比如一个 context 下提升、另一个 context 下降,则是更强的 interaction。
## 图 2C1 Qwen30B mixed workload surface
![C1 Qwen30B surface](figures/knob-conditional-c1-qwen30b-surface.png)
数据来源:
- `interaction-mixed-qwen30b-tp-mns-surface-high1-dash1-d8899c5-20260701T095858Z`
- `interaction-mixed-qwen30b-tp4-mns-nocap-qps20-dash1-d8899c5-20260701T161900Z`
关键观察:
| Context | `MNS=8 -> 32` 的 req/s/GPU 变化 |
|---|---:|
| `TP=1` | `2.10 -> 2.28`, `+8.7%` |
| `TP=2` | `2.28 -> 3.28`, `+44.3%` |
| `TP=4` | `1.28 -> 2.44`, `+90.3%` |
这说明 `max-num-seqs` 的收益强烈依赖 `tensor-parallel-size`。同一个 `MNS` 调整在 `TP=1` 下只是小幅提升,在 `TP=2/4` 下变成决定性能上限的关键 knob。
反过来看,`TP` 的收益也依赖 `MNS`
-`MNS=8` 时,`TP=4` 是坏点,只有 `1.28 req/s/GPU`
-`MNS=32` 时,`TP=2` 变成全局最优附近,达到 `3.28 req/s/GPU`
因此,如果 tuner 固定 `MNS=8` 去判断 topology会错误低估 `TP=4`,也会无法看到 `TP=2 + MNS=32` 的最佳区域;如果固定 `TP=1` 去调 `MNS`,又会低估更高 TP 下 concurrency knob 的价值。这就是 OAT order sensitivity。
## 图 3C1 additive residual
![C1 interaction residual](figures/knob-interaction-residual-c1-qwen30b.png)
如果 `TP``MNS` 可以独立建模,一个简单 additive model
```text
f(TP, MNS) ~= base + effect(TP) + effect(MNS)
```
应该留下接近 0 的 residual。实际 residual 最大达到约 `0.46 req/s/GPU`,而且呈现结构性模式:
- `TP2,MNS32/64` 是正 residual说明这个组合比独立效应相加更好
- `TP2,MNS16``TP4,MNS8` 是强负 residual说明某些组合显著低于独立假设预测。
这张图适合放在机制/appendix 中,用数学形式支持“不是独立 knob effect”。
## 图 4C3 Qwen235B decode workload
![C3 Qwen235B decode lines](figures/knob-conditional-c3-qwen235b-decode-lines.png)
数据来源:
- `interaction-qwen235b-decode-c3-topo-mns-mbt-fixed-dash1-d8899c5-20260703T022514Z`
完整 8 点结果:
| Config | req/s/GPU | pass rate |
|---|---:|---:|
| `TP4 DP2 EP8 MNS64 MBT256` | `0.0535` | `1.0000` |
| `TP4 DP2 EP8 MNS64 MBT384` | `0.0535` | `0.9922` |
| `TP4 DP2 EP8 MNS128 MBT256` | `0.0590` | `0.9929` |
| `TP4 DP2 EP8 MNS128 MBT384` | `0.0590` | `0.9929` |
| `TP2 DP4 EP8 MNS64 MBT256` | `0.0590` | `0.9753` |
| `TP2 DP4 EP8 MNS64 MBT384` | `0.0535` | `0.9961` |
| `TP2 DP4 EP8 MNS128 MBT256` | `0.0590` | `0.9788` |
| `TP2 DP4 EP8 MNS128 MBT384` | `0.0590` | `0.9823` |
关键观察:
- `MBT 256 -> 384``TP4/DP2 + MNS64` 下没有收益;
- 同一个 `MBT 256 -> 384``TP2/DP4 + MNS64` 下反而下降约 `9.2%`
- `MNS 64 -> 128``TP4/DP2` 下提升约 `10.1%`
- 同一个 `MNS 64 -> 128``TP2/DP4 + MBT256` 下没有收益,但在 `TP2/DP4 + MBT384` 下恢复约 `10.1%`
这说明 runtime knobs 的作用不是单调独立的。`MBT` 是否有害取决于 topology 和 `MNS``MNS` 是否有用也取决于 topology 和 `MBT`
## 图 5Delta 形式的直接证据
![Delta summary](figures/knob-conditional-delta-summary.png)
这张图把上面的论证直接转成 `Delta_x(context)`
- C1 中,同样是 `MNS 8 -> 32`,收益从 `+8.7%``+90.3%` 不等;
- C3 中,同样是 `MBT 256 -> 384`,有的 context 是 `0%`,有的 context 是 `-9.2%`
- C3 中,同样是 `MNS 64 -> 128`,有的 context 是 `0%`,有的 context 是 `+10.1%`
这就是 conditional effect 的直接测量证据。
## C2 是边界案例,不是反例
C2 Qwen235B prefill tight SLO 的结果更弱:
- `TP4` family: `0.1067~0.1175 req/s/GPU`
- `TP8` family: `0.1727 req/s/GPU`
- 在测过的 `MNS={64,128}``MBT={8192,16384}` 网格里 runtime knobs 基本平。
这个 case 说明并不是每个 workload 都会在 runtime knobs 上表现出强 interaction。它的主要结论是 topology 主导:`TP8` 相比 `TP4``+47% req/s/GPU`
这对 paper framing 反而有用:我们的 claim 不应该是“所有 knobs 总是强耦合”,而应该是:
> Tuning system 不能预设 knobs 独立;它必须通过 measured response 判断当前 case 是 topology-dominant、runtime-interaction-dominant还是 flat/noisy。Harness 的作用是把这些 measured evidence 维护成 search context。
## 对 harness 设计的含义
这些图支持我们当前 framing
1. Harness 不应该只做单 knob local search。它需要保留 topology/runtime context并允许 joint or projected interventions。
2. Candidate generation 不能只说“把某个 knob 调大/调小”,而要说明这个 intervention 所依赖的 context。
3. Validator 不能只比较 raw request rate必须比较 SLO-feasible `request_rate_per_gpu`,并保存 negative evidence。
4. LLM/planner 的价值不应被描述成“猜一个更好的 knob 值”,而是基于 harness 提供的 measured context 去提出 plausible joint moves。
## 复现图
```bash
python3 scripts/plot_knob_conditional_effects.py
```
输出:
- `docs/harness-ablation/figures/knob-oat-counterexample-c1-qwen30b.png`
- `docs/harness-ablation/figures/knob-interaction-residual-c1-qwen30b.png`
- `docs/harness-ablation/figures/knob-conditional-c1-qwen30b-surface.png`
- `docs/harness-ablation/figures/knob-conditional-c3-qwen235b-decode-lines.png`
- `docs/harness-ablation/figures/knob-conditional-delta-summary.png`