[Feature] ViT Full CUDA Graph (#35963)
Signed-off-by: Baorun Mu <bmu@nvidia.com>
This commit is contained in:
@@ -489,6 +489,28 @@ class CompilationConfig:
|
||||
on selected platforms. Disabled by default until more models
|
||||
are supported/tested to work."""
|
||||
|
||||
# Vision encoder CUDA graph
|
||||
cudagraph_mm_encoder: bool = False
|
||||
"""Enable CUDA graph capture for multimodal encoder (ViT).
|
||||
When enabled, captures full encoder forward as CUDA graph
|
||||
for each token budget level."""
|
||||
|
||||
encoder_cudagraph_token_budgets: list[int] = field(default_factory=list)
|
||||
"""Token budget levels for encoder CUDA graph capture.
|
||||
Each budget defines a fixed token capacity. At runtime, images are greedy-packed
|
||||
into the smallest fitting budget and the corresponding CUDA graph is replayed.
|
||||
If empty (default), auto-inferred from model architecture as power-of-2
|
||||
levels from the model's estimated min budget to max budget.
|
||||
User-provided values override auto-inference.
|
||||
Example: [2048, 4096, 8192, 13824]"""
|
||||
|
||||
encoder_cudagraph_max_images_per_batch: int = 0
|
||||
"""Maximum number of images per batch for encoder CUDA graph capture.
|
||||
Determines the fixed batch size used during graph capture.
|
||||
If 0 (default), auto-inferred as max_budget // min_budget from the
|
||||
model's budget range. User-provided positive value overrides
|
||||
auto-inference."""
|
||||
|
||||
# Inductor capture
|
||||
compile_sizes: list[int | str] | None = None
|
||||
"""Sizes to compile for inductor. In addition
|
||||
@@ -906,6 +928,16 @@ class CompilationConfig:
|
||||
f"Invalid backend for piecewise compilation: {self.backend}"
|
||||
)
|
||||
|
||||
# Validate encoder CUDA graph configuration
|
||||
if (
|
||||
self.cudagraph_mm_encoder
|
||||
and self.encoder_cudagraph_max_images_per_batch < 0
|
||||
):
|
||||
raise ValueError(
|
||||
"encoder_cudagraph_max_images_per_batch must be "
|
||||
"non-negative (0 = auto-infer)"
|
||||
)
|
||||
|
||||
if self.backend == "":
|
||||
self.backend = current_platform.get_compile_backend()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user