Repository navigation
Conversation
…tarts With identical observation, prompt, and fixed seed, Action policy server inference varied across OS process restarts because Wan2.2 VAE observation encoding (`WanVAE_` in `bfloat16`) ran under `cudnn.benchmark=True` and `cudnn.deterministic=False`, selecting nearly-tied convolution kernels with different bf16 reduction orders on first use per process. - Add tri-state `cudnn_deterministic: bool | None = None` to `SetupOverrides` / `SetupArgs` so non-policy inference preserves existing cuDNN autotuning by default (`None`), while explicit `True` / `False` configures both HF / frozen-config checkpoints (`Cosmos3OmniModel.from_pretrained_dcp`) and module-config DCP checkpoints (`OmniInference._create` -> `trainer.cudnn`). - Normalize bracketed `experiment_overrides` in `ConfigOverrides._build_config`, `CheckpointOverrides._build_checkpoint`, `OmniInference._create`, and the LIBERO/RoboCasa introspection fallback so module-config DCP setups accept the same bracketed CLI syntax as sample overrides. - Default `action_policy_server_robolab`, `action_policy_server_libero`, and `action_policy_server_robocasa` to `--cudnn-deterministic` (with `--no-cudnn-deterministic` opt-out), report the live post-load cuDNN flags in server logs/metadata, and document reproducibility flags in `docs/action_policy_droid_server.md`. - Add L0 CPU unit/Hydra tests and a 1-GPU cross-process `WanVAE_` determinism regression test. Fixes #448 Signed-off-by: Kane <153349620+kane-vln@users.noreply.github.com>
kane-vln
force-pushed
the
kane-vln/bug-policy-inference-isnt-reproducible-across-re
branch
from
December 4, 2026 12:18
6d9ce38 to
3fd5e4a
Compare
…cuDNN test Clarify in docs/action_policy_droid_server.md that because the policy server compiles with torch.compile by default, cross-restart action equality under --deterministic-seed also requires keeping a persistent TorchInductor cache (TORCHINDUCTOR_CACHE_DIR), whereas clearing or rebuilding the cache triggers fresh compiler autotuning. In test_policy_servers_report_effective_post_load_cudnn_flags, stub _get_device_memory_bytes alongside the mocked torch.cuda.is_available check so the L0 CPU test runs cleanly on GPU-less hosts without NVML or an NVIDIA driver, and replace function-scoped monkeypatch assignments on torch.backends.cudnn with direct assignments inside try/finally so fixture teardown cannot overwrite the restored process-wide cuDNN flags. Signed-off-by: Kane <153349620+kane-vln@users.noreply.github.com>
kane-vln
marked this pull request as ready for review
December 4, 2026 13:07
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #448
With identical observation, prompt, and fixed seed (
--seed 0 --deterministic-seed), Action policy server inference varied across OS process restarts because Wan2.2 VAE observation encoding (WanVAE_inbfloat16) ran withtorch.backends.cudnn.benchmark = Trueandtorch.backends.cudnn.deterministic = False. Timing noise on first convolution invocation per process picked between nearly-tied cuDNN algorithms with differentbfloat16reduction orders, perturbing the observation latent (vae2llminput) and amplifying across denoising steps into visible open-loop action chunk differences.Changes
cosmos_framework/inference/common/args.py,cosmos_framework/inference/model.py,cosmos_framework/inference/inference.py):cudnn_deterministic: bool | None = NonetoSetupOverrides/SetupArgs:Nonepreserves existing non-policy inference behavior (cudnn.deterministic=False, cudnn.benchmark=Trueon HF / frozen-config DCP, and unchangedtrainer.cudnnon module-config DCP).True/Falseconfigures bothCosmos3OmniModel.from_pretrained_dcp(..., cudnn_deterministic=...)and module-config DCPload_model_from_checkpoint(trainer.cudnn.deterministic/trainer.cudnn.benchmarkappended afterexperiment_overrides).experiment_overridesvia_normalize_dotlist_overrides(...)inConfigOverrides._build_config(),CheckpointOverrides._build_checkpoint(),OmniInference._create(), and the LIBERO/RoboCasa_load_introspection_config_dict()fallback.cosmos_framework/scripts/action_policy_server_{robolab,libero,robocasa}.py):cudnn_deterministic: bool = True(--cudnn-deterministic/--no-cudnn-deterministicvia Tyro) across all three Action policy server entrypoints.torch.backends.cudnn.{deterministic,benchmark}flags at startup (and in/infoon LIBERO/RoboCasa).--cudnn-deterministic/--no-cudnn-deterministicalongside--seed/--deterministic-seedand persistentTORCHINDUCTOR_CACHE_DIRcompiler-cache expectations indocs/action_policy_droid_server.md.cosmos_framework/inference/args_test.py,cosmos_framework/inference/model_test.py,cosmos_framework/scripts/action_policy_server_robolab_test.py) covering CLI flags, GPU-less host isolation, cuDNN flag restoration, HF / frozen-DCP / real Hydraaction_policy_droid_nanomodule-DCP override precedence, and bracketed overrides.WanVAE_(bfloat16) determinism regression test (cosmos_framework/scripts/action_policy_server_cudnn_gpu_test.py).Verification
ruff check&ruff format --checkon all touched Python files: passedrumdl check --fix&markdown-toc-creatorondocs/action_policy_droid_server.md: passedpython -m cosmos_framework.scripts.export_schemas: passedCOSMOS_TRAINING=0&COSMOS_TRAINING=1pytestacrossargs_test.py,model_test.py,video_guardrail_test.py,action_policy_server_robolab_test.py, and--num-gpus=0deselection ofaction_policy_server_cudnn_gpu_test.py: passedWanVAE_(bfloat16) determinism test:CUDA 13.0,cuDNN 9.20.0.48, 12 fresh processes before/after +pytest --levels=0 --num-gpus=1): 9/12 unique latent SHA-256 hashes underbenchmark=True(43.36 msavg) -> 1/12 unique SHA-256 hash across all 12 restarts underdeterministic=True, benchmark=False(44.01 msavg)CUDA 13.3,cuDNN 9.23.0, 4x GB200, Slurm Job3715710+ diagnostic Job3715521):Cosmos3-Nano-Policy-DROID, 3 fresh OS processes sharing persistentTORCHINDUCTOR_CACHE_DIR, defaultcudnn_deterministic=True,seed=0, deterministic_seed=True): post-loadcudnn_deterministic=True, cudnn_benchmark=False;[32, 8]float32action chunks bit-identical across all 3 restarts (np.array_equal,max_abs_diff = 0.0, SHA-2566b5884233d335a2ff31ad0b0b27367cc0439c06a7abb624f80dcbe846348b297;12.65svs13.24swith--no-cudnn-deterministic). Separate diagnostic harness runs withOmniSetupOverrides(..., use_torch_compile=False)also matched across fresh OS processes (max_abs_diff = 0.0, SHA-256f111b58efc312b88), and an in-processtorch.use_deterministic_algorithms(True, warn_only=True)diagnostic emitted zero nondeterministic op warnings.--cfg-parallelHF (Cosmos3-Nano-Policy-DROID, 2 freshtorchrun --nproc-per-node=2launches sharing persistentTORCHINDUCTOR_CACHE_DIR): post-loadcudnn_deterministic=True, cudnn_benchmark=Falseon both rank 0 and rank 1; cleanworker_loop()+shutdown_worker();[32, 8]float32action chunks bit-identical across both restarts (np.array_equal,max_abs_diff = 0.0, SHA-25690d1f2273faa368c1b5dda2bd493a2e4d0039d55ab9da08dd850984efd93ef7b).Cosmos3-Nano-dcp+experiment=action_policy_droid_nano+ bracketedexperiment_overrides, 2 fresh OS processes sharing persistentTORCHINDUCTOR_CACHE_DIR+ opt-out): defaultcudnn_deterministic=Trueverified both live and in savedconfig.yaml(trainer.cudnn: {deterministic: true, benchmark: false}),[32, 8]float32action chunks bit-identical across restarts (np.array_equal,max_abs_diff = 0.0, SHA-2565ad419a6e0400babbcfc9dbaeb2a6637c3db9c8b38ec644f6050ae5d8a065411);--no-cudnn-deterministicverified live and in savedconfig.yaml({deterministic: false, benchmark: true}).