File size: 17,425 Bytes
d6b3397 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 | .. _testing_benchmarks:
Benchmarking Framework
======================
Isaac Lab provides a comprehensive benchmarking framework for measuring the performance
of simulations, training workflows, and system resources. The framework is designed to
work without depending on Isaac Sim's benchmark services, enabling standalone benchmarking
with pluggable output backends.
Overview
--------
The benchmarking framework consists of several key components:
.. code-block:: text
βββββββββββββββββββββββββββββββββββ
β BaseIsaacLabBenchmark β
β (benchmark_core.py) β
βββββββββββββββββ¬ββββββββββββββββββ
β
βββββββββββββΌββββββββββββ
β β β
βΌ βΌ βΌ
βββββββββ βββββββββββ ββββββββββββ
βPhases β βRecordersβ β Backends β
βββββββββ βββββββββββ ββββββββββββ
**Key Components:**
- **BaseIsaacLabBenchmark**: Main class for orchestrating benchmark execution
- **Measurements**: Data classes for recording metrics (timing, counts, statistics)
- **Metadata**: Data classes for recording context (hardware, versions, parameters)
- **TestPhase**: Container for organizing measurements into logical groups
- **Recorders**: System information collectors (CPU, GPU, memory, versions)
- **Backends**: Output formatters (JSON, Osmo, OmniPerf, Summary)
.. seealso::
For method-level micro-benchmarks that measure asset setter/writer and property
performance using mock interfaces (without running full simulations), see
:ref:`testing_micro_benchmarks`.
Quick Start
-----------
Basic usage with :class:`~isaaclab.test.benchmark.BaseIsaacLabBenchmark`:
.. code-block:: python
from isaaclab.test.benchmark import (
BaseIsaacLabBenchmark,
SingleMeasurement,
StatisticalMeasurement,
StringMetadata,
)
# Initialize benchmark
benchmark = BaseIsaacLabBenchmark(
benchmark_name="MyBenchmark",
backend_type="json",
output_path="./results",
)
# Record measurements
benchmark.add_measurement(
phase_name="simulation",
measurement=SingleMeasurement(
name="fps",
value=1234.5,
unit="frames/sec"
),
)
benchmark.add_measurement(
phase_name="simulation",
measurement=StatisticalMeasurement(
name="step_time",
mean=0.82,
std=0.05,
n=1000,
unit="ms"
),
)
# Add metadata
benchmark.add_measurement(
phase_name="simulation",
metadata=StringMetadata(name="task", data="Isaac-Cartpole-v0"),
)
# Finalize and write output
benchmark._finalize_impl()
Running Benchmark Scripts
-------------------------
Isaac Lab provides shell scripts for running benchmark suites:
Non-RL Benchmarks
~~~~~~~~~~~~~~~~~
Measure environment stepping performance without training:
.. code-block:: bash
# Run all non-RL benchmarks
./scripts/benchmarks/run_non_rl_benchmarks.sh ./output_dir
# Run a single benchmark manually
./isaaclab.sh -p scripts/benchmarks/benchmark_non_rl.py \
--task Isaac-Cartpole-v0 \
--num_envs 4096 \
--num_frames 100 \
--benchmark_backend json \
--output_path ./results
RL Training Benchmarks
~~~~~~~~~~~~~~~~~~~~~~
Measure training performance with RSL-RL:
.. code-block:: bash
# Run training benchmarks
./scripts/benchmarks/run_training_benchmarks.sh ./output_dir
# Run manually with RSL-RL
./isaaclab.sh -p scripts/benchmarks/benchmark_rsl_rl.py \
--task Isaac-Cartpole-v0 \
--num_envs 4096 \
--max_iterations 500 \
--benchmark_backend json \
--output_path ./results
PhysX Micro-Benchmarks
~~~~~~~~~~~~~~~~~~~~~~
Measure asset method and property performance using mock interfaces:
.. code-block:: bash
# Run PhysX micro-benchmarks
./scripts/benchmarks/run_physx_benchmarks.sh ./output_dir
# Run articulation benchmarks manually
./isaaclab.sh -p source/isaaclab_physx/benchmark/assets/benchmark_articulation.py \
--num_iterations 1000 \
--num_instances 4096
For detailed documentation on micro-benchmarks, including available benchmark files,
input modes, and how to add new benchmarks, see :ref:`testing_micro_benchmarks`.
Startup Profiling Benchmark
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Profile the startup sequence of an IsaacLab environment using ``cProfile``. Each
startup stage is wrapped in its own profiling session and the top functions by
own-time are reported. This is useful for investigating startup regressions and
understanding where time is spent during initialization.
.. code-block:: bash
# Basic usage β reports top 30 functions per phase
./isaaclab.sh -p scripts/benchmarks/benchmark_startup.py \
--task Isaac-Ant-v0 \
--num_envs 4096 \
--benchmark_backend summary
The script profiles five phases independently:
- **app_launch**: ``launch_simulation()`` context entry (Kit/USD/PhysX init)
- **python_imports**: importing gymnasium, torch, isaaclab_tasks, etc.
- **task_config**: ``resolve_task_config()`` (Hydra config resolution)
- **env_creation**: ``gym.make()`` + ``env.reset()`` (scene creation, sim start)
- **first_step**: a single ``env.step()`` call
Each phase records a wall-clock time plus per-function own-time and cumulative
time as ``SingleMeasurement`` entries. Only IsaacLab functions and first-level
calls into external libraries are included (deep internals of torch, USD, etc.
are filtered out).
**Whitelist mode** β For dashboard time-series comparisons across runs, use a
YAML whitelist config to report a fixed set of functions instead of top-N.
Patterns use ``fnmatch`` syntax (``*`` and ``?`` wildcards):
.. code-block:: yaml
# Example whitelist config
app_launch:
- "isaaclab.utils.configclass:_custom_post_init"
- "isaaclab.sim.*:__init__"
env_creation:
- "isaaclab.cloner.*:usd_replicate"
- "isaaclab.cloner.*:filter_collisions"
- "isaaclab.scene.*:_init_scene"
first_step:
- "isaaclab.actuators.*:compute"
- "warp.*:launch"
.. code-block:: bash
./isaaclab.sh -p scripts/benchmarks/benchmark_startup.py \
--task Isaac-Ant-v0 \
--num_envs 4096 \
--benchmark_backend omniperf \
--whitelist_config scripts/benchmarks/startup_whitelist.yaml
Phases listed in the YAML use the whitelist; phases not listed fall back to
``--top_n`` (default: 5 in whitelist mode, 30 otherwise). Patterns that match
no profiled function emit ``0.0`` placeholders so the output always contains
the same keys.
A default whitelist is provided at ``scripts/benchmarks/startup_whitelist.yaml``.
.. list-table::
:header-rows: 1
:widths: 25 15 60
* - Argument
- Default
- Description
* - ``--task``
- required
- Environment task name
* - ``--num_envs``
- from config
- Number of parallel environments
* - ``--top_n``
- 30 (5 with whitelist)
- Max functions per non-whitelisted phase
* - ``--whitelist_config``
- None
- Path to YAML whitelist file
* - ``--benchmark_backend``
- ``omniperf``
- Output backend (``json``, ``osmo``, ``omniperf``, ``summary``)
* - ``--output_path``
- ``.``
- Directory for output files
Command Line Arguments
----------------------
Common Arguments
~~~~~~~~~~~~~~~~
.. list-table::
:header-rows: 1
:widths: 25 15 60
* - Argument
- Default
- Description
* - ``--benchmark_backend``
- ``json``
- Output backend: ``json``, ``osmo``, ``omniperf``, or ``summary``
* - ``--output_path``
- ``./``
- Directory for output files
Non-RL Benchmark Arguments
~~~~~~~~~~~~~~~~~~~~~~~~~~
.. list-table::
:header-rows: 1
:widths: 25 15 60
* - Argument
- Default
- Description
* - ``--task``
- required
- Environment task name (e.g., ``Isaac-Cartpole-v0``)
* - ``--num_envs``
- ``4096``
- Number of parallel environments
* - ``--num_frames``
- ``100``
- Number of simulation frames to run
* - ``--enable_cameras``
- ``false``
- Enable camera rendering (for RGB/depth tasks)
RL Training Arguments
~~~~~~~~~~~~~~~~~~~~~
.. list-table::
:header-rows: 1
:widths: 25 15 60
* - Argument
- Default
- Description
* - ``--task``
- required
- Environment task name
* - ``--num_envs``
- ``4096``
- Number of parallel environments
* - ``--max_iterations``
- ``500``
- Number of training iterations
Measurement Types
-----------------
The framework provides several measurement types for different data:
SingleMeasurement
~~~~~~~~~~~~~~~~~
For single numeric values:
.. code-block:: python
from isaaclab.test.benchmark import SingleMeasurement
measurement = SingleMeasurement(
name="total_frames",
value=100000,
unit="frames"
)
StatisticalMeasurement
~~~~~~~~~~~~~~~~~~~~~~
For statistical summaries:
.. code-block:: python
from isaaclab.test.benchmark import StatisticalMeasurement
measurement = StatisticalMeasurement(
name="step_time",
mean=0.82,
std=0.05,
n=1000,
unit="ms"
)
BooleanMeasurement
~~~~~~~~~~~~~~~~~~
For pass/fail status:
.. code-block:: python
from isaaclab.test.benchmark import BooleanMeasurement
measurement = BooleanMeasurement(
name="converged",
bvalue=True
)
DictMeasurement
~~~~~~~~~~~~~~~
For structured data:
.. code-block:: python
from isaaclab.test.benchmark import DictMeasurement
measurement = DictMeasurement(
name="config",
value={"learning_rate": 0.001, "batch_size": 64}
)
ListMeasurement
~~~~~~~~~~~~~~~
For sequences of values:
.. code-block:: python
from isaaclab.test.benchmark import ListMeasurement
measurement = ListMeasurement(
name="rewards_per_episode",
value=[100.5, 102.3, 98.7, 105.1]
)
Test Phases
-----------
:class:`~isaaclab.test.benchmark.TestPhase` organizes measurements and metadata
into logical groups. Common phases include:
- ``benchmark_info``: Workflow name, timestamp, configuration
- ``hardware_info``: CPU, GPU, memory information
- ``version_info``: Software versions (Isaac Sim, PyTorch, etc.)
- ``simulation``: Environment stepping metrics
- ``training``: RL training metrics
- ``runtime``: Execution time and resource usage
Example:
.. code-block:: python
# Measurements are automatically grouped by phase
benchmark.add_measurement("simulation", measurement=fps_measurement)
benchmark.add_measurement("simulation", metadata=task_metadata)
benchmark.add_measurement("training", measurement=reward_measurement)
Output Backends
---------------
JSON Backend
~~~~~~~~~~~~
Full output with all phases, measurements, and metadata:
.. code-block:: bash
./isaaclab.sh -p ... --benchmark_backend json --output_path ./results
Output structure:
.. code-block:: json
[
{
"phase_name": "simulation",
"measurements": [
{
"name": "MyBenchmark simulation fps",
"value": 1234.5,
"unit": "frames/sec",
"type": "single"
}
],
"metadata": [
{"name": "MyBenchmark simulation task", "data": "Isaac-Cartpole-v0", "type": "string"}
]
}
]
Osmo Backend
~~~~~~~~~~~~
Simplified key-value format for CI/CD integration:
.. code-block:: bash
./isaaclab.sh -p ... --benchmark_backend osmo --output_path ./results
Output structure:
.. code-block:: json
{
"workflow_name": "MyBenchmark",
"phase": "simulation",
"fps": 1234.5,
"task": "Isaac-Cartpole-v0"
}
OmniPerf Backend
~~~~~~~~~~~~~~~~
Format for database upload and performance tracking:
.. code-block:: bash
./isaaclab.sh -p ... --benchmark_backend omniperf --output_path ./results
Output structure:
.. code-block:: json
{
"simulation": {
"workflow_name": "MyBenchmark",
"fps": 1234.5,
"step_time_mean": 0.82,
"step_time_std": 0.05
}
}
Summary Backend
~~~~~~~~~~~~~~~
Human-readable console report plus JSON file. Prints a formatted summary to the
terminal while also writing the same data as JSON. Standard phases (runtime,
startup, train, frametime, system info) are rendered with specialized formatting;
any additional phases (e.g., from the startup profiling benchmark) are rendered
automatically with their ``SingleMeasurement`` and ``StatisticalMeasurement``
entries. Use when you want a quick readout without opening the JSON:
.. code-block:: bash
./isaaclab.sh -p ... --benchmark_backend summary --output_path ./results
When ``summary`` is selected, frametime recorders are enabled automatically when
running with Isaac Sim (Kit).
BenchmarkMonitor
----------------
:class:`~isaaclab.test.benchmark.BenchmarkMonitor` enables continuous system
monitoring during blocking operations like RL training loops:
.. code-block:: python
from isaaclab.test.benchmark import BaseIsaacLabBenchmark, BenchmarkMonitor
benchmark = BaseIsaacLabBenchmark(
benchmark_name="TrainingBenchmark",
backend_type="json",
output_path="./results",
)
# Monitor system resources during blocking training call
with BenchmarkMonitor(benchmark, interval=1.0):
runner.learn(num_learning_iterations=1000) # Blocking call
benchmark._finalize_impl()
The monitor runs in a background thread and periodically calls
``update_manual_recorders()`` to capture CPU, GPU, and memory usage samples.
System Recorders
----------------
The framework includes built-in recorders for system information:
CPUInfoRecorder
~~~~~~~~~~~~~~~
Captures CPU model, core count, and usage statistics.
GPUInfoRecorder
~~~~~~~~~~~~~~~
Captures GPU model, memory, and utilization via ``nvidia-smi``.
MemoryInfoRecorder
~~~~~~~~~~~~~~~~~~
Captures system and GPU memory usage over time.
VersionInfoRecorder
~~~~~~~~~~~~~~~~~~~
Captures software versions:
- Isaac Sim version
- Isaac Lab version
- PyTorch version
- CUDA version
- Python version
Creating Custom Benchmarks
--------------------------
Step 1: Initialize Benchmark
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: python
import argparse
from isaaclab.test.benchmark import BaseIsaacLabBenchmark
parser = argparse.ArgumentParser()
parser.add_argument("--benchmark_backend", default="json")
parser.add_argument("--output_path", default="./")
args = parser.parse_args()
benchmark = BaseIsaacLabBenchmark(
benchmark_name="CustomBenchmark",
backend_type=args.benchmark_backend,
output_path=args.output_path,
)
Step 2: Run Your Workload
~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: python
import time
start_time = time.time()
# Your workload here
for i in range(num_iterations):
env.step(actions)
elapsed = time.time() - start_time
Step 3: Record Measurements
~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: python
from isaaclab.test.benchmark import SingleMeasurement, StringMetadata
benchmark.add_measurement(
phase_name="runtime",
measurement=SingleMeasurement(
name="total_time",
value=elapsed,
unit="seconds"
),
)
benchmark.add_measurement(
phase_name="runtime",
metadata=StringMetadata(name="num_iterations", data=str(num_iterations)),
)
Step 4: Finalize
~~~~~~~~~~~~~~~~
.. code-block:: python
benchmark._finalize_impl()
Integration with CI/CD
----------------------
The shell scripts in ``scripts/benchmarks/`` are designed for CI/CD integration:
.. code-block:: bash
# GitHub Actions / GitLab CI example
- name: Run Benchmarks
run: |
./scripts/benchmarks/run_non_rl_benchmarks.sh ./benchmark_results
- name: Upload Results
uses: actions/upload-artifact@v3
with:
name: benchmark-results
path: ./benchmark_results/
For Osmo integration, use the ``osmo`` backend:
.. code-block:: bash
./scripts/benchmarks/run_non_rl_benchmarks.sh ./results
# Results are in Osmo-compatible JSON format
Troubleshooting
---------------
Import Errors
~~~~~~~~~~~~~
Ensure you're running through the Isaac Lab launcher:
.. code-block:: bash
./isaaclab.sh -p your_benchmark.py
Not:
.. code-block:: bash
python your_benchmark.py # Missing environment setup
Missing GPU Metrics
~~~~~~~~~~~~~~~~~~~
Verify ``nvidia-smi`` is available and CUDA is configured:
.. code-block:: bash
nvidia-smi # Should show GPU info
Empty Output Files
~~~~~~~~~~~~~~~~~~
Ensure ``_finalize_impl()`` is called before the script exits:
.. code-block:: python
try:
# Your benchmark code
pass
finally:
benchmark._finalize_impl()
Backend Not Recognized
~~~~~~~~~~~~~~~~~~~~~~
Valid backend types are: ``json``, ``osmo``, ``omniperf``, ``summary``
.. code-block:: bash
# Correct
--benchmark_backend json
# Incorrect
--benchmark_backend JSON # Case sensitive
|