Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 44 additions & 3 deletions .file_mapping.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"_source_commit": "2962eb13e76ad641803d5f498c2822555c88e79c-dirty",
"_dest_commit": "6c9d3916e0c5b62f8bed9694ae805d3d4c04c454",
"_generated_at": "2026-09-18T13:40:26Z",
"_source_commit": "4d9b6cfd3731fdbbca883184937d40a64d2dca52-dirty",
"_dest_commit": "c23e51f2f157ae3e51cfcd86ebfb5464850894f2",
"_generated_at": "2026-09-20T05:50:07Z",
"files": {
"imaginaire/__init__.py": "cosmos_framework/__init__.py",
"imaginaire/attention/__init__.py": "cosmos_framework/model/attention/__init__.py",
Expand Down Expand Up @@ -292,6 +292,20 @@
"projects/cosmos3/cosmos3/datasets/augmentors/cropping.py": "cosmos_framework/data/generator/augmentors/cropping.py",
"projects/cosmos3/cosmos3/datasets/augmentors/duration_fps_text_timestamps.py": "cosmos_framework/data/generator/augmentors/duration_fps_text_timestamps.py",
"projects/cosmos3/cosmos3/datasets/augmentors/duration_fps_text_timestamps_test.py": "cosmos_framework/data/generator/augmentors/duration_fps_text_timestamps_test.py",
"projects/cosmos3/cosmos3/datasets/augmentors/hr_lr_degradation/__init__.py": "cosmos_framework/data/generator/augmentors/hr_lr_degradation/__init__.py",
"projects/cosmos3/cosmos3/datasets/augmentors/hr_lr_degradation/augmentor.py": "cosmos_framework/data/generator/augmentors/hr_lr_degradation/augmentor.py",
"projects/cosmos3/cosmos3/datasets/augmentors/hr_lr_degradation/augmentor_test.py": "cosmos_framework/data/generator/augmentors/hr_lr_degradation/augmentor_test.py",
"projects/cosmos3/cosmos3/datasets/augmentors/hr_lr_degradation/bench.py": "cosmos_framework/data/generator/augmentors/hr_lr_degradation/bench.py",
"projects/cosmos3/cosmos3/datasets/augmentors/hr_lr_degradation/codec.py": "cosmos_framework/data/generator/augmentors/hr_lr_degradation/codec.py",
"projects/cosmos3/cosmos3/datasets/augmentors/hr_lr_degradation/contact_sheet.py": "cosmos_framework/data/generator/augmentors/hr_lr_degradation/contact_sheet.py",
"projects/cosmos3/cosmos3/datasets/augmentors/hr_lr_degradation/contact_sheet_test.py": "cosmos_framework/data/generator/augmentors/hr_lr_degradation/contact_sheet_test.py",
"projects/cosmos3/cosmos3/datasets/augmentors/hr_lr_degradation/degrade.py": "cosmos_framework/data/generator/augmentors/hr_lr_degradation/degrade.py",
"projects/cosmos3/cosmos3/datasets/augmentors/hr_lr_degradation/degrade_test.py": "cosmos_framework/data/generator/augmentors/hr_lr_degradation/degrade_test.py",
"projects/cosmos3/cosmos3/datasets/augmentors/hr_lr_degradation/diffjpeg.py": "cosmos_framework/data/generator/augmentors/hr_lr_degradation/diffjpeg.py",
"projects/cosmos3/cosmos3/datasets/augmentors/hr_lr_degradation/kernels.py": "cosmos_framework/data/generator/augmentors/hr_lr_degradation/kernels.py",
"projects/cosmos3/cosmos3/datasets/augmentors/hr_lr_degradation/ops.py": "cosmos_framework/data/generator/augmentors/hr_lr_degradation/ops.py",
"projects/cosmos3/cosmos3/datasets/augmentors/hr_lr_degradation/packing_test.py": "cosmos_framework/data/generator/augmentors/hr_lr_degradation/packing_test.py",
"projects/cosmos3/cosmos3/datasets/augmentors/hr_lr_degradation/profiles.py": "cosmos_framework/data/generator/augmentors/hr_lr_degradation/profiles.py",
"projects/cosmos3/cosmos3/datasets/augmentors/idle_frames_text_info.py": "cosmos_framework/data/generator/augmentors/idle_frames_text_info.py",
"projects/cosmos3/cosmos3/datasets/augmentors/image_editing_transform.py": "cosmos_framework/data/generator/augmentors/image_editing_transform.py",
"projects/cosmos3/cosmos3/datasets/augmentors/image_editing_transform_test.py": "cosmos_framework/data/generator/augmentors/image_editing_transform_test.py",
Expand Down Expand Up @@ -339,6 +353,7 @@
"projects/cosmos3/cosmos3/datasets/augmentors/transfer_control_input/seg.py": "cosmos_framework/data/generator/augmentors/transfer_control_input/seg.py",
"projects/cosmos3/cosmos3/datasets/augmentors/transfer_control_transform.py": "cosmos_framework/data/generator/augmentors/transfer_control_transform.py",
"projects/cosmos3/cosmos3/datasets/augmentors/transfer_control_transform_test.py": "cosmos_framework/data/generator/augmentors/transfer_control_transform_test.py",
"projects/cosmos3/cosmos3/datasets/augmentors/transfer_target_length_test.py": "cosmos_framework/data/generator/augmentors/transfer_target_length_test.py",
"projects/cosmos3/cosmos3/datasets/augmentors/video_editing_transform.py": "cosmos_framework/data/generator/augmentors/video_editing_transform.py",
"projects/cosmos3/cosmos3/datasets/augmentors/video_editing_transform_test.py": "cosmos_framework/data/generator/augmentors/video_editing_transform_test.py",
"projects/cosmos3/cosmos3/datasets/augmentors/video_parsing.py": "cosmos_framework/data/generator/augmentors/video_parsing.py",
Expand Down Expand Up @@ -371,6 +386,8 @@
"projects/cosmos3/cosmos3/models/mot/__init__.py": "cosmos_framework/model/generator/mot/__init__.py",
"projects/cosmos3/cosmos3/models/mot/action_io_projector.py": "cosmos_framework/model/generator/mot/action_io_projector.py",
"projects/cosmos3/cosmos3/models/mot/action_io_projector_test.py": "cosmos_framework/model/generator/mot/action_io_projector_test.py",
"projects/cosmos3/cosmos3/models/mot/activation_marks.py": "cosmos_framework/model/generator/mot/activation_marks.py",
"projects/cosmos3/cosmos3/models/mot/activation_marks_test.py": "cosmos_framework/model/generator/mot/activation_marks_test.py",
"projects/cosmos3/cosmos3/models/mot/attention.py": "cosmos_framework/model/generator/mot/attention.py",
"projects/cosmos3/cosmos3/models/mot/attention_test.py": "cosmos_framework/model/generator/mot/attention_test.py",
"projects/cosmos3/cosmos3/models/mot/cfgp_ar_test.py": "cosmos_framework/model/generator/mot/cfgp_ar_test.py",
Expand Down Expand Up @@ -460,12 +477,15 @@
"projects/cosmos3/cosmos3/models/reasoner/qwen3_vl_moe/shared_expert_test.py": "cosmos_framework/model/generator/reasoner/qwen3_vl_moe/shared_expert_test.py",
"projects/cosmos3/cosmos3/models/utils/__init__.py": "cosmos_framework/model/generator/utils/__init__.py",
"projects/cosmos3/cosmos3/models/utils/data_and_condition.py": "cosmos_framework/model/generator/utils/data_and_condition.py",
"projects/cosmos3/cosmos3/models/utils/data_and_condition_test.py": "cosmos_framework/model/generator/utils/data_and_condition_test.py",
"projects/cosmos3/cosmos3/models/utils/load_balancing_stats.py": "cosmos_framework/model/generator/utils/load_balancing_stats.py",
"projects/cosmos3/cosmos3/models/utils/memory.py": "cosmos_framework/model/generator/utils/memory.py",
"projects/cosmos3/cosmos3/models/utils/moe_utils.py": "cosmos_framework/model/generator/utils/moe_utils.py",
"projects/cosmos3/cosmos3/models/utils/safetensors_loader.py": "cosmos_framework/model/generator/utils/safetensors_loader.py",
"projects/cosmos3/cosmos3/models/utils/safetensors_loader_indexed_test.py": "cosmos_framework/model/generator/utils/safetensors_loader_indexed_test.py",
"projects/cosmos3/cosmos3/models/utils/safetensors_loader_test.py": "cosmos_framework/model/generator/utils/safetensors_loader_test.py",
"projects/cosmos3/cosmos3/models/utils/sr_latent_noise.py": "cosmos_framework/model/generator/utils/sr_latent_noise.py",
"projects/cosmos3/cosmos3/models/utils/sr_latent_noise_test.py": "cosmos_framework/model/generator/utils/sr_latent_noise_test.py",
"projects/cosmos3/cosmos3/models/vision_encoder.py": "cosmos_framework/model/generator/vision_encoder.py",
"projects/cosmos3/cosmos3/models/vlm_model.py": "cosmos_framework/model/generator/vlm_model.py",
"projects/cosmos3/cosmos3/processors/__init__.py": "cosmos_framework/data/generator/processors/__init__.py",
Expand All @@ -492,6 +512,7 @@
"projects/cosmos3/cosmos3/sequence_packing/natten.py": "cosmos_framework/data/generator/sequence_packing/natten.py",
"projects/cosmos3/cosmos3/sequence_packing/packers.py": "cosmos_framework/data/generator/sequence_packing/packers.py",
"projects/cosmos3/cosmos3/sequence_packing/runtime.py": "cosmos_framework/data/generator/sequence_packing/runtime.py",
"projects/cosmos3/cosmos3/sequence_packing/runtime_test.py": "cosmos_framework/data/generator/sequence_packing/runtime_test.py",
"projects/cosmos3/cosmos3/sequence_packing/sequence.py": "cosmos_framework/data/generator/sequence_packing/sequence.py",
"projects/cosmos3/cosmos3/sequence_packing/temporal_causal.py": "cosmos_framework/data/generator/sequence_packing/temporal_causal.py",
"projects/cosmos3/cosmos3/tokenizers/audio/__init__.py": "cosmos_framework/model/generator/tokenizers/audio/__init__.py",
Expand Down Expand Up @@ -584,6 +605,26 @@
"projects/cosmos3/interactive/models/utils/nvfp4_test.py": "cosmos_framework/model/generator/utils/nvfp4_test.py",
"projects/cosmos3/interactive/sequence_packing.py": "cosmos_framework/data/generator/sequence_packing/autoregressive.py",
"projects/cosmos3/interactive/utils/data_batch.py": "cosmos_framework/utils/generator/data_batch.py",
"projects/cosmos3/tokenizer/lidar_tokenizer/__init__.py": "cosmos_framework/model/generator/tokenizers/lidar/__init__.py",
"projects/cosmos3/tokenizer/lidar_tokenizer/checkpoint.py": "cosmos_framework/model/generator/tokenizers/lidar/checkpoint.py",
"projects/cosmos3/tokenizer/lidar_tokenizer/checkpoint_test.py": "cosmos_framework/model/generator/tokenizers/lidar/checkpoint_test.py",
"projects/cosmos3/tokenizer/lidar_tokenizer/dtypes.py": "cosmos_framework/model/generator/tokenizers/lidar/dtypes.py",
"projects/cosmos3/tokenizer/lidar_tokenizer/dtypes_test.py": "cosmos_framework/model/generator/tokenizers/lidar/dtypes_test.py",
"projects/cosmos3/tokenizer/lidar_tokenizer/lidar_tokenizer_v1.py": "cosmos_framework/model/generator/tokenizers/lidar/lidar_tokenizer_v1.py",
"projects/cosmos3/tokenizer/lidar_tokenizer/network/__init__.py": "cosmos_framework/model/generator/tokenizers/lidar/network/__init__.py",
"projects/cosmos3/tokenizer/lidar_tokenizer/network/distributions.py": "cosmos_framework/model/generator/tokenizers/lidar/network/distributions.py",
"projects/cosmos3/tokenizer/lidar_tokenizer/network/encoding.py": "cosmos_framework/model/generator/tokenizers/lidar/network/encoding.py",
"projects/cosmos3/tokenizer/lidar_tokenizer/network/ops.py": "cosmos_framework/model/generator/tokenizers/lidar/network/ops.py",
"projects/cosmos3/tokenizer/lidar_tokenizer/network/rope3d.py": "cosmos_framework/model/generator/tokenizers/lidar/network/rope3d.py",
"projects/cosmos3/tokenizer/lidar_tokenizer/network/transformer_vae.py": "cosmos_framework/model/generator/tokenizers/lidar/network/transformer_vae.py",
"projects/cosmos3/tokenizer/lidar_tokenizer/normalization.py": "cosmos_framework/model/generator/tokenizers/lidar/normalization.py",
"projects/cosmos3/tokenizer/lidar_tokenizer/normalization_test.py": "cosmos_framework/model/generator/tokenizers/lidar/normalization_test.py",
"projects/cosmos3/tokenizer/lidar_tokenizer/paths.py": "cosmos_framework/model/generator/tokenizers/lidar/paths.py",
"projects/cosmos3/tokenizer/lidar_tokenizer/postprocessing.py": "cosmos_framework/model/generator/tokenizers/lidar/postprocessing.py",
"projects/cosmos3/tokenizer/lidar_tokenizer/postprocessing_test.py": "cosmos_framework/model/generator/tokenizers/lidar/postprocessing_test.py",
"projects/cosmos3/tokenizer/lidar_tokenizer/preprocessing.py": "cosmos_framework/model/generator/tokenizers/lidar/preprocessing.py",
"projects/cosmos3/tokenizer/lidar_tokenizer/range_projection.py": "cosmos_framework/model/generator/tokenizers/lidar/range_projection.py",
"projects/cosmos3/tokenizer/lidar_tokenizer/range_projection_test.py": "cosmos_framework/model/generator/tokenizers/lidar/range_projection_test.py",
"projects/cosmos3/tokenizer/uniae/checkpoint_identity.py": "cosmos_framework/model/tokenizer/checkpoint_identity.py",
"projects/cosmos3/tokenizer/uniae/checkpoint_io.py": "cosmos_framework/model/tokenizer/checkpoint_io.py",
"projects/cosmos3/tokenizer/uniae/evaluation/lpips_cache.py": "cosmos_framework/model/tokenizer/evaluation/lpips_cache.py",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@

import attrs

# The forward attention op of every backend the frontend can dispatch, by the name
# the checkpoint policy matches against.
#
# * natten: fmha_forward
# * flash2: _flash_attn_varlen_forward (varlen), _flash_attn_forward (dense)
# * flash3: _flash_attn_forward (dense, varlen)
#
# cuDNN is deliberately absent since it does not support varlen attention.
ATTENTION_FORWARD_OPS_REGEX = [
"fmha_forward",
"_flash_attn_varlen_forward",
"_flash_attn_forward",
]


@attrs.define(slots=False)
class ActivationCheckpointingConfig:
Expand Down Expand Up @@ -45,10 +59,34 @@ class ActivationCheckpointingConfig:

# Regex patterns for ops to save when using selective AC. Ignored if
# mode is "full" or "none".
#
# Defaults to attention on whichever backend the frontend picks, which is what
# every config asking for selective AC wants and is not what a name like "fmha"
# delivers: that covers NATTEN alone, and NATTEN is only the *selected* backend
# where the others refuse the call. On sm100 cuDNN and flash2 both reject varlen
# so NATTEN wins and "fmha" matches; on sm90 flash3 is ranked first and takes it,
# leaving nothing in the region named "fmha", so selective AC there kept nothing
# and silently recomputed every attention it was configured to save.
#
# Copied because attrs hands this list to the instance, and a config mutating it
# would edit the module constant for every other config in the process.
save_ops_regex: list[str] = attrs.field(
factory=lambda: ["fmha"],
factory=lambda: list(ATTENTION_FORWARD_OPS_REGEX),
)

# Narrow ``save_ops_regex`` to the call sites that asked to be kept.
#
# The regex matches dispatched op names, which cannot separate calls running
# the same kernel. The decomposed multiview attention runs four FMHA calls per
# layer worth very different amounts to keep -- the same-view fold is ~96% of
# forward attention time and ~94% of backward, the rest are cheap to recompute.
#
# With this on, a matching op is kept only where the model marked it with
# ``activation_marks.mark_next_activation``. The regex still says which ops are
# eligible; the mark says which of them are worth it. Off by default, which is
# the behaviour every existing config already has.
save_only_marked_ops: bool = False

# Stash and restore RNG state across recompute boundaries. Required for
# deterministic output vs. non-checkpointed passes; slower otherwise.
preserve_rng_state: bool = True
Expand Down
12 changes: 12 additions & 0 deletions cosmos_framework/configs/base/defaults/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ class CompileConfig:
# Whether to use CUDA graphs for faster inference. This option does not work during training.
use_cuda_graphs: bool = False

# Granularity of CUDA-graph capture for AR inference (only with ``enabled`` and
# ``use_cuda_graphs``). "block": every decoder block is compiled with
# ``torch.compile(mode="reduce-overhead")`` and replays its own CUDA-graph tree, so a
# forward still pays one graph launch per block plus the Python between blocks.
# "forward": blocks are compiled without CUDA-graph trees and the AR loop captures one
# explicit graph per whole forward (denoise / KV-refresh × CFG branch) on the
# static-shape KV path from cache index 1 onward.
cuda_graph_scope: Literal["block", "forward"] = attrs.field(
default="block",
validator=attrs.validators.in_({"block", "forward"}),
)

# AR-inference-specific behavior once the rolling KV window saturates.
# "default" uses the global compile settings for the entire generation.
# "static-compile" keeps the normal pre-saturation path, then uses dedicated
Expand Down
5 changes: 5 additions & 0 deletions cosmos_framework/configs/base/defaults/model_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from cosmos_framework.configs.base.defaults.reasoner import VLMConfig
from cosmos_framework.model.generator.mot.action_io_projector import ACTION_IO_PROJECTOR_TYPES
from cosmos_framework.model.generator.utils.load_balancing_stats import LBLConfig
from cosmos_framework.model.generator.utils.sr_latent_noise import SRLatentConditionNoiseConfig

# Mirrors ``cosmos3.common.args.AttentionIOLayout``. Defined locally on purpose: importing
# the ``cosmos3`` workspace package at module scope makes the whole cosmos3 config tree
Expand Down Expand Up @@ -351,6 +352,10 @@ class OmniMoTModelConfig:
sound_dim: int | None = None # Sound latent channel size (e.g., 64 for AVAE 48kHz)
sound_latent_fps: int = 25 # Sound tokenizer's latent rate (e.g., 48kHz / 1920 hop = 25 Hz)

# Super-resolution: Gaussian noise on the LR conditioning latent of SR samples during training (L1).
# None disables it. See cosmos_framework/model/generator/utils/sr_latent_noise.py.
sr_latent_condition_noise: SRLatentConditionNoiseConfig | None = None

# When False, removes bias from vae2llm, sound2llm, and the two Linear layers inside
# time_embedder. These biases seem to inject token-constant DC offsets that dominate
# the MoE router input and create prompt invariant routing. This is observed empirically
Expand Down
Loading
Loading