Feature: fp16 builds for timesfm (3x to 12x faster than fp32) need an overflow guard for large normalized inputs

Abierto
#2,050 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
46/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python, pytorch, tensorflow

Línea de trabajo

Start with the TimesFM family build and network builder paths, then read families/timesfm/README.md and the FP8 study referenced in the issue. Trace where normalized inputs enter the input residual block and how precision is selected; the issue does not name specific source files or tests. Done means fp16 builds pass an overflow guard, all 200 sampled M4 daily series produce finite forecasts, and an fp16 end-to-end case covers the behavior while fp32 remains the default.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

enhancement

Request type: Improvement to existing behavior

Problem and use case

families/timesfm builds fp32 only (the family build rejects fp16, although the network builder has an fp16 path). fp32 with TF32 off is slow: on google/timesfm-2.0-500m-pytorch an fp16 engine is 3.2x to 3.5x faster at batch 1 and 11.5x to 12.4x faster at batch 32 (B200 / B300, TensorRT 11.4), with M4 hourly MASE 0.5859 against 0.5866 for fp32.

fp16 cannot simply be turned on: on 1 of 200 sampled M4 daily series the fp16 engine (the builder's fp16 path) returns non-finite forecasts. That series' input to the input residual block reaches 1.53e9 and its residual stream 8.96e8, past the fp16 maximum (65504) from layer 0 on. The fp32 engine and Hugging Face fp32 are finite on all 200 series. For comparison, the median per-series maximum on M4 daily is 32.4 (input) and 138 (residual); on M4 hourly the maximum over all series is 66.2 and 173. TimesFM normalizes each series by the mean and standard deviation of its first unpadded patch, so a nearly flat start can give very large normalized values (likely cause, not verified per series). fp32_layers cannot fix it, because the residual stream of every layer is out of range.

Proposed outcome

Accept precision=fp16 for timesfm with an overflow guard, for example scaling or clamping the normalized input before the input residual block (or keeping the input block and residual stream in fp32), so that all M4 series stay finite, with its own fp16 E2E case. fp32 stays the default.

Model and target details

google/timesfm-2.0-500m-pytorch @ dc2443792ce5516872b89b37cf1bc058c3bf0c10 (the family manifest model); TensorRT 11.4; B200 / B300.

fp32 (default) fp16 (builder path)
Time, batch 1, B200 / B300 6.94 / 6.64 ms 1.96 / 2.11 ms
Time, batch 32, B200 / B300 51.45 / 45.91 ms 4.17 / 3.98 ms
Plan size (B200) 1906 MiB 956 MiB
M4 hourly MASE (HF fp32 0.5866) 0.5866 0.5859
M4 daily series with non-finite forecast (of 200) 0 1

Alternatives considered

fp32_layers (does not help: every layer is out of range on that series). FP8 (measured in #2005, not shipped; it runs on fp16 activations and has the same non-finite series).

Additional context

Found during the FP8 study recorded in families/timesfm/README.md (#2005, "fp16 overflow found on the way").

Lenguaje dominante
Python
Estrellas
288
Forks
73
Merge medio
1 d 3 h
PR fusionados (30 d)
273

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de NVIDIA/TensorRT-Model-Connect

Todos los issues de NVIDIA/TensorRT-Model-Connect

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.