Skip to content

[Fix] Cut ~4 s from the first articulation spawn by deferring the TorchScript converter import - #8762

Merged
ooctipus merged 2 commits into
isaac-sim:mainfrom
hujc7:jichuanh/nvbug6937746-lazy-ts2ep
Oct 22, 2026
Merged

ooctipus merged 2 commits into
isaac-sim:mainfrom
hujc7:jichuanh/nvbug6937746-lazy-ts2ep

Conversation

@hujc7

@hujc7 hujc7 commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • The first articulation spawn in a process is ~4 s faster: test_robot_load_performance[test_config0-cpu] (Cartpole, CPU, 15 s limit) drops from 11.5–11.9 s to 7.7–8.0 s.
  • torch._export.converter is now imported inside resave_checkpoint_with_metadata, its only user, instead of at module scope.

Description

#8381 added a module-level from torch._export.converter import TS2EPConverter to isaaclab/sim/schemas/schemas_actuators.py. PhysX actuator_control imports that module on every articulation spawn, and the converter import pulls in torch._dynamo, torch.export and sympy (~4.3 s). The cost lands on the first Articulation(cfg) in a process, which is the first-parametrized case of test_robot_load_performance. Since then, that case has failed intermittently on CI hosts, where it runs close to its 15 s limit (NVBug 6937746).

Only resave_checkpoint_with_metadata uses the converter, so the import moves there. Behaviour is unchanged.

Not addressed here: other one-time costs remain in the first spawn (isaaclab.actuators.newton import ~2.6 s, Warp CPU kernel compile on a cold cache).

Fixes NVBug 6937746

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Test plan

Kit PhysX, isaac-lab:latest-main image, desk (5 runs per arm):

Arm test_robot_load_performance[test_config0-cpu] Result
main 11.50–11.85 s 5/5 pass
this PR 7.73–7.98 s 5/5 pass
  • source/isaaclab/test/actuators/test_newton_adapter.py (exercises the converter path): 17/17 pass

Checklist

Docker and GPU tests run on demand. Push the commits you want tested, then
comment run-ci on the pull request.

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with uv run isaaclab --format
  • Documentation changes are not required because no documented API changed
  • My changes generate no new warnings
  • I have validated the changed behavior with focused coverage and applied the test-audit criteria to any test changes
  • I have added a changelog fragment under source/<pkg>/changelog.d/ for every touched package (do not edit CHANGELOG.rst or bump package versions — CI handles that)
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

hujc7 added 2 commits October 20, 2026 13:00
Importing torch._export.converter at module scope loads torch._dynamo on
every articulation spawn, adding ~4 s to the first load in a process and
pushing test_robot_load_performance[Cartpole-cpu] past its 15 s limit.
@hujc7

hujc7 commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator Author

run-ci

@github-actions github-actions Bot added bug Something isn't working isaac-lab Related to Isaac Lab team labels Oct 20, 2026
@isaaclab-bot isaaclab-bot Bot added ci:run-docker Trigger the on-demand Docker and GPU CI workflow and removed ci:run-docker Trigger the on-demand Docker and GPU CI workflow labels Oct 20, 2026
@hujc7
hujc7 marked this pull request as ready for review October 20, 2026 22:01
@hujc7
hujc7 requested a review from a team October 20, 2026 22:01
@hujc7

hujc7 commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator Author

run-ci

@isaaclab-bot isaaclab-bot Bot added ci:run-docker Trigger the on-demand Docker and GPU CI workflow and removed ci:run-docker Trigger the on-demand Docker and GPU CI workflow labels Oct 20, 2026

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

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.

Isaac Lab Review Bot

Needs attention: Style consistency (1). Other reviewed categories look good.

  • PR description: The body matches the diff and reports five runs per arm, but reproducibility requires exact revisions, command, hardware, environment count, and confirmation that each first-spawn sample used a fresh process.
  • Design and architecture: Architecture looks good.
  • Scope and over-engineering: No over-engineering issues.
  • API: API changes look good.
  • Compatibility and deprecation: No breaking changes identified.
  • Implementation: Implementation looks good.
  • Style consistency: The comment incorrectly describes a cached, once-per-process import cost as affecting every articulation spawn; state that it delays the first spawn instead.
  • Test quality: Test quality looks good.

Minor fixes needed. Posted 1 inline finding.

Automated review; human maintainers own approval decisions.

Returns:
Path to the temporary ``.pt2`` checkpoint.
"""
# Deferred: importing the converter loads torch._dynamo, which adds seconds to every articulation spawn.

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.

🟡 Warning · Style Consistency — Comment misstates import cost frequency

Module imports are cached, so the converter cost is paid once per process on the first articulation spawn, not on "every articulation spawn". Reword to match the changelog fragment and PR body.

@greptile-apps

greptile-apps Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change affects articulation startup and actuator checkpoint conversion.

The PR appears safe to merge, with a non-blocking correction to the import-cost comment.

Findings

  1. P2 Comment overstates repeated import costs ▶

Summary

Moves the TS2EPConverter import into resave_checkpoint_with_metadata.

  • Articulation startup avoids loading the converter until checkpoint conversion.

Reviews (1) · Last reviewed commit: "Merge remote-tracking branch 'upstream/m..." · Reviewed by Greptile

Returns:
Path to the temporary ``.pt2`` checkpoint.
"""
# Deferred: importing the converter loads torch._dynamo, which adds seconds to every articulation spawn.

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.

P2 Comment overstates repeated import costs

The comment says this import adds seconds to every articulation spawn, but Python caches the imported module. Only the first import in a process pays that cost. Change “every articulation spawn” to “the first articulation spawn” so future maintainers do not mistake a one-time startup cost for a repeated cost.

Suggested change
# Deferred: importing the converter loads torch._dynamo, which adds seconds to every articulation spawn.
# Deferred: importing the converter loads torch._dynamo, which adds seconds to the first articulation spawn.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@ooctipus
ooctipus merged commit 84b8df5 into isaac-sim:main Oct 22, 2026
78 of 93 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants