# PR #53839 完整报告

- 仓库：`vllm-project/vllm`
- 标题：[Doc] Add EXAONE-4.0-1.2B to batch invariance tested models
- 合并时间：2026-08-28 02:38
- 原文链接：http://prhub.com.cn/vllm-project/vllm/pull/53839

---

# PR 分析报告：为 batch invariance 文档新增 EXAONE 4.0 系列验证记录

## 执行摘要

本 PR 在 `docs/features/batch_invariance.md` 的已验证模型清单中新增 EXAONE 4.0 系列三个 checkpoint（1.2B、32B、4.0.1-32B），是 batch invariance 验证覆盖的首个 EXAONE 条目，也是首个带逐层混合滑动 / 全局注意力（`sliding_window_pattern: "LLLG"`）的模型。PR 本身只有 1 行文档改动，但验证过程揭示 32B checkpoint 在 FLEX_ATTENTION 后端下 `torch._dynamo` recompile 上限被击穿的问题，作者将其归因于混合注意力布局放大 flex_attention 特化数量，并计划单独跟踪。

## 功能与动机

- 响应 issue #27433（Batch Invariant Feature and Performance Optimization）的持续跟踪，扩展已验证模型矩阵。
- 评审者 yewentao256 在 review 中要求『Could you test this series of model instead of the specific one?』，作者据此从单一 1.2B 扩展到整个 EXAONE 4.0 系列。
- 这是文档列表上第一个混合滑动窗口 / 全注意力架构的模型，验证价值在于确认混合注意力下 FLASH_ATTN 与 TRITON_ATTN 后端的 batch invariance 依然成立。

## 实现拆解

1. **初始提交**：在 `docs/features/batch_invariance.md` 的已验证模型列表中加入 EXAONE-4.0-1.2B，依据是 RTX 4090（SM 8.9）上 19 项 `test_batch_invariance.py` 用例全部通过。
2. **扩展验证范围**：响应 review 意见后，作者在 H200 NVL（SM 9.0）上补充 EXAONE-4.0-32B 与 EXAONE-4.0.1-32B 验证，并更新文档。
3. **结果分层记录**：PR body 中清晰区分 FLASH_ATTN/TRITON_ATTN 全部通过、FLEX_ATTENTION 在 32B 上 5 项失败且失败发生在 `capture_model()` → `cudagraph_manager.capture()` → `flex_attention.py:forward` 的 engine 初始化阶段（`FailOnRecompileLimitHit`），而非确定性断言。
4. **收尾调整**：应用评审 suggestion（commit 0f897fa，含 Co-authored-by），最终 head 提交保留三个 checkpoint 完整名称并合并 main 解决冲突。
5. **合入流程**：yewentao256 触发 `/ci run`，CI 通过后审批合入。

本 PR 无源码、测试或配置改动；配套验证基于 `tests/v1/determinism/test_batch_invariance.py` 完成。

### 本次变更仅涉及文档列表，展示如下（新增行为最后一个模型条目）：

```markdown
Batch invariance has been tested and verified on the following models:

- **Phi series**: `microsoft/Phi-3.5-mini-instruct`
- **Granite 3.1 (MoE)**: `ibm-granite/granite-3.1-1b-a400m-instruct`, `ibm-granite/granite-3.1-3b-a800m-instruct`
- **Granite 3.1 (Dense)**: `ibm-granite/granite-3.1-2b-instruct`, `ibm-granite/granite-3.1-8b-instruct`
- **EXAONE 4.0 series**: `LGAI-EXAONE/EXAONE-4.0-1.2B`, `LGAI-EXAONE/EXAONE-4.0.1-32B`, `LGAI-EXAONE/EXAONE-4.0-32B`

Other models may also work, but these have been explicitly validated.

```

## 评论区精华

> yewentao256（评审）: "Could you test this series of model instead of the specific one?"

> 作者对 FLEX_ATTENTION 失败的归因："The extra mask configuration appears to multiply flex_attention specializations across CUDA-graph capture shapes, exceeding recompile_limit = 16." 并给出关键反证——`test_logprobs_without_batch_invariance_should_fail[FLEX_ATTENTION]`（设置 `VLLM_BATCH_INVARIANT=0`）同样失败，说明并非 batch invariance 引入的问题。

> 作者补充说明："It reproduces with batch invariance disabled... This does not appear to be a batch-invariance failure." 且 1.2B 在同一 commit 上通过全部 FLEX_ATTENTION 用例，排除构建回归。

## 风险与影响

- **文档与实测偏差**：文档声明系列已验证，但 32B 在 FLEX_ATTENTION 后端实际存在 5 项失败（engine 初始化崩溃），文档未加注该后端限制，用户启用 FLEX_ATTENTION 时可能产生预期落差。
- **验证时效性**：验证基于固定 commit（如 `17da48596`）与 CUDA 13.1 / torch 2.13.0+cu130 组合，版本漂移后结论可能失效。
- **编译层隐患**：`exaone4.py` 的混合注意力布局与 `flex_attention.py:54` 的 `recompile_limit = 16` 之间存在兼容性缺口，32B 捕获 35 个 CUDA-graph 尺寸即触发 `FailOnRecompileLimitHit`；随着 MRV2 与 torch.compile 默认化，该问题可能影响更多混合注意力模型。
- **积极影响**：为 EXAONE 4.0 系列在 FLASH_ATTN/TRITON_ATTN 下提供确定性基线，且验证方法（跨 GPU、跨后端、区分无关失败）为后续模型扩展提供了可复制模式。

## 关联脉络

- issue #27433 是 batch invariance 特性的总跟踪 issue，本 PR 是其『扩展已验证模型矩阵』的直接落地；同一功能线包含 #25603（基础框架）、#27839（文档化）、#27842（测试接入 CI，即 `test_batch_invariance.py`）。
- 近期主线 PR #53183（MRV2 默认启用）与本 PR 关注的确定性、CUDA graph 捕获路径存在潜在交集——MRV2 全面铺开可能改变 CUDA graph 捕获与 `torch._dynamo` 特化行为，值得在后续 FLEX_ATTENTION 修复中一并评估。
- 作者承诺单独提交 FLEX_ATTENTION 相关 issue，可关注其后续进展以确认 32B 在编译层的限制是否被系统性解决。