[Bug] [Relax] FLOAT16 quantize wraps positive INT16 saturation to -32768
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 45/100
Línea de trabajo
The payload names only the Relax relax.op.quantize call with float16 input and int16 output, plus the repro script. Run the snippet first to confirm the float16 path returns -32768 where the float32 path saturates to 32767. Then find where quantize's float-to-int16 clamp is lowered and check whether the clip bound is applied after float16 rounding. Done means both dtypes match the expected clipped output and the float32 assertion still passes.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Expected behavior
With scale 1 and zero point 0, quantizing finite positive values 65504 and 32768 to INT16 should saturate to 32767.
Actual behavior
Direct Relax execution returns:
FLOAT32: [32767, 32767, 32752, -32768]
FLOAT16: [-32768, -32768, 32752, -32768]
The inputs represent exactly the same finite values. The INT16 upper bound 32767 rounds up to 32768 in FLOAT16, so the final cast wraps instead of saturating. The FLOAT32 control matches the independent wide-domain clipping formula.
Environment
TVM 0.28.dev0 (local CPU build; build commit unavailable), LLVM 18.1.3, Python 3.12.3, NumPy 2.5.4, Linux x86_64.
Steps to reproduce
Run with python repro.py:
import numpy as np
import tvm
from tvm import relax
values = np.array([65504, 32768, 32752, -65504], dtype="float32")
expected = np.clip(np.rint(values.astype("float64")), -32768, 32767).astype("int16")
for dtype in ["float32", "float16"]:
x = relax.Var("x", relax.TensorType((4,), dtype))
builder = relax.BlockBuilder()
with builder.function("main", params=[x]):
result = builder.emit(relax.op.quantize(
x, relax.const(1, dtype), relax.const(0, "int16"), axis=0, out_dtype="int16"))
builder.emit_func_output(result)
vm = relax.VirtualMachine(relax.build(builder.get(), target="llvm"), tvm.cpu())
actual = vm["main"](tvm.runtime.tensor(values.astype(dtype))).numpy()
print(dtype, "expected", expected.tolist(), "actual", actual.tolist())
if dtype == "float32":
np.testing.assert_array_equal(actual, expected)
Triage
- needs-triage
- Lenguaje dominante
- Python
- Estrellas
- 13.9k
- Forks
- 4k
- Merge medio
- 8 h 6 min
- PR fusionados (30 d)
- 147
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de apache/tvm
-
needs-triage type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
needs-triage type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
Los mantenedores suelen responder en 1 día
-
[Bug] [Relax][ONNX] OneHot does not convert floating-point depth to int64Posiblemente ocupada @tandede la tomó hace 4 días. Abiertoneeds-triage type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
needs-triage type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
needs-triage type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
Todos los issues de apache/tvm
Issues similares
-
community enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
NVIDIA/auto-ontology#463 ·
Los mantenedores suelen responder en 1 día
-
Update Atari link on Gymnasium docs pagePosiblemente ocupada @qwist1233-cpu la tomó hoy. Abiertohelp wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Farama-Foundation/Gymnasium#1845 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 91/100
WingedGuardian/GENesis-AGI#4101 ·
Los mantenedores suelen responder en 1 día