Skip to content

Commit f80e196

Browse files
committed
Raise Warp's determinism mode instead of reading intent from its value
The previous guard skipped the request whenever warp.config.deterministic was not NOT_GUARANTEED, treating any non-default value as a deliberate choice. It cannot tell one from the other, and it left a configured gpu_to_gpu below the requested guarantee when something had already selected run_to_run. The modes are ordered by strength, so the request now only ever raises the setting: a stronger guarantee already in place is kept, a weaker one is upgraded.
1 parent 6a5fe32 commit f80e196

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

source/isaaclab_rl/isaaclab_rl/entrypoints/common.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -517,20 +517,23 @@ def request_warp_determinism(physics_cfg: Any) -> None:
517517
``warp.DeterministicMode`` members lowercased, so ``"gpu_to_gpu"`` selects
518518
``GPU_TO_GPU`` rather than being weakened to ``RUN_TO_RUN``. Warp reads the setting at module
519519
build time, so it must land before the first kernel launch; :func:`apply_env_overrides` runs
520-
before the environment is created. A mode already set on ``warp.config`` is left alone.
520+
before the environment is created.
521+
522+
The modes are ordered by strength, and this only ever raises the setting. Reading the current
523+
value cannot tell a deliberate choice from the shipped default, so rather than guess at intent
524+
it never weakens a guarantee already in place -- whoever set it, they wanted at least that much.
521525
522526
Args:
523527
physics_cfg: Resolved physics config, or ``None`` when the config tree carries none.
524528
"""
525529
import warp as wp
526530

527-
if wp.config.deterministic != wp.DeterministicMode.NOT_GUARANTEED:
528-
return
529531
requested = getattr(physics_cfg, "deterministic_mode", None)
530532
mode = getattr(wp.DeterministicMode, requested.upper(), None) if isinstance(requested, str) else None
531533
if mode is None or mode == wp.DeterministicMode.NOT_GUARANTEED:
532534
mode = wp.DeterministicMode.RUN_TO_RUN
533-
wp.config.deterministic = mode
535+
if wp.config.deterministic < mode:
536+
wp.config.deterministic = mode
534537

535538

536539
def validate_distributed_device(args_cli: argparse.Namespace) -> None:

source/isaaclab_rl/test/test_entrypoints_common.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,20 @@ def test_apply_env_overrides_keeps_an_explicit_warp_mode(monkeypatch: pytest.Mon
476476
assert wp.config.deterministic == wp.DeterministicMode.GPU_TO_GPU
477477

478478

479+
def test_apply_env_overrides_raises_an_already_weaker_warp_mode(monkeypatch: pytest.MonkeyPatch) -> None:
480+
"""A guarantee already in place is raised to the configured one, never left below it."""
481+
import warp as wp
482+
483+
monkeypatch.setattr(wp.config, "deterministic", wp.DeterministicMode.RUN_TO_RUN)
484+
physics = _fake_physics_cfg("NewtonCfg", deterministic_mode="gpu_to_gpu")
485+
env_cfg = SimpleNamespace(sim=SimpleNamespace(physics=physics))
486+
487+
args_cli = argparse.Namespace(num_envs=None, device=None, deterministic=True)
488+
_rl_common.apply_env_overrides(args_cli, env_cfg, apply_device=False)
489+
490+
assert wp.config.deterministic == wp.DeterministicMode.GPU_TO_GPU
491+
492+
479493
def test_apply_env_overrides_leaves_warp_alone_without_the_flag(monkeypatch: pytest.MonkeyPatch) -> None:
480494
"""Without ``--deterministic`` Warp keeps its default, so no run pays for determinism."""
481495
import warp as wp

0 commit comments

Comments
 (0)