Spaces:
Running on L40S
Running on L40S
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | |
| # SPDX-License-Identifier: OpenMDW-1.1 | |
| """User-facing torch.compile knobs for VFM and VLM training paths.""" | |
| import attrs | |
| class CompileConfig: | |
| # Master torch.compile switch. When False, all other CompileConfig fields | |
| # are inert. | |
| enabled: bool = False | |
| # Whether the entire Cosmos3 VFM network is compiled, or only a specific region is compiled. | |
| # Use "language" to compile only individual layers in the MOT model. | |
| # Use "all" to compile the the MOT model, as well as encode/decode functions. | |
| compiled_region: str = attrs.field( | |
| default="language", | |
| validator=attrs.validators.in_({"all", "language"}), | |
| ) | |
| # Whether torch.compile should generate symbolic-shape (dynamic) kernels | |
| # (maps to ``torch.compile(dynamic=...)``). Defaults to True for training, | |
| # which sees varying shapes across batches (sequence length, CP sharding, ...); | |
| # specializing would recompile continuously. See ParallelismOverrides in | |
| # cosmos_framework/inference/common/args.py for the inference-side rationale | |
| # (where dynamic=False is preferred for stable AR shapes). | |
| compile_dynamic: bool = True | |
| # Whether to use CUDA graphs for faster inference. This option does not work during training. | |
| use_cuda_graphs: bool = False | |
| # Enable autotuning for pointwise/reduction Triton kernels (e.g. RMSNorm). | |
| # Explores 6 candidate configs instead of the default 1, improving kernel performance | |
| # at the cost of longer first-iteration compilation time. | |
| max_autotune_pointwise: bool = False | |
| # Enable coordinate descent tuning after autotuning. Starts from the best autotuned | |
| # config and explores nearby configs by adjusting one parameter at a time. | |
| # Requires max_autotune_pointwise=True to have effect on reduction kernels. | |
| coordinate_descent_tuning: bool = False | |