Repository navigation
Adds conditional Kit launch to benchmark scripts - #4815
Conversation
Benchmark scripts now capture the active preset string (e.g. "physx,ovrtx_renderer,rgb") and include it in the benchmark_info workflow_metadata. Sources checked in order: 1. CLI hydra arg: presets=physx,ovrtx_renderer,rgb 2. Env var: OMNIPERF_ISAACLAB_PRESET (used by Omniperf CI runner) 3. Fallback: "default" This allows the Omniperf dashboard and DB to distinguish runs made with different physics/renderer/data-type permutations. Made-with: Cursor
Moves the duplicated preset-capture logic from each benchmark script into get_preset_string() in scripts/benchmarks/utils.py. No behavior change — same 3 sources checked in the same order (CLI hydra arg, OMNIPERF_ISAACLAB_PRESET env var, "default" fallback). Made-with: Cursor
Greptile SummaryThis PR adds three improvements to the benchmark scripts: preset metadata is injected into the JSON output, Key issue:
The Kit-requiring path (default PhysX) and kitless-requiring changes are well-structured, and the conditional Kit launch logic is sound. However, the dead code and docstring inaccuracy present a maintainability risk as new renderer presets are added. Confidence Score: 3/5
Last reviewed commit: c87b2f5 |
| agent_cfg["params"]["seed"] += int(os.getenv("RANK", "0")) | ||
| agent_cfg["params"]["config"]["device"] = f"cuda:{int(os.getenv("LOCAL_RANK", "0"))}" | ||
| agent_cfg["params"]["config"]["device_name"] = f"cuda:{int(os.getenv("LOCAL_RANK", "0"))}" | ||
| agent_cfg["params"]["config"]["multi_gpu"] = True | ||
| # update env config device | ||
| env_cfg.sim.device = f"cuda:{app_launcher.local_rank}" | ||
| env_cfg.sim.device = f"cuda:{int(os.getenv("LOCAL_RANK", "0"))}" |
There was a problem hiding this comment.
SyntaxError: nested double-quotes inside double-quoted f-strings (multi-gpu block)
This block also has nested double-quote f-strings on lines 179, 180, and 183, which are SyntaxError in Python < 3.12:
| agent_cfg["params"]["seed"] += int(os.getenv("RANK", "0")) | |
| agent_cfg["params"]["config"]["device"] = f"cuda:{int(os.getenv("LOCAL_RANK", "0"))}" | |
| agent_cfg["params"]["config"]["device_name"] = f"cuda:{int(os.getenv("LOCAL_RANK", "0"))}" | |
| agent_cfg["params"]["config"]["multi_gpu"] = True | |
| # update env config device | |
| env_cfg.sim.device = f"cuda:{app_launcher.local_rank}" | |
| env_cfg.sim.device = f"cuda:{int(os.getenv("LOCAL_RANK", "0"))}" | |
| agent_cfg["params"]["seed"] += int(os.getenv("RANK", "0")) | |
| agent_cfg["params"]["config"]["device"] = f"cuda:{int(os.getenv('LOCAL_RANK', '0'))}" | |
| agent_cfg["params"]["config"]["device_name"] = f"cuda:{int(os.getenv('LOCAL_RANK', '0'))}" | |
| agent_cfg["params"]["config"]["multi_gpu"] = True | |
| # update env config device | |
| env_cfg.sim.device = f"cuda:{int(os.getenv('LOCAL_RANK', '0'))}" |
There was a problem hiding this comment.
Fix the nested quote syntax errors by using single quotes inside the f-strings:
| agent_cfg["params"]["seed"] += int(os.getenv("RANK", "0")) | |
| agent_cfg["params"]["config"]["device"] = f"cuda:{int(os.getenv("LOCAL_RANK", "0"))}" | |
| agent_cfg["params"]["config"]["device_name"] = f"cuda:{int(os.getenv("LOCAL_RANK", "0"))}" | |
| agent_cfg["params"]["config"]["multi_gpu"] = True | |
| # update env config device | |
| env_cfg.sim.device = f"cuda:{app_launcher.local_rank}" | |
| env_cfg.sim.device = f"cuda:{int(os.getenv("LOCAL_RANK", "0"))}" | |
| agent_cfg["params"]["seed"] += int(os.getenv("RANK", "0")) | |
| agent_cfg["params"]["config"]["device"] = f"cuda:{int(os.getenv('LOCAL_RANK', '0'))}" | |
| agent_cfg["params"]["config"]["device_name"] = f"cuda:{int(os.getenv('LOCAL_RANK', '0'))}" | |
| agent_cfg["params"]["config"]["multi_gpu"] = True | |
| # update env config device | |
| env_cfg.sim.device = f"cuda:{int(os.getenv('LOCAL_RANK', '0'))}" |
| env_cfg.sim.device = f"cuda:{int(os.getenv("LOCAL_RANK", "0"))}" | ||
| agent_cfg.device = f"cuda:{int(os.getenv("LOCAL_RANK", "0"))}" | ||
|
|
||
| # set seed to have diversity in different threads | ||
| seed = agent_cfg.seed + app_launcher.local_rank | ||
| seed = agent_cfg.seed + int(os.getenv("LOCAL_RANK", "0")) |
There was a problem hiding this comment.
SyntaxError: nested double-quotes inside double-quoted f-strings
Lines 158, 159, and 162 all use nested double-quote characters inside double-quoted f-strings, which is a SyntaxError in Python 3.10/3.11 (the project's target version). Compare with how the existing training scripts handle the same pattern — e.g., scripts/reinforcement_learning/rsl_rl/train.py correctly uses a temporary variable or single-quotes.
Fix by using single-quotes for the inner strings:
| env_cfg.sim.device = f"cuda:{int(os.getenv("LOCAL_RANK", "0"))}" | |
| agent_cfg.device = f"cuda:{int(os.getenv("LOCAL_RANK", "0"))}" | |
| # set seed to have diversity in different threads | |
| seed = agent_cfg.seed + app_launcher.local_rank | |
| seed = agent_cfg.seed + int(os.getenv("LOCAL_RANK", "0")) | |
| env_cfg.sim.device = f"cuda:{int(os.getenv('LOCAL_RANK', '0'))}" | |
| agent_cfg.device = f"cuda:{int(os.getenv('LOCAL_RANK', '0'))}" | |
| # set seed to have diversity in different threads | |
| seed = agent_cfg.seed + int(os.getenv('LOCAL_RANK', '0')) |
| from scripts.benchmarks.utils import get_preset_string | ||
|
|
||
| _needs_kit = "newton" not in get_preset_string(hydra_args).split(",") |
There was a problem hiding this comment.
Duplicate import of get_preset_string
get_preset_string is imported here at line 49 (before the AppLauncher decision), and then again at line 73 inside the regular bulk import block. Python silently ignores the duplicate, but removing it from one location would be cleaner. The same pattern appears in benchmark_rlgames.py (lines 49 and 96) and benchmark_rsl_rl.py (lines 55 and 95).
Since the early import is intentionally placed before the Kit-launch gate, the simplest fix is to remove get_preset_string from the later from scripts.benchmarks.utils import (...) block in each file.
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Signed-off-by: preeves-nv <[email protected]>
Addresses review from @bareya: the env var should not be Omniperf-specific. Renamed from OMNIPERF_ISAACLAB_PRESET to ISAACLAB_BENCHMARK_PRESET. Omniperf CI runners should update to set the new env var name. Made-with: Cursor
| # Preset names that indicate kitless physics (no Kit/AppLauncher required). | ||
| # The renderer must also be kitless for the full pipeline to skip Kit. | ||
| KITLESS_PHYSICS_PRESETS = {"newton"} | ||
| KITLESS_RENDERER_PRESETS = {"newton_renderer"} | ||
| KIT_RENDERER_PRESETS = {"ovrtx_renderer"} | ||
|
|
||
|
|
||
| def needs_kit(hydra_args: list[str]) -> bool: | ||
| """Return True if the active presets require Kit (AppLauncher). | ||
|
|
||
| Kit is skipped only when BOTH the physics backend AND renderer (if | ||
| specified) are kitless. When no renderer preset is given the default | ||
| renderer is assumed, which requires Kit. | ||
| """ | ||
| active = set(get_preset_string(hydra_args).split(",")) | ||
| has_kitless_physics = bool(active & KITLESS_PHYSICS_PRESETS) | ||
| has_kit_renderer = bool(active & KIT_RENDERER_PRESETS) | ||
| if not has_kitless_physics: | ||
| return True | ||
| if has_kit_renderer: | ||
| return True | ||
| return False |
There was a problem hiding this comment.
KITLESS_RENDERER_PRESETS is defined but never used in the needs_kit() function, making it dead code. The function only checks KIT_RENDERER_PRESETS, meaning any renderer not explicitly listed in KIT_RENDERER_PRESETS is assumed to be kitless. This allowlist-of-kits approach could silently skip Kit for a future renderer that actually requires it.
Additionally, the docstring states "When no renderer preset is given the default renderer is assumed, which requires Kit," but the code returns False (Kit NOT required) for presets=newton with no renderer. The PR description confirms this is intentional—Kit should be skipped for kitless physics with no renderer specified.
Recommendation:
Either:
- Remove
KITLESS_RENDERER_PRESETSand update the docstring to clarify that renderers require Kit only if explicitly listed inKIT_RENDERER_PRESETS, OR - Switch to a safe-by-default allowlist approach where the function checks that any renderer present is in
KITLESS_RENDERER_PRESETS:
def needs_kit(hydra_args: list[str]) -> bool:
"""Return True if the active presets require Kit (AppLauncher).
Kit is required unless the physics backend is kitless AND every renderer
preset in the active set is explicitly listed in KITLESS_RENDERER_PRESETS
(or no renderer preset is given).
"""
active = set(get_preset_string(hydra_args).split(","))
has_kitless_physics = bool(active & KITLESS_PHYSICS_PRESETS)
if not has_kitless_physics:
return True
renderer_presets = active & (KITLESS_RENDERER_PRESETS | KIT_RENDERER_PRESETS)
if renderer_presets - KITLESS_RENDERER_PRESETS: # any non-kitless renderer present
return True
return FalseUpdate the docstring accordingly to match your chosen approach.
…resets When presets=newton is passed, benchmark scripts now skip AppLauncher and set simulation_app=None, avoiding unnecessary Kit loading. This is the minimal fix for the issue Soowan reported where benchmark scripts (unlike training scripts) always loaded Kit even with Newton presets. Guards added: simulation_app.is_running(), simulation_app.close(), and distributed training now uses LOCAL_RANK/RANK env vars instead of app_launcher properties. NOTE: This is a minimal targeted fix. A fuller refactor to use launch_simulation() (as training scripts do) is recommended as a follow-up. Also, Newton presets will still crash on the separate SolverMuJoCo.get_max_contact_count() bug — that is a Newton team fix. Made-with: Cursor
Replaces inline "newton" string check in each benchmark script with a shared needs_kit() function in utils.py. The function considers both physics and renderer presets, so combinations like presets=newton,ovrtx_renderer correctly require Kit while presets=newton alone skips it. New presets only need to be added to the KITLESS_PHYSICS_PRESETS or KIT_RENDERER_PRESETS sets in one place. Made-with: Cursor
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Signed-off-by: preeves-nv <[email protected]>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Signed-off-by: preeves-nv <[email protected]>
Pre-commit CI requires Python 3.10 compat where f-strings cannot reuse the outer quote character. Switches inner os.getenv() calls from double to single quotes inside double-quoted f-strings. Made-with: Cursor
c87b2f5 to
a30e0aa
Compare
Signed-off-by: Kelly Guo <[email protected]>
Description
Summary
Three improvements to benchmark scripts for rendering permutation testing:
Preset metadata in JSON output — injects the active
presetsstring (from CLI orISAACLAB_BENCHMARK_PRESETenv var) into thebenchmark_infophase of the output JSON, enabling dashboards to distinguish runs by preset combination.Conditional Kit launch for kitless presets — benchmark scripts now skip
AppLauncherwhen the preset combination is fully kitless (e.g.presets=newton), matching the behavior of training scripts. Guards added forsimulation_app.is_running(),.close(), and distributed rank lookups.Centralized
needs_kit()utility — replaces per-script inline"newton"string checks with a sharedneeds_kit()function inscripts/benchmarks/utils.py. The function considers both physics and renderer presets, sopresets=newton,ovrtx_renderercorrectly requires Kit whilepresets=newtonalone skips it. New kitless backends only need to be added toKITLESS_PHYSICS_PRESETSorKIT_RENDERER_PRESETSsets in one place.Migration note for external runners
The environment variable for passing presets has been renamed from
OMNIPERF_ISAACLAB_PRESETtoISAACLAB_BENCHMARK_PRESET. Any CI runner or script that sets the old env var should update to use the new name:Context
Reported by Soowan Park in Slack: running
presets=newton,newton_renderer,rgbon benchmark scripts still loaded Kit (unlike training scripts), and the benchmark JSON output contained no preset information for dashboard ingestion.Known limitation
Newton presets will still crash due to a separate pre-existing bug:
SolverMuJoCois missing theget_max_contact_count()method thatnewton_manager.pyexpects. This is a Newton team fix, not addressed here.Recommended follow-ups
launch_simulation()context manager (as training scripts already do)Isaac-Cartpole-Camera-Presets-Direct-v0) require--enable_camerasflag — CI runners should pass this for camera tasksType of change
Test plan
presets: "default"needs_kit()returns correct results for all preset combinations (newton, newton+ovrtx_renderer, physx, default)Checklist
pre-commitchecks with./isaaclab.sh --format