Skip to content

Adds conditional Kit launch to benchmark scripts - #4815

Merged
kellyguo11 merged 10 commits into
developfrom
feature/benchmark-kitless-launch
Mar 4, 2026
Merged

kellyguo11 merged 10 commits into
developfrom
feature/benchmark-kitless-launch

Conversation

@preeves-nv

@preeves-nv preeves-nv commented Mar 4, 2026 •

Copy link
Copy Markdown
Contributor

Description

Summary

Three improvements to benchmark scripts for rendering permutation testing:

  1. Preset metadata in JSON output — injects the active presets string (from CLI or ISAACLAB_BENCHMARK_PRESET env var) into the benchmark_info phase of the output JSON, enabling dashboards to distinguish runs by preset combination.

  2. Conditional Kit launch for kitless presets — benchmark scripts now skip AppLauncher when the preset combination is fully kitless (e.g. presets=newton), matching the behavior of training scripts. Guards added for simulation_app.is_running(), .close(), and distributed rank lookups.

  3. Centralized needs_kit() utility — replaces per-script inline "newton" string checks with a shared needs_kit() function in scripts/benchmarks/utils.py. The function considers both physics and renderer presets, so presets=newton,ovrtx_renderer correctly requires Kit while presets=newton alone skips it. New kitless backends only need to be added to KITLESS_PHYSICS_PRESETS or KIT_RENDERER_PRESETS sets in one place.

Migration note for external runners

The environment variable for passing presets has been renamed from OMNIPERF_ISAACLAB_PRESET to ISAACLAB_BENCHMARK_PRESET. Any CI runner or script that sets the old env var should update to use the new name:

- env["OMNIPERF_ISAACLAB_PRESET"] = "physx,ovrtx_renderer,rgb"
+ env["ISAACLAB_BENCHMARK_PRESET"] = "physx,ovrtx_renderer,rgb"

Context

Reported by Soowan Park in Slack: running presets=newton,newton_renderer,rgb on 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: SolverMuJoCo is missing the get_max_contact_count() method that newton_manager.py expects. This is a Newton team fix, not addressed here.

Recommended follow-ups

  • Full refactor of benchmark scripts to use launch_simulation() context manager (as training scripts already do)
  • Camera tasks (Isaac-Cartpole-Camera-Presets-Direct-v0) require --enable_cameras flag — CI runners should pass this for camera tasks
  • Camera tasks produce 5 extra GPU Frametime keys in JSON — may require DB schema consideration

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Test plan

  • PhysX default (no preset): Kit loads normally, benchmark completes, JSON written with presets: "default"
  • Newton preset: Kit skipped (cannot fully test due to Newton solver bug above)
  • needs_kit() returns correct results for all preset combinations (newton, newton+ovrtx_renderer, physx, default)

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

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
@github-actions github-actions Bot added enhancement New feature or request isaac-lab Related to Isaac Lab team labels Mar 4, 2026
@preeves-nv
preeves-nv marked this pull request as draft March 4, 2026 15:04
@preeves-nv preeves-nv self-assigned this Mar 4, 2026
@greptile-apps

greptile-apps Bot commented Mar 4, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds three improvements to the benchmark scripts: preset metadata is injected into the JSON output, AppLauncher/Kit is conditionally skipped for kitless presets (e.g. presets=newton), and a centralized needs_kit() utility in utils.py replaces per-script inline checks. The distributed-rank lookups are migrated from app_launcher.local_rank/global_rank to env vars (LOCAL_RANK, RANK, WORLD_SIZE), which is consistent with how the training scripts handle kitless distributed runs.

Key issue:

  • The KITLESS_RENDERER_PRESETS constant in utils.py is defined but never referenced inside needs_kit(), making it dead code. The function uses an optimistic allowlist approach (only Kit-requiring renderers are listed in KIT_RENDERER_PRESETS), which could cause Kit to be silently skipped for a future renderer that actually requires it. The needs_kit() docstring should also be updated to clarify the "no renderer" case, as it currently contradicts the code behavior (the code correctly skips Kit for presets=newton with no renderer, matching the PR description, but the docstring suggests Kit would be needed).

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

  • The PR is mostly safe for the default Kit path, but the KITLESS_RENDERER_PRESETS dead code and docstring inaccuracy in needs_kit() create a maintainability risk for future preset additions.
  • The conditional Kit launch logic is sound and correctly implements the PR requirements. The distributed rank migration to environment variables is consistent with training scripts. However, the needs_kit() function has a dead-code issue where KITLESS_RENDERER_PRESETS is defined but never checked, creating an optimistic allowlist that could silently skip Kit for a future renderer requiring it. Additionally, the docstring contradicts the code behavior (though the code itself is correct). These issues should be resolved before merging to prevent confusion and bugs as new presets are added. Pre-commit checks remain unchecked per the PR checklist.
  • scripts/benchmarks/utils.py — the needs_kit() function's renderer detection logic and docstring need attention before new renderer presets are added.

Last reviewed commit: c87b2f5

Comment thread scripts/benchmarks/benchmark_non_rl.py Resolved
Comment thread scripts/benchmarks/benchmark_rlgames.py Resolved
Comment thread scripts/benchmarks/benchmark_rlgames.py Outdated
Comment on lines +178 to +183
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"))}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Suggested change
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'))}"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the nested quote syntax errors by using single quotes inside the f-strings:

Suggested change
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'))}"

Comment thread scripts/benchmarks/benchmark_rsl_rl.py Outdated
Comment on lines +158 to +162
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"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Suggested change
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'))

Comment thread scripts/benchmarks/benchmark_non_rl.py Outdated
Comment on lines +49 to +51
from scripts.benchmarks.utils import get_preset_string

_needs_kit = "newton" not in get_preset_string(hydra_args).split(",")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@preeves-nv preeves-nv changed the title Feature/benchmark Adds conditional Kit launch to benchmark scripts for kitless Newton presets Adds preset metadata and conditional Kit launch to benchmark scripts Mar 4, 2026
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Signed-off-by: preeves-nv <[email protected]>
@preeves-nv preeves-nv changed the title Adds preset metadata and conditional Kit launch to benchmark scripts Adds conditional Kit launch to benchmark scripts Mar 4, 2026
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
@preeves-nv
preeves-nv marked this pull request as ready for review March 4, 2026 17:31
Comment on lines +112 to +133
# 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Remove KITLESS_RENDERER_PRESETS and update the docstring to clarify that renderers require Kit only if explicitly listed in KIT_RENDERER_PRESETS, OR
  2. 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 False

Update the docstring accordingly to match your chosen approach.

preeves-nv and others added 5 commits March 4, 2026 17:41
…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
@preeves-nv
preeves-nv force-pushed the feature/benchmark-kitless-launch branch from c87b2f5 to a30e0aa Compare March 4, 2026 17:41
@fatimaanes
fatimaanes self-requested a review March 4, 2026 18:23
@kellyguo11
kellyguo11 merged commit 94e2518 into develop Mar 4, 2026
5 checks passed
@kellyguo11
kellyguo11 deleted the feature/benchmark-kitless-launch branch March 4, 2026 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants