Include callable skill and live-GUI prerequisites, epoch sensor reads, packed snapshots, sampled bit-exact kinematics, and verified-tick rendering without changing the physical/control schedule. Record bounded analytic S1 GUI/headless qualification, original failures and CPU evidence (1557 passed, 6 skipped). Preserve accepted_skill=false and sub-real-time limitations. Exclude native authorities, caches, large media and local delivery copies; retain sealed artifact digest.
9.2 KiB
Read-only hot-path review
Review
- Correct: Every physics tick completes latch updates, safety checks and synchronous evidence capture before rendering or another physics step (
source/SkillFactory/SkillFactory/tasks/manager_based/contact_cycle_sim/evaluation_env.py:447–469). Preserve this ordering. - Correct: RuntimeHooks retains pre-step admission, counters, unique wrench ownership and reset/write guards (
evaluation_env.py:114–201). - Fixed: None; read-only review.
- No issues found.
- Merge verdict: OK with notes for the profiling approach—not approval of an optimized implementation or a performance claim.
Inspected the requested original source seams, observer/binding integration, and relevant CPU tests. No commands, tests, GPU operations or edits were performed. No performance-profile.json was available when checked; no measured hot-function ranking is claimed.
Below, task-module paths are relative to source/SkillFactory/SkillFactory/tasks/manager_based/.
Why a single leg can look slow
The implementation contains substantial serial CPU/GPU handshaking around small tensor workloads. Training throughput across many environments and single-environment GUI frame rate measure different things; aggregate training throughput does not establish single-leg interactive performance.
The environment requests rendering every 20 physics ticks. At 500 Hz simulation time, that is 25 render requests per simulated second, not necessarily 25 per wall second. Slow execution of those intervening physics/check/recording ticks also slows GUI updates without the renderer itself being the dominant cost.
These are code-supported explanations, not a measured attribution of the reported 2–3 FPS. Current evidence does not establish GPU utilization, rendering cost, or an achievable speedup. Maximizing useful execution speed also does not require—or guarantee—100% RTX5080 utilization for this small serial workload.
Evidenced optimization opportunities
| Location | Code evidence | Advice |
|---|---|---|
contact_cycle/recording.py:109–139; contact_cycle_sim/recording.py:14–26 |
Snapshot builds many tensor fields and independently executes detach().cpu().clone() for each. Simulation extras repeat this pattern. Some metadata is already CPU-resident. |
First candidate: pack GPU snapshot fields by exact dtype/device, copy each packed group synchronously once, then reconstruct the original CPU fields. Keep CPU metadata separate. |
contact_cycle_sim/evaluation_mdp.py:119–168 |
Safety retrieves failure flags to Python and converts numerous individual GPU predicates to Python booleans. It also recreates limit tensors each call. | Subsequently batch boolean predicate results into one synchronous CPU transfer. Preserve each predicate’s arithmetic, thresholds, cause ordering and overlapping causes. Cache immutable limit tensors per state instance. |
contact_cycle_sim/evaluation_env.py:325–332; evaluation_mdp.py:25–26, 86–104 |
Each event converts two reference vectors to CPU tuples; protocol-command construction reads GPU weight as a Python float. Reference/port-reference helpers repeatedly reconstruct commands and device tensors. | Secondary candidate only. Reuse read-only results within a precisely bounded snapshot/reference epoch; never cache merely by global tick. |
contact_cycle/recording.py:122; contact_cycle/mdp.py:261–275 |
Snapshot calls both failed() and failure_flags(); failed() recomputes the flags. |
Compute flags once within that snapshot and derive would_fail = flags.any(-1). Do not remove the separate safety gate. |
contact_cycle_sim/recording.py:22–23; contact_cycle_sim/mdp.py:106–113 |
Position and velocity cost helpers each compute both components through pose_cost. |
Reuse that read-only result inside the snapshot, retaining the original arithmetic and outputs. |
contact_cycle_sim/functional_flow_recording_v2.py:175–198 |
Every frame receives full finite, bounds, composition and identity checks; additional nominal CPU copying occurs during composition validation. | Retain every check. Consider instance-local immutable nominal CPU data only after equivalence qualification. |
contact_cycle_sim/skill_gui_v041.py:105–137 |
GUI updates run each control call, including GPU scalar reads for tick/contact. Other displayed physical values already come from CPU evidence. | Lower-priority opportunity: read matching tick/contact evidence from the same completed frame where available. Do not change render cadence or evidence frequency. |
Introspection: no established per-tick culprit
RuntimeHooks.isaac() enumerates methods during installation; guard setup and functools.wraps are not repeated discovery operations on every tick (evaluation_env.py:69–120, 161–201).
There is no explicit per-tick inspect.signature, inspect.stack or source inspection in the requested application hot paths. Installed Isaac code contains introspection elsewhere, but its existence does not establish active-loop cost. Do not remove provenance checks, bypass wrappers, or globally cache/patch introspection without a profile identifying the actual caller.
Lowest-risk first implementation
Implement a new bound packed recorder, leaving the original recorder and frozen physical/controller sources untouched.
- Construct the same snapshot values using the same GPU expressions.
- Flatten/group GPU tensors by exact dtype and device. Never cast counters, booleans or integer phase fields into floating-point storage.
- Perform synchronous device-to-host copies before the evidence callback returns.
- Reconstruct the same keys, shapes, dtypes, values and independent snapshot ownership.
- Run all existing frame checks and window/endpoint audits before another physics step.
Do not defer copies to a later control, buffer unchecked ticks, or use unfinished asynchronous transfers. Keep initial snapshots, offending samples, next-reference evidence and seam fingerprints.
This first version should optimize transfer packaging, not simultaneously rewrite safety predicates, command caching and GUI behavior. Smaller scope makes exact-equivalence failures easier to localize. Packing adds its own concatenation/allocation work; improvement remains unmeasured.
The observer currently accepts mode="packed" but does not itself select an implementation (contact_cycle_sim/performance_v042.py:13–18); environment/recorder construction remains explicit in scripts/evaluate_cycle_functional_flow.py:219–231. A mode label alone is not evidence that packing occurred.
Any new implementation must join authenticated source/import inventories before PREP. Existing integration points are:
source/SkillFactory/SkillFactory/legs/contact_cycle_sim/skill_binding_v4.py:8–17, 25–56scripts/skill_launch_v4.py:19–40
Required qualification before acceptance
Parent-run tests only, after the active run ends:
- Differential original/packed snapshots: identical keys, dtype, shape and values; include noncontiguous tensors, CPU metadata, booleans, integers, empty fields and nonfinite values.
- Snapshot ownership: mutating source tensors or later snapshots must not alter earlier evidence.
- Failure injection at physics substep 2: retain the offending frame, report all original causes in order, and execute no third step or post-failure render.
- Transfer/reconstruction exceptions must fail closed before another physics step.
- Preserve exact window decisions at ticks 1499/1999/2999; endpoint evidence, admission, carry/RNG identity and exactly one refresh at seams.
- Compare original/optimized complete traces and gate results; disclose any tolerance rather than calling unequal results exact.
- Negative provenance tests: changed implementation, mode/config or unbound imports must reject before physics. Retain original GPU admission and SHA-bound shutdown ownership.
- GUI/headless regression and early-close/final-hold checks: no added physics, changed render interval or altered cleanup semantics.
Existing suites to extend/rerun include:
test_contact_cycle_sim_evaluation_runtime.py,
test_contact_cycle_functional_flow_runtime_v2.py,
test_contact_cycle_skill_v4.py,
test_contact_cycle_gui_v041.py, and
test_contact_cycle_gui_shutdown_v041.py.
Benchmark matched protocols with profiling enabled on both sides for diagnosis, then disabled for final wall-throughput reporting. LoopProfile correctly separates active-loop timing from startup/final viewing and labels render generations as submissions—not displayed frames (contact_cycle_sim/performance_v042.py:40–67).
Residual risks
- Dominant cost remains unknown until baseline profiling completes; physics, rendering, CPU recording or synchronization may dominate.
- Packed copies can reduce transfer fan-out yet lose time to packing/allocation.
- CPU equivalence tests cannot establish native CUDA/PhysX trace equality.
- Command caching is particularly sensitive to endpoint/next-reference clocks and live pair-command changes; defer it initially.
- No recommendation changes the floating-root fixture, physical parameters, limits, controller math, 500 Hz trace, gates, render settings, GPU ownership or protected historical artifacts.