Reduce per-step TorchSampler RNG staging work

Abierto
#23,161 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
45/100
Tipo de issue
Refactorización
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python, pytorch

Línea de trabajo

Start by reading TorchSampler._stage_fast_sampling_seeds and the internal seed manager; trace how persistent seed and offset buffers are filled during stage_in_graph_sampling and how eager sampling uses the allocating API. Compare the seeded and unseeded paths while preserving request-local streams, slot ownership, and padding semantics. Done means the live buffer prefix is prepared directly, host-only counters stay as Python integers, and the existing sampler and in-graph request-seed tests pass.

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

Descripción

Pytorch

Motivation

On main at 1df5c23d, the PyTorch backend's TorchSampler._stage_fast_sampling_seeds creates temporary device seed/offset tensors and then copies them to the graph sampler's persistent input buffers on each decode step.

A warmed CUDA trace of three calls to stage_in_graph_sampling followed by sample_in_graph replay shows:

  • Unseeded: six initialization kernels and six device-to-device copies for RNG metadata.
  • Seeded: six host-to-device copies followed by six device-to-device copies; host seed/offset preparation also reads and updates CPU tensor scalars for each row.

The persistent destination buffers already exist. Their live prefix can be filled directly without changing request-local streams, slot ownership, or padding semantics.

Proposed change

Let the internal seed manager optionally receive the destination seed/offset tensors. Fuse unseeded initialization into one kernel; copy seeded/mixed host values directly into the destination through named device_copy sites. Keep host-only counters as Python integers. Preserve the existing allocating API for eager sampling.

This follows the fixed-capacity sampling-input preparation used by DeepInfer, adapted to TensorRT-LLM's existing RNG and copy contracts. It complements #19719, #18437 and #21974; it does not change the penalty/embedding-bias paths in #21864 or #22638.

Validation

The implementation has been tested on one NVIDIA H20 using current-main sampler sources over the official 1.4.0rc5 runtime: 44 in-graph/request-seed tests, plus 271 sampler/greedy tests (131 architecture/feature skips), and actual HTTP streaming service comparisons with Qwen3.5-0.8B and Qwen3-4B. Seeded outputs match the baseline. The measured benefit is workload-dependent: sampler staging improves, smaller-model seeded concurrent serving benefits, and Qwen3-4B TPOT remains approximately unchanged. The linked implementation PR will include the configurations and results.

Lenguaje dominante
Python
Estrellas
15.2k
Forks
3k
Merge medio
2 d 21 h
PR fusionados (30 d)
477

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

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-LLM

Todos los issues de NVIDIA/TensorRT-LLM

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.