Files
obsidian/projects/auto-tuner/outline.md

422 lines
16 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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.

# Draft
挑战:
1. workload 的 benchmark 性能与线上的 gap如何最小化这一 gap从而让 offline benchmark 数据能够在指导线上的资源配置时最小化误差
2. 使用 AI tuner 时如何让 LLM 有一条清晰的优化目标,而不是随意的 propose config 也无法判断优劣
3. 如何尽量减少 evolve 时需要的 GPU 卡时,减少资源需求,避免 AI tuner 成本甚至大于人力成本
我们的机制:
1. workload 的抽象定义,需要能够用于解释说明为什么不同 workload 下不同 setup 的表现不同
2. 自动化的异构硬件资源池内的 config/model 调整方案
# 11. Related Work (结构建议:按“范式”而非按领域罗列)
**11.1 Inference autotuning**
- Black-box optimization for serving configs
- Model-based fast search (operation-level / database-driven)
**TODO:** insert concrete citations and differences
**11.2 Agentic tuning for training/storage/PFS**
- StorageXTuner / ASAP / STELLAR line
- Position: our novelty is inference-specific feasibility + verifiable loop + drift reuse
**11.3 Systems optimization methodology**
- measurement-driven tuning, adaptive control, safe exploration
---
# GPT
## 一、把问题抽象成“论文级别”的 Research Problem
在顶会视角里,这个问题不是“压测不准”,而是:
> 在**高度异构硬件 + 多模型混部 + 动态调度**的 LLM 推理集群中,
> 怎样在满足多级 SLOP95/P99 延迟)的前提下,**系统化地完成容量规划与资源编排**,同时让 offline benchmark 与 online 行为之间的误差可控?
可以总结出 **34 个核心挑战Challenges**,每个挑战都要能撑得起一个小机制:
### Challenge 1Workload 维度极高,传统 trace / benchmark 已经不够用了
* 传统 web/microservice workload请求大小 / CPU 时间分布 + 到达过程,维度很低。
* LLM workload 至少包括:
* prefill_tokens、decode_tokens 的长尾分布(甚至多峰);
* sampling 参数temperature, top_p, tools对计算路径和 latency 的影响;
* multi-turn conversation / tool-call 带来的 stateful pattern
* dynamic batching + KV cache 使得同一请求在不同系统状态下 cost 差异巨大。
* 离线压测往往用 **“单点分布 + 恒定并发”**,无法覆盖真实的高维空间。
**论文话术**
LLM inference workload is inherently *high-dimensional* and *stateful*, breaking the assumptions behind existing capacity planning and benchmarking techniques for web and microservice workloads.
---
### Challenge 2Multi-stage Pipeline & Scheduler 行为导致强状态依赖
* LLM 推理天然是 **两阶段**甚至多阶段:
* prefill矩阵大、吞吐友好
* decode矩阵小、step-by-step容易被 tail 拖垮)。
* dynamic batching / speculative decoding / MoE 激活 / KV cache 驱逐等行为,使得:
* 单个请求的 latency 并不是其“独立 cost”而是**队列状态 + 当前 batch 其他请求的函数**。
* offline 单请求 / 小批量 benchmark 很难反映真实 scheduler 行为。
**论文话术**
LLM inference systems are *queueing systems with complex stateful schedulers*. Per-request cost is a function of *system state* (batch composition, cache state, competing models), invalidating the independence assumptions used in prior capacity planning models.
---
### Challenge 3模型和硬件双重异构性能曲线高度非线性
* **模型异构**
* dense vs MoE vs MLAFP16 vs FP8/FP4不同架构Qwen, LLaMA, DeepSeek, GPT…
* 不同层数 / hidden size / experts 数,导致 compute / memory / bandwidth 比例完全不同。
* **硬件异构**
* A100 vs H100 vs L40S vs 4090 vs 国内卡SM 数、HBM 带宽、NVLink 拓扑各不相同;
* 部分硬件支持特定指令 / kernel比如 FP8/FP4、特定 GEMM kernel
* 传统 “QPS = f(硬件 FLOPS)” 一类的简单模型完全失效。
**论文话术**
Model and hardware heterogeneity yields highly non-linear and non-monotonic performance surfaces, making extrapolation from a small set of microbenchmarks fundamentally unreliable.
---
### Challenge 4多目标 & 反馈回路SLO、成本、干扰、稳定性
* 目标不再是“单纯最大吞吐”,而是:
* SLO不同租户/业务线、P95/P99
* 成本GPU 小时 / 能耗);
* 干扰与隔离hot model vs cold modelRL / search 等长 query 对其他服务的拖累)。
* 容量规划的结果会反过来改变系统行为:
* 调整 batch 大小 / 并发 / 混部方案,会改变 latency 和 cost
* 不同模型在同一节点上的 placement 会产生“不可线性叠加”的干扰。
**论文话术**
The system must solve a multi-objective optimization problem under closed-loop feedback: capacity decisions alter scheduler behavior and interference patterns, shifting the workload characteristics themselves.
---
### Challenge 5强非平稳non-stationaryoffline 结果迅速“过期”
* 模型会迭代kernel 会升级,量化策略会变;
* 业务 pattern 也会变(比如长上下文应用越来越多,工具调用变多等)。
* 一个月前测出来的 “最优配置” 可能已经不再优。
**论文话术**
LLM workloads and serving stacks are *non-stationary*: model upgrades, kernel changes, and evolving user patterns quickly invalidate static benchmark-based capacity plans.
---
## 二、如果当成 SOSP/OSDI 论文storyline 可以这样讲
一个典型的“系统 + 测量 + 机制”型 paper可以这样结构化
### 1. Introduction讲痛点 + 一组 killer numbers
* 现实背景:某大规模 LLM 服务平台xx 个模型、yy 种 GPU、每天 zz 亿 tokens
* 观测:当前行业普遍用 synthetic benchmark 做容量规划,导致:
* 为满足 tail latency SLO**平均 over-provision 3060% GPU**
* 但在复杂高峰场景下,仍然会出现 SLO violation。
* 提出论文目标:
> 我们要构建一个 **trace-driven、heterogeneity-aware、online-calibrated** 的容量规划与资源编排系统,将 offline benchmark 与 online 行为闭环起来。
最后给出 contributions bullet list比如
1. 第一个系统性测量 LLM inference offline benchmark vs online gap 的工作;
2. 一个 token-centric 的 workload 抽象与 trace 压缩方法;
3. 一个 heterogeneity-aware 的性能模型和容量规划器;
4. 一个在线校准 + shadow serving 的闭环控制框架;
5. 真实大规模部署xx 模型 yy 集群上,节省 zz% GPU 成本且保持 SLO。
---
### 2. Background & Motivation / Measurement Study
* 简要介绍现有 LLM serving stack例如 vLLM / TensorRT-LLM / internal stack
* pipelineprefill / decodedynamic batchingKV cache
* typical scheduler 行为。
* Measurement 部分:
* 对某些典型模型 M1…Mn在 A100/H100/4090 等上用行业常见压测方法fixed prompt, fixed concurrency测试
* 然后对比真实生产 trace 的表现:
* latency 分布差异;
* GPU 利用率差异;
* per-token cost 的状态依赖batch size / cache hit 等)。
* 这一节的目标是“打破读者的直觉”,让他们相信:
**传统 benchmark + naive 容量规划是 fundamentally flawed**
---
### 3. System Overview整体 architecture
画一个系统图,把你的方案抽象成 4 个逻辑组件:
1. **Trace Collector & Profiler**
从线上采集 token-level trace构建 token-centric workload profile。
2. **Trace Synthesizer & Replayer**
* 将高维 trace 压缩成少量 profile
* 支持生成 synthetic workload、重放真实 trace。
3. **Performance Model & Capacity Planner**
* 解析模型 + 校准点;
* 异构硬件 / 多模型资源分配。
4. **Online Calibrator & Shadow Serving**
* 线上 metric 对比预测,更新模型;
* 利用 shadow 流量验证新配置。
---
### 4. 关键“创新机制”可以怎么讲?
下面是可以写进论文、又不只是“工程 best practice”的那种机制
---
#### 机制 1Token-centric Workload Abstraction令牌中心工作负载抽象
**痛点对应**Challenge 1高维 workload
**思路**
* 提出一个“token-centric”的 trace 表示,把请求抽象为:
* prefill_token_trace每个时刻注入多少 prefill tokens
* decode_token_trace每个时刻系统需要生成多少 decode tokens
* 结合 arrival process把原本复杂的请求行为用“token 流量token flow”来建模。
**创新点可以讲**
* 提出一种**多粒度 trace 表示**
* conversation-level
* request-level
* token-bucket-level
* 并设计压缩算法,将实际数十亿条请求压缩成少量 profile同时保持对系统行为batching、队列长度的预测 精度。
**论文卖点**
从“request-centric”转向“token-centric”的 workload 抽象,显著提高了仿真的表达力和压缩率,是 LLM 特定的新的 workload 模型。
---
#### 机制 2State-aware Performance Model状态感知性能模型
**痛点对应**Challenge 2 & 3scheduler 状态依赖 + 异构)
**思路**
* 不用“全黑盒 curve fitting”也不用纯理论 queueing而是
* 把模型的 cost 分解成几个 operator 类别prefill matmul / decode matmul / MoE gating / KV read/write
* 用少量 microbench 估计每类 operator 在不同硬件上的 throughput
* 再通过**scheduler 的状态特征**batch_size、cache_hit_rate、active_experts组合出 per-request cost。
**更系统一点说**
$$
T_\text{req} \approx f(L_\text{prefill}, L_\text{decode}, B_\text{prefill}, B_\text{decode}, \text{cache\_stats}, \text{experts\_activated}, \text{hw\_features})
$$
`f` 做成:
* 一个参数化公式 + 少量校准项;
* 或者一个小模型(比如 GBDT/MLP输入是上述 feature输出是 per-request latency / tokens/s。
**论文卖点**
* 这是一个**state-aware、operator-aware、hardware-aware** 的统一模型;
* 能在很少的测量点下,对未测配置做 reasonably accurate 的预测;
* 能清楚解释“为什么这个 config 在 H100 上更好,但在 4090 上反而更差”。
---
#### 机制 3Heterogeneity-aware Capacity Planning异构感知的容量规划
**痛点对应**Challenge 3 & 4
**思路**
* 把每个 (model, hw, config) 抽象成一条“性能曲线”:
* 在不同 traffic level 下的 {tokens/s, P95 latency}
* 再把多模型、多硬件的组合,看成一个优化问题:
> 在预算 B或目标 tokens/s选择每种硬件上的实例数和每个模型的 config使
>
> * 所有 (model, traffic_class) 的 SLO 满足;
> * 总成本最低 / 利用率最高。
可以引入的技术点:
* 把性能曲线离散化成 piecewise-linear segments用 MILP / ILP 近似求解;
* 或者用 heuristicgreedy、local search但要有理论或实验解释“好在哪”。
**论文卖点**
* 这是一个针对 LLM inference 特化的 “multi-model, multi-hardware capacity planning” formulation
* 支持把不同模型视作**token 流**而非“QPS”更符合 LLM 的真实代价。
---
#### 机制 4Online Calibration with Safety Guardrails带安全边界的在线校准
**痛点对应**Challenge 5non-stationary
**思路**
* 运行时持续收集:
* per (model, hw, config) 的 measured latency / tokens/s
* 维护一个“预测 vs 实测”的误差估计,比如:
* 每个组合一个信心水平和 bias term
* 用类似 bandit / Bayesian update 的方式更新模型:
* 如果长期 under-predict预测太乐观 → 自动增加安全裕度;
* 如果长期 over-predict → 可以安全收紧资源。
**创新点可以讲**
* 不是简单手工加 20% buffer而是**自动学习每个组合的安全系数**
* 对高风险配置引入更严格的 conservative bound对老练稳定配置更激进。
**论文卖点**
* 提出一个 **confidence-aware capacity planner**,在线适配 non-stationary 的 LLM 堆栈;
* 实验中展现:在保证 SLO violation rate 不上升的前提下,把平均 GPU over-provision 从 X% 降到 Y%。
---
#### 机制 5Shadow Serving + Semantic-equivalent Replay影子服务 + 语义等价回放)
(如果你愿意把“功能正确性 + 性能”一起讲)
**痛点**:新模型 / 新 config 不仅要看性能,还要保证语义/答案质量不退化。
**思路**
* shadow 集群接收真实流量;
* 对于采样类任务(开放对话),做 semantic diffembedding / reward model
* 把“性能 / 质量 / 资源 cost”放在一起形成三维 tradeoff。
这块可以是 optional但如果你做了会让论文更“完整”——从系统工程到用户体验。
---
## 三、论文的“创新性定位”可以怎么说?
顶会 reviewer 会问:**这和现有的 LLM serving, autoscaling, capacity planning 工作有什么根本不同?**
你可以把创新性定位在三层:
1. **问题定义层**
* 从“QPS-capacity for microservices” 迁移到 “token-centric, stateful LLM inference capacity planning”
* 首次系统性刻画 offline benchmark vs real-world LLM workload 的巨大 gap。
2. **建模与抽象层**
* token-centric workload 模型;
* state-aware performance model
* heterogeneity-aware capacity planning formulation。
3. **系统与实践层**
* 在真实大规模集群落地xx GPUs, yy models
* 提供可观测的数据点(数十亿请求 trace、open-source 工具(如果能开源更好)。
---
## 四、如果你要落到具体 paper skeleton可以是这样中英文混合大纲
1. **Introduction**
* 背景LLM inference at scale
* 痛点 & measurement teaser
* Our approach & contributions
2. **Background & Motivation**
* LLM serving pipeline & scheduler
* Workload characteristics
* Why existing capacity planning breaks
3. **Measurement: The Gap between Offline Benchmarks and Production**
* Methodology (trace collection, baseline benchmarks)
* Key findings23 条最重要的 gap
* Design implications为后面机制买伏笔
4. **Token-centric Workload Abstraction**
* Trace modelconversation/request/token 三级)
* Compression & profile generation
* Accuracy vs size tradeoff
5. **State-aware Performance Modeling**
* Operator-level decomposition
* Hardware heterogeneity encoding
* Online calibration mechanism
6. **Heterogeneity-aware Capacity Planning**
* Optimization formulation
* Solving strategyMILP / heuristic
* Integration with workload forecaster
7. **Online Calibration and Shadow Serving**
* Confidence-aware model update
* Shadow evaluation pipeline
* Safety guardrails
8. **Implementation**
* Integration with existing LLM serving stack (vLLM/…)
* Engineering detailsoverhead, compatibility
9. **Evaluation**
* Micro-bench: modeling accuracy, calibration speed
* Cluster-level: GPU savings, SLO satisfaction, robustness
* Ablation: no calibration / no heterogeneity / no token-centric
10. **Related Work & Discussion**
11. **Conclusion**
---
如果你愿意,下一步我们可以更具体地“代写”两块:
* **Measurement 部分**:一起设计 34 个关键 finding包括可能的图比如“offline latency vs online latency”的散点图、“token-centric profile 压缩比 vs 误差”的图);
* **Design 部分**:把你已经有的 auto-tuner / vLLM 实验管线映射到上面的几个机制中,形成真正可落地的“系统 + 机制”叙事。