Polygraphy INT32 comparison can overflow and falsely pass at zero tolerance

未关闭 适合新手
#4,916 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 6 天内回复

@0z5a 已经在做这个了。

开始于 2026年11月4日。

  • #4919 来自 @0z5a —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
numpy, python
领域
testing

调研方向

issue 提到了 Polygraphy 的 SimpleCompareFunc,并提供了仅使用 CPU 的复现步骤;请找到它的实现和现有的 comparator 测试。先以零容差运行复现步骤,然后为 INT32_MIN 与零的比较以及 INT32_MAX 与 INT32_MIN 的比较添加边界用例。当两项比较都以预期的非负差值失败,且相关测试通过时,即视为完成。

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

描述

Module:Polygraphy
Description

Polygraphy's simple comparator subtracts INT32 arrays in INT32, so differences can overflow before the absolute value is computed. In particular, the absolute value of the minimum INT32 remains negative and an incorrect output can be reported as matching even with zero tolerances.

Reproduction

On main at 16ed0636df41e4a27d46f82d9028fc50fadc7200:

import numpy as np
from polygraphy.comparator import IterationResult, SimpleCompareFunc

a = IterationResult(outputs={"out": np.array([-2147483648], dtype=np.int32)})
b = IterationResult(outputs={"out": np.array([0], dtype=np.int32)})
result = SimpleCompareFunc(rtol=0, atol=0)(a, b)["out"]
print(bool(result), result.max_absdiff)  # actual: True, -2147483648.0

The comparison should fail, with a nonnegative absolute difference of 2147483648. A second boundary pair, INT32_MAX versus INT32_MIN, should produce a difference of 4294967295 without wrapping. Reproduced on CPU using NumPy 2.5.4; no TensorRT engine or GPU is required.

主要语言
C++
星标
13.5k
派生
2.4k
平均合并
6 天 21 小时
30 天内合并 PR
3

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

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

NVIDIA/TensorRT 的其他 Issue

查看 NVIDIA/TensorRT 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

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