# PR #46792 完整报告

- 仓库：`vllm-project/vllm`
- 标题：[Hardware][AMD][CI] Fix AMD CI image build
- 合并时间：2026-06-26 13:05
- 原文链接：http://prhub.com.cn/vllm-project/vllm/pull/46792

---

# PR 46792 分析报告

## 执行摘要

PR #46792 修复了因 #46761 合并而导致的 AMD CI 镜像构建失败。问题在于 `layernorm_kernels.cu` 中引入了一个未使用的变量 `weight_row_off`，而 AMD CI 编译时启用了 `-Werror` 标志，将警告视为错误。本 PR 删除了这一行代码，恢复了构建。

## 功能与动机

PR body 明确指出：“This PR fixes the AMD CI image build, which was broken after https://github.com/vllm-project/vllm/pull/46761 because it left an unused variable in the layernorm kernels. On AMD CI, the vLLM wheel is compiled with `-Werror` and `-Wunused-variable`, so this led to a `csrc` compilation failure.” 目标是快速修复构建断裂，使 AMD CI 能够继续正常运行。

## 实现拆解

1. **定位问题**：在 `csrc/libtorch_stable/layernorm_kernels.cu` 文件中，`rms_norm_kernel` 函数内定义了一个变量 `int64_t weight_row_off = 0;`，该变量在后续代码中未被使用。
2. **修复**：删除该变量声明，仅此一行。
3. **验证**：AMD CI 镜像构建成功通过。

### `csrc/libtorch_stable/layernorm_kernels.cu`

包含变更的唯一文件；删除了导致 AMD CI 构建失败的未使用变量 `weight_row_off`。

```cu
// 文件 : csrc/libtorch_stable/layernorm_kernels.cu
// 变更 : 删除第 32 行的未使用变量 `weight_row_off`
// 该变量在 PR #46761 中被引入但未被使用，
// 导致 AMD CI 编译时因 -Werror 和 -Wunused-variable 而失败

__global__ void rms_norm_kernel(
    scalar_t* __restrict__ out,
    const scalar_t* __restrict__ input,
    const scalar_t* __restrict__ weight,
    const float epsilon,
    const int64_t num_rows,
    const int64_t num_cols,
    const int64_t input_stride_d2,
    const int64_t input_stride_d3,
    const int64_t output_stride_d2,
    const int64_t output_stride_d3) {

  float variance = 0.0f;
  const scalar_t* input_row;
  const scalar_t* weight_row;
  // 删除 : int64_t weight_row_off = 0;
  if constexpr (NUM_DIMS == 2) {
    input_row = input + blockIdx.x * input_stride_d2;
    weight_row = weight;
  }
  // ... 后续代码保持不变
}

```

## 评论区精华

无 review 评论或讨论。PR 获得两位 reviewer 批准，变更直接合并。

## 风险与影响

- **风险**：极低。仅删除未使用的变量，不影响程序逻辑。
- **影响**：仅影响 AMD CI 构建流程。修复后 AMD 平台可正常编译和测试。

## 关联脉络

本 PR 是对 PR #46761 的快速后续修复。#46761 融合了 DFlash 各层的 K-norm 为单次 kernel 调用，但在修改 `layernorm_kernels.cu` 时引入了一个未使用的变量。由于 AMD CI 使用更严格的编译标志，导致构建失败。这表明不同平台编译配置的差异可能暴露未在默认配置中发现的代码问题。