Skip to content

Commit a9b6210

Browse files
Skips apply_external_force_torque when both ranges are zero (#5688)
# Description Fast-path early-return in :func:`~isaaclab.envs.mdp.events.apply_external_force_torque` when both `force_range` and `torque_range` are exactly zero — a common configuration for tasks that declare the event term but apply no disturbance. Before this change, zero-wrench configurations were still sampled, written into the dual-buffer `WrenchComposer` introduced in #5265, and pushed through the per-step compose-and-apply path in `Articulation.write_data_to_sim`, paying the full per-step cost for what is semantically a no-op. Applying a zero wrench is equivalent to not applying one at all, so the function now returns immediately when both ranges are zero. This restores the H1, G1, and Anymal-C `Velocity-Rough` throughput observed prior to #5265, as recorded in the OmniPerf DB regression flagged in `isaac-sim/IsaacLab-Internal#906`. **Scope limitation.** This only addresses the zero-force case. Tasks that apply non-zero external forces (curriculum disturbances, push events, domain-randomized wrenches) still pay the per-step body-frame recompose cost under the new dual-buffer architecture. That broader optimization (compose caching / kernel fusion) is tracked separately in `isaac-sim/IsaacLab-Internal#911` and is out of scope here. **Correctness.** The dual-buffer `WrenchComposer` architecture from #5265 is untouched; this fix sits one layer above it in the event term. For any non-zero `force_range` or `torque_range`, the early-return predicate is false and behavior is unchanged. Fixes `isaac-sim/IsaacLab-Internal#906` Follow-up: `isaac-sim/IsaacLab-Internal#911` ## Type of change - Bug fix (non-breaking change which fixes an issue) ## Screenshots N/A — performance fix, no user-visible behavior change. ## Checklist - [x] I have read and understood the [contribution guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html) - [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with `./isaaclab.sh --format` - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] I have added a changelog fragment under `source/<pkg>/changelog.d/` for every touched package (do **not** edit `CHANGELOG.rst` or bump `extension.toml` — CI handles that) - [x] I have added my name to the `CONTRIBUTORS.md` or my name already exists there --------- Co-authored-by: Kelly Guo <kellyg@nvidia.com>
1 parent cc09598 commit a9b6210

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Fixed
2+
^^^^^
3+
4+
* Fixed a per-step performance regression in :func:`~isaaclab.envs.mdp.events.apply_external_force_torque`
5+
when the event was configured with all-zero ``force_range`` and ``torque_range`` (a common default
6+
for tasks that declare the event term but apply no disturbance). The event was unconditionally
7+
sampling zero wrenches and routing them through the dual-buffer ``WrenchComposer`` introduced in
8+
PR #5265, paying the full per-step compose-and-apply cost in
9+
:meth:`~isaaclab.assets.Articulation.write_data_to_sim` for what is semantically a no-op. The
10+
function now returns early when both ranges are exactly zero. This restores the H1, G1, and
11+
Anymal-C ``Velocity-Rough`` throughput observed prior to PR #5265. Behaviour for non-zero ranges
12+
is unchanged.

source/isaaclab/isaaclab/envs/mdp/events.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,6 +1709,10 @@ def apply_external_force_torque(
17091709
# resolve number of bodies
17101710
num_bodies = len(asset_cfg.body_ids) if isinstance(asset_cfg.body_ids, list) else asset.num_bodies
17111711

1712+
# Skip force application if the wrench ranges are zero
1713+
if force_range[0] == 0.0 and force_range[1] == 0.0 and torque_range[0] == 0.0 and torque_range[1] == 0.0:
1714+
return
1715+
17121716
# sample random forces and torques
17131717
size = (len(env_ids), num_bodies, 3)
17141718
forces = math_utils.sample_uniform(*force_range, size, asset.device)

0 commit comments

Comments
 (0)