Repository navigation
Conversation
|
run-ci |
[Medium impact] The PR appears safe to merge, with a non-blocking concern about matching drift across sensors sharing one body. Findings
SummaryMoves masked actuator resets and ray-caster drift sampling into Warp kernels.
The earlier thruster finding is fixed. The short-mask finding was withdrawn after hujc7 clarified that it was outside the documented contract and already existed on Reviews (2) · Last reviewed commit: "Resample the ray-caster drift from per-e..." · Reviewed by Greptile |
| """ | ||
| for actuator in self.values(): | ||
| actuator.reset(env_ids) | ||
| actuator.reset(env_ids=env_ids, env_mask=env_mask) |
There was a problem hiding this comment.
Unselected thrusters get reset
Multirotor.reset(env_mask=mask) still resets every thruster. The parent Articulation.reset turns missing env_ids into slice(None) before calling _ThrusterCollection.reset. This collection forwards the slice unchanged, so Thruster.reset skips its mask conversion and resets all environments. Meanwhile, thrust targets are restored only where the mask is true. Running environments therefore get new motor parameters and current thrust unexpectedly.
Normalize slice(None) to None before forwarding to the thrusters, as ActuatorCollection.reset does.
| self.assert_shape_and_dtype_mask(body_poses, (env_mask, body_mask), wp.transformf, "body_poses") | ||
| wp.launch( | ||
| shared_kernels.set_body_link_pose_to_sim_mask, | ||
| dim=(self.num_instances, self.num_bodies), | ||
| dim=(env_mask.shape[0], body_mask.shape[0]), |
There was a problem hiding this comment.
The newly accepted short masks still reach a full-size launch after the collection write. Each changed writer calls _invalidate_fk_mask, which forwards the same masks to NewtonBackend.invalidate_fk. That method launches over every row of articulation_ids, and its kernel reads env_mask[env] without checking the mask length. It also loops over every body when reading articulation_mask.
A short environment or body mask therefore causes reads past its end and can schedule resets for unselected objects. Bound this follow-up launch and loop by the supplied mask lengths, or expand the masks into full-size storage.
There was a problem hiding this comment.
Not changed here. On main this writer launches over (num_instances, num_bodies) and reads env_mask[i] and body_mask[j], so a short mask already reads past its end there. #8821 launches the writer over the mask lengths; NewtonBackend.invalidate_fk keeps main's launch size. The masks are documented as (num_instances,) and (num_bodies,).
There was a problem hiding this comment.
You're right. I treated short masks as supported even though the API documents full-length masks, and the overread was already present on main. This isn't a regression introduced by this PR, so my finding should be withdrawn.
There was a problem hiding this comment.
Isaac Lab Review Bot
Needs attention: Design and architecture (1), Scope and over-engineering (2), Compatibility and deprecation (8), Implementation (4), Style consistency (2), Test quality (2). Other reviewed categories look good.
- PR description: Clarify cumulative scope, correct “non-breaking,” remove the duplicate diagram, and provide test commands; benchmark MLP latency/memory baseline versus candidate with revisions, workload, hardware, backend, environment count, warmup, and software environment.
- Design and architecture: PhysX reset forwards competing selectors to consumers with different precedence, clearing different environments within one articulation; apply one selection consistently across actuator and wrench state.
- Scope and over-engineering: Minimal implementation: extend actuator_net.py and NewtonActuatorAdapter, batch LSTM fills, and delete the parallel reset-callable list; keep preallocated masks, fixed-address histories, and direct reset forwarding; no source modules were added. Suggested PR breakdown: selector normalization in memory.py and backend consumers, validated by writer contracts; scene/reset integration with compatibility bridges, validated at extension boundaries; actuator_net.py and its changelog, validated by graph replay and legacy resets.
- API: API changes look good.
- Compatibility and deprecation: Breaking changes: legacy reset overrides, InteractiveSceneWarp imports, camera selectors, numeric Newton/OVPhysX masks, and gradient-enabled MLP histories lose accepted behavior; retain functional bridges with targeted warnings, migration/removal guidance, and transition coverage.
- Implementation: Optional-scratch mask resolution accepts oversized masks, allowing Newton tendon launches to address shorter outputs; reject masks exceeding the destination length while retaining short-mask support.
- Style consistency: Changed selector docstrings promise mask precedence where supplied IDs win; correct the precedence descriptions and remove unsupported thruster timing claims.
- Test quality: New simulator-free files lack kitless routing, and network tests hard-code cuda:0; add file-level marks and use repository-selected CUDA devices.
Needs rework. Posted 19 inline findings.
Automated review; human maintainers own approval decisions.
| if isinstance(actuator, ActuatorBase): | ||
| actuator.reset(group_env_ids) | ||
| self._control.reset_native_actuators(slice(None) if group_env_ids is None else group_env_ids) | ||
| actuator.reset(env_ids=group_env_ids, env_mask=env_mask) |
There was a problem hiding this comment.
🔴 Critical · Compatibility — Preserve custom actuator resets
Every custom reset(env_ids) override now receives an unexpected env_mask keyword, including for index-only calls. Bridge the old invocation with targeted deprecation guidance and validate old and new overrides.
| actuator.reset(group_env_ids) | ||
| self._control.reset_native_actuators(slice(None) if group_env_ids is None else group_env_ids) | ||
| actuator.reset(env_ids=group_env_ids, env_mask=env_mask) | ||
| self._control.reset_native_actuators(slice(None) if group_env_ids is None else group_env_ids, env_mask) |
There was a problem hiding this comment.
🔴 Critical · Compatibility — Preserve native reset hooks
Existing ActuatorControl.reset_native_actuators(env_ids) overrides now receive a second positional argument on every reset. Preserve the one-argument hook through a warned, documented transition.
There was a problem hiding this comment.
reset_native_actuators is an internal ActuatorControl method; the PhysX, Newton and OvPhysX implementations all take env_mask.
| # -- assets | ||
| for articulation in self._articulations.values(): | ||
| articulation.reset(env_ids) | ||
| articulation.reset(env_ids=env_ids, env_mask=env_mask) |
There was a problem hiding this comment.
🔴 Critical · Compatibility — Preserve legacy entity resets
Passing env_mask=None on ordinary resets breaks custom assets and sensors implementing reset(env_ids). Keep their old call functional through a warned, documented deprecation transition and validate both signatures.
There was a problem hiding this comment.
Intended and listed under Breaking changes: custom assets and sensors accept env_mask, as AssetBase.reset and SensorBase.reset do.
| raise ValueError("Selectors must be rank-1 arrays") | ||
| if mask is not None or selection.dtype == wp.bool: | ||
| if selection.dtype != wp.bool or selection.shape != scratch_mask.shape: | ||
| if selection.dtype != wp.bool or (scratch_mask is not None and selection.shape != scratch_mask.shape): |
There was a problem hiding this comment.
🔴 Critical · Implementation — Bound masks by destination length
Without scratch_mask, a mask longer than all_mask passes validation; Newton tendon writers launch over its length and address shorter outputs. Permit short masks but reject oversized ones.
| """ | ||
| for actuator in self.values(): | ||
| actuator.reset(env_ids) | ||
| actuator.reset(env_ids=env_ids, env_mask=env_mask) |
There was a problem hiding this comment.
🔴 Critical · Implementation — Honor mask-only thruster resets
PhysX Articulation.reset turns omitted IDs into slice(None); Thruster.reset treats that as supplied IDs and ignores the forwarded mask, resetting every thruster. Normalize the full slice before forwarding.
|
|
||
| pytestmark = pytest.mark.skipif(not torch.cuda.is_available(), reason="CUDA device required") | ||
|
|
||
| DEVICE = "cuda:0" |
There was a problem hiding this comment.
🟡 Warning · Test Quality — Use selected CUDA test devices
Hard-coded cuda:0 bypasses the repository's multi-GPU device mask. Parameterize both graph tests with test_devices(DeviceScope.CUDA) and pass the selected device through their helpers.
There was a problem hiding this comment.
Fixed in 14de6e9: both graph tests are parametrized with test_devices(DeviceScope.CUDA).
| """Reset every thruster actuator for the given environments. | ||
|
|
||
| .. caution:: | ||
| If both ``env_ids`` and ``env_mask`` are provided, the mask is used: the masked write measured faster. |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Correct thruster precedence prose
The caution promises mask precedence, but Thruster.reset uses supplied IDs first; its timing claim is unsupported here. State the actual selection behavior without the timing claim.
| mask = mask.to(torch.bool) | ||
| return wp.from_torch(mask, dtype=wp.bool) | ||
| return mask | ||
| return resolve_1d_mask(mask=mask, all_mask=full_mask) |
There was a problem hiding this comment.
🟡 Warning · Compatibility — Preserve Newton mask coercion
Newton deformable and MPM writers previously accepted numeric Torch masks by casting to bool; they now raise. Keep that conversion through a warned, documented transition in both consumers.
There was a problem hiding this comment.
Masks are boolean only, as on the other backends; a numeric tensor raises instead of being cast.
| if isinstance(env_mask, wp.array) and str(env_mask.device) != self._device: | ||
| env_mask = wp.clone(env_mask, device=self._device) | ||
| return env_mask | ||
| return resolve_1d_mask(mask=env_mask, all_mask=self._ALL_TRUE_ENV_MASK) |
There was a problem hiding this comment.
🟡 Warning · Compatibility — Preserve numeric Torch masks
OVPhysX mask resolvers previously cast numeric Torch masks to bool; the shared resolver rejects them across affected assets. Retain the conversion through a warned, documented transition.
There was a problem hiding this comment.
Masks are boolean only, as on the other backends; a numeric tensor raises instead of being cast.
|
|
||
| Args: | ||
| joint_ids: Joint indices. If None, then all indices are used. | ||
| joint_mask: Boolean mask; takes precedence over ``joint_ids``. |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Correct selector precedence docstrings
Joint, body, and tendon resolver docstrings promise mask precedence, while resolve_ids prefers supplied IDs. Correct these descriptions and the matching rigid-object resolver prose.
There was a problem hiding this comment.
Isaac Lab Review Bot
Needs attention: Design and architecture (1), Scope and over-engineering (2), Compatibility and deprecation (6), Implementation (2), Style consistency (4), Test quality (3). Other reviewed categories look good.
- PR description: Cumulative scope is mapped correctly; replace “non-breaking,” collapse the duplicate diagram, and benchmark MLP latency/peak-memory with baseline/candidate revisions, command/workload, hardware, backend, environment-count, warmup, and software environment; reported passes establish correctness only.
- Design and architecture: Conflicting IDs and masks reset different environments across actuator models; preserve mask precedence and resolve one selection before dispatch.
- Scope and over-engineering: Minimal implementation: extend ActuatorCollection, actuator_net.py, NewtonActuatorAdapter, InteractiveScene, and memory.py; batch LSTM fills and delete duplicate reset-callback storage; no source modules are added. Essential flow is selection, forwarding, and owned-state reset. Suggested PR breakdown: shared selectors and tendon writers with writer-contract validation; scene/backend/sensor resets with compatibility and selective-reset validation; network resets and fixed history storage with CUDA replay and gradient-input validation.
- API: API changes look good.
- Compatibility and deprecation: Breaking changes: legacy reset overrides, InteractiveSceneWarp imports/configurations, permissive camera IDs, numeric masks, and seeded sampling change without complete transitions; preserve old contracts with targeted warnings, migration/removal guidance, and transition coverage.
- Implementation: Articulation normalizes mask-only resets to slice(None), causing Thruster.reset to resample every environment; treat the full slice as absent explicit IDs before resolving the mask.
- Style consistency: Multirotor reset documentation claims mask precedence despite ID-preferring thrusters; document the corrected dispatch policy and remove the unsupported speed rationale.
- Test quality: New simulator-free regression files lack kitless markers and miss text-based CI selection; add file-level markers while retaining distinct network, backend, and physical-fixture coverage.
Needs rework. Posted 18 inline findings.
Automated review; human maintainers own approval decisions.
| if isinstance(actuator, ActuatorBase): | ||
| actuator.reset(group_env_ids) | ||
| self._control.reset_native_actuators(slice(None) if group_env_ids is None else group_env_ids) | ||
| actuator.reset(env_ids=group_env_ids, env_mask=env_mask) |
There was a problem hiding this comment.
🔴 Critical · Design Architecture — Resolve reset selection once
With conflicting IDs and mask, network actuators use IDs while delayed and native actuators use the mask. One reset splits state across episodes. Preserve the prior mask precedence and dispatch one selection.
There was a problem hiding this comment.
Not changed: callers pass either ids or a mask, or both selecting the same environments; each reset's docstring states which one it uses when both are given.
| actuator.reset(group_env_ids) | ||
| self._control.reset_native_actuators(slice(None) if group_env_ids is None else group_env_ids) | ||
| actuator.reset(env_ids=group_env_ids, env_mask=env_mask) | ||
| self._control.reset_native_actuators(slice(None) if group_env_ids is None else group_env_ids, env_mask) |
There was a problem hiding this comment.
🔴 Critical · Compatibility — Bridge native reset overrides
The new second positional argument breaks backend reset_native_actuators(env_ids) overrides on ordinary resets. Preserve the old hook through a warned, documented transition and validate both signatures.
There was a problem hiding this comment.
reset_native_actuators is an internal ActuatorControl method; the PhysX, Newton and OvPhysX implementations all take env_mask.
| # move history queue by 1 and update top of history | ||
| # -- positions | ||
| self._joint_pos_error_history = self._joint_pos_error_history.roll(1, 1) | ||
| torch.index_select(self._joint_pos_error_history, 1, self._history_shift, out=self._joint_pos_error_spare) |
There was a problem hiding this comment.
🔴 Critical · Implementation — Preserve gradient-bearing compute inputs
Gradient-bearing inputs make history require gradients; the next index_select(out=...) then raises where roll worked. Retain a differentiable history path for those inputs.
There was a problem hiding this comment.
Not changed: the history is filled from simulation state and inference-time actions, and we found no caller that needs gradients through it; main's roll chaining gradients across steps was not wanted either.
| # -- assets | ||
| for articulation in self._articulations.values(): | ||
| articulation.reset(env_ids) | ||
| articulation.reset(env_ids=env_ids, env_mask=env_mask) |
There was a problem hiding this comment.
🔴 Critical · Compatibility — Preserve existing entity resets
Passing env_mask=None on every scene reset breaks custom assets and sensors implementing reset(env_ids). Keep legacy calls functional through a targeted warning, migration guidance, and old/new coverage.
There was a problem hiding this comment.
Intended and listed under Breaking changes: custom assets and sensors accept env_mask, as AssetBase.reset and SensorBase.reset do.
| env_ids: Env indices to reset. If ``None``, resets all envs. | ||
| env_mask: Env mask. Shape is (num_envs,). Defaults to None. | ||
| """ | ||
| if env_ids is None and env_mask is not None: |
There was a problem hiding this comment.
🔴 Critical · Implementation — Honor mask-only multirotor resets
Articulation passes slice(None) with the mask, so this branch ignores the mask and resamples every thruster environment. Treat the full slice as no explicit IDs before resolving the mask.
| from isaaclab.utils import instantiate | ||
| from isaaclab.utils.types import ArticulationActions | ||
|
|
||
| pytestmark = pytest.mark.skipif(not torch.cuda.is_available(), reason="CUDA device required") |
There was a problem hiding this comment.
🟡 Warning · Test Quality — Route simulator-free regressions
This and the new delayed-actuator, selector-resolution, and masked-write files omit pytest.mark.kitless. Text-based CI routing misses them; add a file-level marker to each.
There was a problem hiding this comment.
Fixed in 1c1d47e: test_actuator_net.py is marked kitless.
|
|
||
| pytestmark = pytest.mark.skipif(not torch.cuda.is_available(), reason="CUDA device required") | ||
|
|
||
| DEVICE = "cuda:0" |
There was a problem hiding this comment.
🟡 Warning · Test Quality — Respect selected CUDA devices
Hard-coded cuda:0 ignores the runtime device mask. Parameterize with test_devices(DeviceScope.CUDA) and pass the selected device through capture and assertion helpers.
There was a problem hiding this comment.
Fixed in 14de6e9: both graph tests are parametrized with test_devices(DeviceScope.CUDA).
| """Reset every thruster actuator for the given environments. | ||
|
|
||
| .. caution:: | ||
| If both ``env_ids`` and ``env_mask`` are provided, the mask is used: the masked write measured faster. |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Correct reset precedence documentation
This says the mask wins, but Thruster.reset prefers explicit IDs while the target-buffer write uses the mask. Document one actual policy after fixing dispatch; remove the unsupported speed rationale.
| limits[..., 1] = 0.2 | ||
| wp.capture_launch(capture.graph) | ||
|
|
||
| written = {"stiffness": stiffness, "damping": damping, "pos_limits": limits} |
There was a problem hiding this comment.
🟡 Warning · Test Quality — Assert the tendon simulation write
The test captures write_fixed_tendon_properties_to_sim_mask but checks only staged properties; removing the simulation write would pass. Assert selected and unselected simulation bindings after replay.
There was a problem hiding this comment.
data.fixed_tendon_* wraps the _sim_bind_* arrays bound to the Newton model, not staged values, so the test reads what the write put into the model.
| if isinstance(env_mask, wp.array) and str(env_mask.device) != self._device: | ||
| env_mask = wp.clone(env_mask, device=self._device) | ||
| return env_mask | ||
| return resolve_1d_mask(mask=env_mask, all_mask=self._ALL_TRUE_ENV_MASK) |
There was a problem hiding this comment.
🟡 Warning · Compatibility — Preserve numeric mask inputs
OVPhysX masks and Newton deformable/MPM masks previously cast numeric Torch tensors to bool; resolve_1d_mask rejects them. Retain conversion through a warned, documented transition.
There was a problem hiding this comment.
Masks are boolean only, as on the other backends; a numeric tensor raises instead of being cast.
warp-nn 0.5.0 is the first release with the faster module kernels that the recorded ActuatorNetMLP compute is measured with.
|
run-ci |
The exported ONNX model takes inputs of the sample inputs' shapes, so the actuator traces with its own (env, joint) batch and declares no dynamic axes.
Its compute and masked reset are Warp kernels and Warp-NN on fixed buffers, so it inherits capturable from DCMotor instead of opting out.
The LSTM network is loaded as ONNX (TorchScript is exported at load for the actuator's batch) and runs with Warp-NN, like ActuatorNetMLP: a Warp kernel writes the network input and the hidden and cell states carry over in Warp buffers, so a Warp graph alone records the compute. The two network actuators share their effort buffers and torque clip in a private base class, and both are capturable.
The motor limits and the LSTM states are buffers the actuator owns and writes in place, so their Warp views are made in __init__ instead of on every compute and masked reset; only the tensors a caller passes in are converted per call. The LSTM's sample inputs for the ONNX export become a local function of __init__, and a comment says why the network runs once before any capture.
ActuatorNetLSTM and ActuatorNetMLP now share one Warp-NN entry in the PR's fragment.
The actuators package keeps its Warp kernels in actuator_kernels.py; the network actuators' input, history and clip kernels join dc_motor_clip there under a section of their own, and actuator_net.py keeps only the classes.
|
run-ci |
| ``env_ids`` and does not synchronize the device. A mask on another device is copied to the | ||
| collection's device first. Defaults to None. | ||
| """ | ||
| if env_mask is not None and env_mask.device != wp.get_device(self.device): |
There was a problem hiding this comment.
In general I try to avoid these checks for device, everything should always be on the same decide that I believe is defined by env cfg
There was a problem hiding this comment.
Removed in 55d930d; the reset expects the mask on the collection's device, like the other reset paths.
|
|
||
|
|
||
| class ActuatorNetLSTM(DCMotor): | ||
| class _NetworkActuator(DCMotor): |
| _seed_listeners: list[weakref.WeakMethod] = [] | ||
|
|
||
|
|
||
| def add_seed_listener(listener: Callable[[int], None]) -> None: |
There was a problem hiding this comment.
I think we should avoid this type of design here, global variable with functions to add is not good. @AntoineRichard 's work also overlaps here for warp RGN, should double check with him
There was a problem hiding this comment.
Removed in e07b99f: utils/seed.py is back to main and the drift states are seeded once when the rays initialize.
StafaH
left a comment
There was a problem hiding this comment.
Additional review. The goal (env_mask + capturable actuator nets on Warp-NN) looks good. My main concerns are the network loading path and some avoidable work per step:
| # | Concern |
|---|---|
| 1 | Traced TorchScript checkpoints fail to load (lstm.num_layers missing after jit.load) |
| 2 | Checkpoints using Gather (out[:, -1]) fail to load; the fixture was edited around it |
| 3 | TorchScript → ONNX export at runtime with the legacy exporter; prefer converting offline + loading only .onnx |
| 4 | LSTM state copied out and back every step; ping-pong if Warp-NN can write to provided buffers |
| 5 | Flat indexing, init-time settings read at runtime, per-call from_torch in kernels/launches |
|
|
||
| def sample_inputs(module: torch.jit.ScriptModule) -> tuple: | ||
| # inputs that trace a TorchScript network for its ONNX export: one sample and zero states per row | ||
| state = torch.zeros(module.lstm.num_layers, batch, module.lstm.hidden_size, device=self._device) |
There was a problem hiding this comment.
This breaks traced checkpoints. torch.jit.trace modules don't keep lstm.num_layers / lstm.hidden_size after torch.jit.load (checked on torch 2.11: AttributeError: 'RecursiveScriptModule' object has no attribute 'num_layers'), and scripted ones do. main read these from state_dict(), which works for both:
sd = module.lstm.state_dict()
num_layers, hidden = len(sd) // 4, sd["weight_hh_l0"].shape[1]There was a problem hiding this comment.
Fixed in ac3553d: the layer count and hidden size come from lstm.state_dict() as on main, and the LSTM test now also loads a traced checkpoint.
| # run network inference; its new states are the ones the next step reads | ||
| outputs = self.network(self._network_inputs) | ||
| torque, hidden_state, cell_state = (outputs[name] for name in self._network_output_names) | ||
| wp.copy(self._hidden_state, hidden_state) |
There was a problem hiding this comment.
The two copies move the full LSTM state (2 × layers × envs·joints × hidden floats, each way) on every step. Can Warp-NN write its outputs into buffers we provide? Then the h/c buffers could swap roles each step (ping-pong) instead of being copied.
There was a problem hiding this comment.
Warp-NN keeps its own cached outputs, and swapping the buffers each step would break replaying one recorded graph. The two copies are 4.1 µs per step at 4096 envs (~5% of the replayed compute), so I kept them.
| wp.launch( | ||
| write_lstm_input, | ||
| dim=(self._num_envs, self.num_joints), | ||
| inputs=[wp.from_torch(control_action.joint_positions), wp.from_torch(joint_pos), wp.from_torch(joint_vel)], |
There was a problem hiding this comment.
This builds three wp.from_torch arrays (plus the reshape in _apply_torque and the inputs dict) on every call. That host overhead is probably why eager is only −4 % (E3). Could these be built once per call site?
There was a problem hiding this comment.
The four from_torch calls cost ~13 µs; most eager time is Warp-NN's per-operator launches (117 of 197 µs for the Go1 MLP), and a graph removes both. Caching per call site would key on caller tensors, which are new each call for non-slice groups.
| ``torque`` holds one value per (env, joint), row-major. Launch with ``dim=(num_envs, num_joints)``. | ||
| """ | ||
| env_id, joint = wp.tid() | ||
| effort = torque[env_id * computed_effort.shape[1] + joint] * torque_scale |
There was a problem hiding this comment.
The flat index is rebuilt by hand here, but _apply_torque already reshapes torque on the host. Reshaping to (num_envs, num_joints) lets this be torque[env_id, joint]. Same for row = env_id * J + joint in write_lstm_input.
There was a problem hiding this comment.
I tried it: the network buffers are one row per (env, joint) by design (the ONNX LSTM has a single batch axis, the MLP starts with a Gemm), so 2-D indexing needed a second view of the same memory. I kept the row index.
| _push_newest(joint_vel_history, env_id, joint, joint_vel[env_id, joint]) | ||
| num_samples = history_indices.shape[0] | ||
| row = env_id * joint_pos.shape[1] + joint | ||
| pos_column = wp.where(pos_first, 0, num_samples) |
There was a problem hiding this comment.
pos_first and history_indices are fixed at init, but here every thread reads them at runtime. A cached kernel factory with wp.static, like make_masked_fill, would bake in the column offsets and the index list.
There was a problem hiding this comment.
I tried a cached wp.static kernel per (input_idx, input_order); the Go1 MLP graph replay stayed at 65.5 µs, so I kept the runtime arguments.
|
|
||
|
|
||
| @wp.func | ||
| def dc_motor_clip( |
There was a problem hiding this comment.
nit: this is a second copy of DCMotor._clip_effort. Could DCMotor use this function too, so the torque-speed envelope lives in one place?
There was a problem hiding this comment.
Done in ac3553d: DCMotor._clip_effort launches the same dc_motor_clip kernel into a preallocated buffer, so the envelope lives in one place (DCMotor compute also went from ~65 to ~45 µs eager).
|
|
||
| def load_onnx_model( | ||
| model_path: str, | ||
| sample_inputs: tuple | Callable[[torch.jit.ScriptModule], tuple], |
There was a problem hiding this comment.
The API is leaky: sample_inputs takes a tuple or a callable, and for .onnx files sample_inputs, input_names and output_names are all silently ignored. The actuator then has to find its inputs and outputs by position (inputs[1] is assumed to be h, outputs torque/h/c), and nothing checks that order.
Simplest fix: this util only reads ONNX, and a small one-off script converts .pt → .onnx.
There was a problem hiding this comment.
load_onnx_model now only reads .onnx, the TorchScript export is a separate export_torchscript_to_onnx(module, inputs, ...) used only for non-ONNX files, and Warp-NN checks the input names when the network is prepared.
| model, | ||
| input_names=input_names, | ||
| output_names=output_names, | ||
| dynamo=False, |
There was a problem hiding this comment.
This exports from TorchScript at runtime with the legacy exporter (dynamo=False) every time an actuator is built. That adds load time, and loading now depends on an exporter path PyTorch is moving away from. I'd rather convert offline once and load .onnx only.
There was a problem hiding this comment.
Agreed. The shipped ANYdrive and Go1 checkpoints are TorchScript and also feed the Newton actuator path, so loading only .onnx moves to the follow-up that switches both paths to ONNX checkpoints; until then the export runs once per build.
| out, hc_new = self.lstm(x, hc) | ||
| return self.fc(out[:, -1, :]), hc_new | ||
| # one time step per call; squeezing it exports to an operator Warp-NN runs (indexing exports to Gather) | ||
| return self.fc(out.squeeze(1)), hc_new |
There was a problem hiding this comment.
Editing the fixture hides a compatibility break: out[:, -1, :] is the usual way to write an LSTM head, and user checkpoints written that way now fail to load (no Gather in Warp-NN 0.5.0). This needs at least a clear error at load time and a migration note in the changelog. Better: a Warp-NN Gather, or a rewrite at export time.
There was a problem hiding this comment.
Done in ac3553d: an operator Warp-NN doesn't support now fails at load with the file name and the fix (out.squeeze(1) for the step), a test covers the out[:, -1, :] head, and the changelog notes the migration.
| # Drift random states, allocated when the rays initialize; every configure_seed reseeds them. | ||
| self._drift_rng_state: wp.array | None = None | ||
| # A drift stream from the configuration, which writes callables by name, so it repeats across processes. | ||
| self._drift_stream = zlib.crc32(json.dumps(self.cfg.to_dict(), sort_keys=True, default=str).encode()) |
There was a problem hiding this comment.
Hashing the whole config means any unrelated field (debug_vis, visualizer_cfg, …) changes the drift that is drawn. If each sensor needs its own stream, key it on something stable, such as the sensor index or prim path.
There was a problem hiding this comment.
Changed in e07b99f: the stream is keyed on the sensor's prim path and offset, so unrelated fields don't change the drift and ray casters at different offsets on one prim still differ.
Read the LSTM layer count and hidden size from the weights, so traced TorchScript checkpoints load. Split load_onnx_model (reads .onnx files) from the new export_torchscript_to_onnx; a TorchScript network_file is still exported when the actuator loads, with a warning that points to the new offline converter, scripts/tools/convert_actuator_net_to_onnx.py. The LSTM looks its inputs and outputs up by name and rejects an ONNX file without them. A network with an operator Warp-NN does not support fails with an error naming the file and the fix. Index the network kernels per environment and joint, compile the MLP history samples and column order into a cached kernel, and rename the shared base class to ActuatorNetBase. DCMotor clips its effort with the same dc_motor_clip kernel function the network actuators use, into a preallocated applied-effort buffer.
The collection, like the other reset paths, takes a mask on its own device; drop the copy of a mask from another device, its test case and its changelog entry.
Seed the per-environment drift states from the environment seed when the rays initialize, and key each sensor's stream on its prim path and offset instead of a hash of its whole configuration, so unrelated fields no longer change the drift and configurations with callables such as functools.partial patterns build. Remove the configure_seed listener registry; a later env.reset(seed=...) no longer restarts the drift sequence.
…ments The networks take one row per (environment, joint): the ONNX LSTM operator has a single batch axis and the MLP's first layer is a Gemm. Keep the network input and torque in that layout and index them by row in the kernels, instead of holding a second per-environment view of the same memory. Pass the MLP history samples and column order to the kernel as arguments again; compiling them into a kernel per configuration measured no faster.
Each network actuator reads an .onnx file, or loads its TorchScript file, builds the sample inputs from the loaded module and exports it with export_torchscript_to_onnx, which now takes the module and the inputs. Drop the shared loader that took a sample-input function and the warning on every TorchScript load; a small helper only names the network file when Warp-NN cannot run it.
ActuatorNetBase loads the network file once for both actuators; each actuator only builds the sample inputs that trace its TorchScript network for the export. The LSTM checks and reads its inputs through a dictionary keyed by name.
Converting checkpoints offline belongs with the change that moves both actuator paths to ONNX files, so remove the converter script and the export's dynamic-axes option it alone used. Warp-NN already checks the input names when it prepares the network, so drop the actuators' own name and count checks and the base class's placeholder for the export sample.
|
run-ci |
Summary
computeof both network actuators (ActuatorNetMLPandActuatorNetLSTM, now both on Warp-NN) and every masked reset of the actuator networks and the ray-caster drift. Both actuators arecapturable.computecall againstmaineager: in a Warp graph, Go1 MLP 377.5 → 82.0 µs and ANYdrive LSTM 686.1 → 76.6 µs at 4096 envs; run eagerly, on par or faster (E3, E4).main: unchanged (E5). With the defaultuse_newton_actuators=True, Newton's own actuator runs these networks, so this PR's actuators run when Newton actuators are disabled.Dependencies
ActuatorCollection.is_graphableexcludes explicit groups)Slice); this PR requireswarp-nn>=0.5.0ActuatorNetLSTMon Warp-NNuse_newton_actuators=True, Newton runs the network from a Torch.pt2export, which Newton cannot capture; handing it ONNX instead, with the shipped checkpoints moved to ONNX so both paths load only.onnx(no export at load)Description
compute= history kernel (shift + scaled network input) → Warp-NN → scale + DC motor clip kernel; efforts in preallocated Warp buffers,computed_effort/applied_effortstay Torch viewsactuator_net.py,actuator_kernels.pycompute= input kernel → Warp-NN → new hidden and cell states copied into their state buffers → the same clip kernel;sea_*stay Torch views of the Warp buffersactuator_net.pyActuatorNetBase: network file check, computed-effort buffer, network loading, scale + clip launchactuator_net.py.onnxread as is; a TorchScript file is exported to ONNX at load for the actuator's batch (the LSTM reads its layer count and hidden size from the weights, so traced checkpoints load); a network with an operator Warp-NN does not support fails with an error naming the file;networkis now the Warp-NN runtime for both actuators (breaking; no caller in the repo)actuator_net.py,utils/io/onnx.pyenv_idskeepmain's Torch pathactuator_net.pycapturable: drops the opt-outsmainadded in #9120actuator_net.pyactuator_kernels.pyDCMotorclips its effort with the network actuators'dc_motor_clipkernel into a preallocated buffer (applied_effortis its Torch view), so the torque-speed envelope lives in one place (E6)actuator_pd.py,actuator_kernels.pyenv.reset(seed=...)does not restart the driftbase_ray_caster.py,ray_caster/kernels.py,utils/warp/kernels.py::initialize_rng_statesqueeze(Warp-NN 0.5.0 has noGather; a test pins the load error for an indexing head); actuator concepts page describes the network fileactuator_equivalence.py,test_dc_motor.py,test_actuator_net.py,concepts/actuators.rstwarp-nn>=0.5.0pyproject.toml,uv.lockEvidence
Per
computecall (µs):maineagermaineagerE5: env step (ms, RTX PRO 6000, 4096 envs, Newton MJWarp;
maind56d381a20fvs this PRec5dc495c89, alternating runs, median of 6 × 100 steps):mainuse_newton_actuators=False)use_newton_actuators=False)E6:
DCMotor.computeeager (µs, RTX PRO 6000, 12 joints;ec5dc495c89vsac3553dfd46, alternating, 2 runs each): 512 envs 64.9 / 65.9 → 48.7 / 44.5; 4096 envs 63.9 / 66.9 → 48.1 / 44.3.At
46c853c902d(RTX PRO 6000):test_actuator_net.py16,test_dc_motor.py22,test_actuator_collection.py29,test_newton_adapter.py26,test_newton_actuators_newton.py38 andtest_newton_raycast_sensor.py10 passed. Atec5dc495c89(RTX PRO 6000):test_actuator_net.py13,test_dc_motor.py22,test_actuator_collection.py30 (2 skipped) andtest_newton_actuators_newton.py38 passed. Both actuators'computeand masked reset replay from a Warp graph on Warp's own stream, from a Warp graph on Torch's stream and fromtorch.cuda.graphwith zero error (12/12). ANYdrive LSTM at3a8360a89d9: againstmaineager with TF32 off, 9.7e-4 (512 envs) and 1.1e-3 (4096 envs) over 24 steps; against an FP64 reference, Warp-NN 1.7e-5 andmain's FP32 cuDNN 9.5e-4. Ray-caster tests ate7c807e3226:test_newton_raycast_sensor.py10,test_ray_caster_sensor.py4,test_ray_caster_integration.py10 passed.History
ActuatorNetBase,DCMotorshares the clip kernel, the collection's device copy dropped, drift seeded once at init (ac3553dfd46…b4175b1a588); mergedmain(46c853c902d).ActuatorNetLSTMon Warp-NN with a shared base (3a8360a89d9); both actuators capturable (d98b83c5b12); TorchScript exported for the actuator's batch (6f4030a8889); review cleanups (5d49b8dd94e,ec5dc495c89).main; require warp-nn 0.5.0 (19d9aab3247).6c27eb313a7,0ef4971028a,4634d7863fa; mergedmain.e7c807e3226), reseeded byconfigure_seed(4b9dd927aa2); test trims.mainafter [Warp] Part 1a/8: Resolve id and mask selections through shared helpers #8821 merged and [Warp] Part 2a/8: Reset only the masked environments #6646 closed.Type of change
Release backport
mainScreenshots
Not applicable.
Checklist
Docker and GPU tests run on demand. Push the commits you want tested, then
comment
run-cion the pull request.pre-commitchecks withuv run isaaclab --formatsource/<pkg>/changelog.d/for every touched package (do not editCHANGELOG.rstor bump package versions — CI handles that)CONTRIBUTORS.mdor my name already exists there