Adjust design around encoder_cudagraph_forward (#42288)
Signed-off-by: Weida Hong <wdhongtw@google.com>
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
|
||||
from collections.abc import Callable
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Any
|
||||
|
||||
import torch
|
||||
|
||||
@@ -40,11 +39,6 @@ class EncoderCudaGraphConfig:
|
||||
modalities: list[str]
|
||||
"""Supported modalities (e.g. ["image"])."""
|
||||
|
||||
input_key_by_modality: dict[str, str]
|
||||
"""Per-modality input tensor key mapping, e.g.
|
||||
{"image": "pixel_values", "video": "pixel_values_videos"}.
|
||||
"""
|
||||
|
||||
buffer_keys: list[str]
|
||||
"""Keys for the tensor buffers recorded into the CUDA graph.
|
||||
Before replay the manager zeros then slice-copies new data
|
||||
@@ -74,11 +68,7 @@ class EncoderCudaGraphCaptureInputs:
|
||||
Returned by ``prepare_encoder_cudagraph_capture_inputs()``.
|
||||
"""
|
||||
|
||||
mm_kwargs: dict[str, Any]
|
||||
"""Dummy forward inputs (model-specific keys).
|
||||
For Qwen3-VL this contains pixel_values and grid_thw."""
|
||||
|
||||
buffers: dict[str, torch.Tensor]
|
||||
values: dict[str, torch.Tensor]
|
||||
"""Precomputed tensor buffers that will be recorded into the
|
||||
CUDA graph. The manager stores references to these exact
|
||||
tensor objects and copies new data into them before each
|
||||
@@ -94,7 +84,7 @@ class EncoderCudaGraphReplayBuffers:
|
||||
Keys match ``EncoderCudaGraphConfig.buffer_keys``.
|
||||
"""
|
||||
|
||||
buffers: dict[str, torch.Tensor | None]
|
||||
values: dict[str, torch.Tensor | None]
|
||||
"""Data to copy into the captured buffers before replay.
|
||||
``None`` values leave the corresponding captured buffer
|
||||
unchanged."""
|
||||
|
||||
Reference in New Issue
Block a user