[Bug]: torch.ops.trtllm.flashinfer_silu_and_mul / flashinfer_gelu_tanh_and_mul: wrong values on strided slices

未关闭
#22,992 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@sylvesterkaczmarek 已经在做这个了。

开始于 2026年11月28日。

  • #23015 来自 @sylvesterkaczmarek —— 未关闭

评估

难度
3/5
预计耗时
1-2 天
新手友好度
66/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python, pytorch

调研方向

Start at the torch.ops.trtllm registrations for flashinfer_silu_and_mul and flashinfer_gelu_tanh_and_mul, then trace how they call the FlashInfer gated activation kernel. Reproduce with the provided strided slice and compare against x.contiguous() on CUDA. Done when both operators either return matching values for strided inputs or reject them explicitly before launch; add regression coverage for both dtypes and operators.

由索引模型根据 Issue 内容生成。

描述

Customized kernels
System Info
  • TensorRT-LLM: 1.3.0 (torch.ops.trtllm, upstream main checked @ 546c48139181)
  • GPU: NVIDIA H100 PCIe (80GB, SM90)
  • PyTorch / CUDA: 2.14.0+cu130 / CUDA 13.0 (driver 580.178.04)
  • OS / Python: Ubuntu 24.04 x86_64, Python 3.12
Reproduction
import torch
import tensorrt_llm  # registers torch.ops.trtllm

torch.manual_seed(0)
for fn in (torch.ops.trtllm.flashinfer_silu_and_mul, torch.ops.trtllm.flashinfer_gelu_tanh_and_mul):
    base = torch.full((4, 160), 77.0, device="cuda", dtype=torch.bfloat16)
    x = base[:, :128]
    x.copy_(torch.randn(4, 128, device="cuda", dtype=torch.bfloat16))
    y_strided = fn(x)
    y_contig = fn(x.contiguous())
    torch.cuda.synchronize()
    print(fn, "max_abs_diff:", (y_strided.float() - y_contig.float()).abs().max().item())
Expected behavior

Either honor x.stride(0) inside the activation wrapper/kernel or reject non-contiguous inputs with an explicit TORCH_CHECK(x.is_contiguous()) before kernel launch so y_strided never silently diverges from y_contig.

actual behavior

Both torch.ops.trtllm.flashinfer_silu_and_mul and torch.ops.trtllm.flashinfer_gelu_tanh_and_mul accept non-contiguous column-strided float16/bfloat16 slices (base[:, :128]) without error, read out-of-slice padding (77.0) into rows >= 1, and silently return wrong values on H100 SM90 (flashinfer_silu_and_mul: max_abs_diff = 154.531 in bfloat16, 203.658 in float16; flashinfer_gelu_tanh_and_mul: max_abs_diff = 149.875 in bfloat16, 172.184 in float16).

additional notes

The underlying FlashInfer gated activation kernel assumes packed row stride 2 * d from x.data_ptr() without checking x.is_contiguous(). Adding x = x.contiguous() or TORCH_CHECK(x.is_contiguous()) at the torch.ops.trtllm registration boundary prevents silent output corruption.

Before submitting a new issue...
  • Make sure you already searched for relevant issues, and checked the documentation and examples for answers to frequently asked questions.

Credit given to UCSB PLSE.

主要语言
Python
星标
15.2k
派生
3k
平均合并
2 天 21 小时
30 天内合并 PR
477

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

NVIDIA/TensorRT-LLM 的其他 Issue

查看 NVIDIA/TensorRT-LLM 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。