Reduce per-step TorchSampler RNG staging work

Đang mở
#23,161 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python, pytorch

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
15.2k
Fork
3k
Merge trung bình
2 ngày 21 giờ
Pull request đã merge (30 ngày)
477

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của NVIDIA/TensorRT-LLM

Tất cả issue của NVIDIA/TensorRT-LLM

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.