-
Notifications
You must be signed in to change notification settings - Fork 228
Address Warp Deprecation Warnings #1305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Address Warp Deprecation Warnings #1305
Conversation
📝 WalkthroughWalkthroughAdd mesh adjacency and mesh-solidification utilities plus a GPU RGB-copy kernel and Bourke color map; migrate numerous Warp imports/type usages to updated/internal paths; simplify CUDA-graph support checks and adjust several type annotations and small call sites. No public API removals. Changes
Sequence Diagram(s)sequenceDiagram
actor Caller
participant solidify_mesh as solidify_mesh()
participant WarpRuntime as Warp runtime / GPU
participant OutArrays as out_vertices/out_indices
Caller->>solidify_mesh: call(faces, vertices, thickness)
solidify_mesh->>WarpRuntime: allocate & upload arrays, launch solidify_mesh_kernel
WarpRuntime->>OutArrays: write extruded vertices and faces
WarpRuntime-->>solidify_mesh: kernel complete
solidify_mesh-->>Caller: return (out_faces, out_vertices)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Fix all issues with AI Agents 🤖
In @newton/_src/viewer/viewer_gl.py:
- Line 611: Replace the direct use of the module name "warp" with the
established import alias "wp" for the render function reference: change any
occurrence of warp._src.render.render_opengl.copy_rgb_frame_uint8 to
wp._src.render.render_opengl.copy_rgb_frame_uint8 (reference symbol
copy_rgb_frame_uint8) so the code consistently uses the wp alias and avoids the
static analysis warning.
🧹 Nitpick comments (2)
newton/_src/viewer/viewer.py (1)
586-586: Remove unused noqa directive.The
# noqa: PLC0415directive is unnecessary since the PLC0415 check is not enabled.🔎 Proposed fix
- from warp._src.render.utils import solidify_mesh # noqa: PLC0415 + from warp._src.render.utils import solidify_meshnewton/_src/solvers/style3d/linear_solver.py (1)
230-230: Remove unusednoqadirective.The
# noqa: PLC0415directive is unnecessary since thePLC0415rule (import-outside-toplevel) is not enabled in your linting configuration.🔎 Suggested cleanup
- from warp._src.context import runtime # noqa: PLC0415 + from warp._src.context import runtime
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (27)
docs/generate_api.pynewton/_src/core/types.pynewton/_src/geometry/sdf_mc.pynewton/_src/sim/builder.pynewton/_src/sim/contacts.pynewton/_src/sim/graph_coloring.pynewton/_src/sim/style3d/builder_style3d.pynewton/_src/solvers/implicit_mpm/solve_rheology.pynewton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/_src/solvers/solver.pynewton/_src/solvers/style3d/collision/bvh/bvh.pynewton/_src/solvers/style3d/linear_solver.pynewton/_src/solvers/vbd/particle_vbd_kernels.pynewton/_src/solvers/vbd/rigid_vbd_kernels.pynewton/_src/utils/__init__.pynewton/_src/utils/import_mjcf.pynewton/_src/utils/recorder.pynewton/_src/utils/selection.pynewton/_src/viewer/viewer.pynewton/_src/viewer/viewer_gl.pynewton/examples/diffsim/example_diffsim_ball.pynewton/examples/diffsim/example_diffsim_cloth.pynewton/examples/diffsim/example_diffsim_drone.pynewton/examples/diffsim/example_diffsim_soft_body.pynewton/examples/diffsim/example_diffsim_spring_cage.pynewton/examples/robot/example_robot_anymal_c_walk.pynewton/tests/test_coloring.py
🧰 Additional context used
🧠 Learnings (32)
📓 Common learnings
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/_src/solvers/featherstone/kernels.py:75-75
Timestamp: 2025-08-12T18:04:06.577Z
Learning: The Newton physics framework requires nightly Warp builds, which means compatibility concerns with older stable Warp versions (like missing functions such as wp.spatial_adjoint) are not relevant for this project.
Learnt from: shi-eric
Repo: newton-physics/newton PR: 521
File: newton/examples/example_cloth_hanging.py:36-36
Timestamp: 2025-08-12T05:17:34.423Z
Learning: The Newton migration guide (docs/migration.rst) is specifically for documenting how to migrate existing warp.sim functionality to Newton equivalents. New Newton-only features that didn't exist in warp.sim do not need migration documentation.
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/tests/test_ik.py:25-26
Timestamp: 2025-08-12T17:58:16.929Z
Learning: In the Newton physics engine codebase, it's acceptable for tests to import and use private `_src` internal modules and functions when needed for testing purposes, even though this breaks the public API boundary. This is an intentional project decision for test code.
📚 Learning: 2025-08-12T18:04:06.577Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/_src/solvers/featherstone/kernels.py:75-75
Timestamp: 2025-08-12T18:04:06.577Z
Learning: The Newton physics framework requires nightly Warp builds, which means compatibility concerns with older stable Warp versions (like missing functions such as wp.spatial_adjoint) are not relevant for this project.
Applied to files:
newton/_src/solvers/vbd/particle_vbd_kernels.pynewton/_src/viewer/viewer_gl.pynewton/_src/solvers/style3d/linear_solver.pynewton/_src/utils/__init__.pynewton/_src/solvers/vbd/rigid_vbd_kernels.pynewton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/_src/utils/import_mjcf.pynewton/_src/sim/builder.py
📚 Learning: 2025-08-12T17:51:37.474Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/geometry.py:16-22
Timestamp: 2025-08-12T17:51:37.474Z
Learning: In the Newton public API refactor, common geometry symbols like ParticleFlags and ShapeFlags are now exposed at the top level in newton/__init__.py rather than through newton.geometry. The newton/geometry.py module is intentionally focused only on broad-phase collision detection classes (BroadPhaseAllPairs, BroadPhaseExplicit, BroadPhaseSAP).
Applied to files:
newton/_src/solvers/vbd/particle_vbd_kernels.pynewton/_src/core/types.pynewton/_src/solvers/style3d/collision/bvh/bvh.py
📚 Learning: 2025-08-12T05:17:34.423Z
Learnt from: shi-eric
Repo: newton-physics/newton PR: 521
File: newton/examples/example_cloth_hanging.py:36-36
Timestamp: 2025-08-12T05:17:34.423Z
Learning: The Newton migration guide (docs/migration.rst) is specifically for documenting how to migrate existing warp.sim functionality to Newton equivalents. New Newton-only features that didn't exist in warp.sim do not need migration documentation.
Applied to files:
newton/_src/solvers/vbd/particle_vbd_kernels.pynewton/_src/solvers/style3d/linear_solver.pynewton/_src/sim/contacts.pynewton/examples/diffsim/example_diffsim_soft_body.pynewton/examples/diffsim/example_diffsim_ball.pynewton/_src/viewer/viewer.pynewton/_src/core/types.pynewton/examples/robot/example_robot_anymal_c_walk.pynewton/_src/solvers/vbd/rigid_vbd_kernels.pynewton/examples/diffsim/example_diffsim_spring_cage.pynewton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/_src/utils/import_mjcf.pynewton/_src/sim/builder.pynewton/_src/utils/recorder.py
📚 Learning: 2025-08-12T17:52:15.009Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/_src/utils/import_mjcf.py:226-231
Timestamp: 2025-08-12T17:52:15.009Z
Learning: In the Newton codebase, when passing array-like objects (numpy arrays, lists, tuples) to wp.vec3(), the consistent pattern is to use the unpacking operator: wp.vec3(*array) rather than wp.vec3(array). This pattern is used throughout newton/_src/utils/import_mjcf.py and newton/_src/core/types.py.
Applied to files:
newton/_src/solvers/vbd/particle_vbd_kernels.pynewton/_src/utils/selection.pynewton/_src/solvers/vbd/rigid_vbd_kernels.pynewton/_src/utils/import_mjcf.py
📚 Learning: 2025-09-18T07:05:56.836Z
Learnt from: gdaviet
Repo: newton-physics/newton PR: 750
File: newton/_src/solvers/implicit_mpm/solve_rheology.py:969-986
Timestamp: 2025-09-18T07:05:56.836Z
Learning: In newton/_src/solvers/implicit_mpm/solve_rheology.py, transposed_strain_mat parameter cannot be None - the type signature was corrected to reflect this guarantee, eliminating the need for None checks when accessing transposed_strain_mat.offsets.
Applied to files:
newton/_src/solvers/vbd/particle_vbd_kernels.pynewton/_src/solvers/style3d/linear_solver.pynewton/_src/solvers/implicit_mpm/solve_rheology.pynewton/_src/solvers/implicit_mpm/solver_implicit_mpm.py
📚 Learning: 2025-09-25T16:14:22.033Z
Learnt from: dylanturpin
Repo: newton-physics/newton PR: 806
File: newton/_src/sim/ik/ik_objectives.py:0-0
Timestamp: 2025-09-25T16:14:22.033Z
Learning: In NVIDIA Warp's Newton physics library, wp.transform supports direct numerical indexing (e.g., body_tf[0], body_tf[1], body_tf[2] for position and body_tf[3], body_tf[4], body_tf[5], body_tf[6] for quaternion components) to access its elements. This is the standard API used throughout the codebase.
Applied to files:
newton/_src/solvers/vbd/particle_vbd_kernels.pynewton/_src/solvers/vbd/rigid_vbd_kernels.py
📚 Learning: 2025-09-22T21:08:31.901Z
Learnt from: dylanturpin
Repo: newton-physics/newton PR: 806
File: newton/examples/ik/example_ik_franka.py:121-123
Timestamp: 2025-09-22T21:08:31.901Z
Learning: In the newton physics framework, when creating warp arrays for IK solver joint variables using wp.array(self.model.joint_q, shape=(1, coord_count)), the resulting array acts as a reference/pointer to the original model's joint coordinates, so updates from the IK solver automatically reflect in the model's joint_q buffer used for rendering.
Applied to files:
newton/_src/solvers/vbd/particle_vbd_kernels.pynewton/_src/viewer/viewer_gl.pynewton/_src/solvers/vbd/rigid_vbd_kernels.py
📚 Learning: 2025-09-22T21:08:31.901Z
Learnt from: dylanturpin
Repo: newton-physics/newton PR: 806
File: newton/examples/ik/example_ik_franka.py:121-123
Timestamp: 2025-09-22T21:08:31.901Z
Learning: In the newton physics framework, when creating warp arrays for IK solver joint variables using wp.array(self.model.joint_q, shape=(1, coord_count)), the resulting array acts as a reference/pointer to the original model's joint coordinates, so updates from the IK solver automatically reflect in the model's joint_q buffer used for rendering, despite the general warp documentation suggesting copies are made by default.
Applied to files:
newton/_src/solvers/vbd/particle_vbd_kernels.pynewton/_src/viewer/viewer_gl.pynewton/_src/solvers/style3d/linear_solver.pynewton/_src/solvers/vbd/rigid_vbd_kernels.pynewton/_src/utils/import_mjcf.pynewton/_src/utils/recorder.py
📚 Learning: 2025-09-25T16:14:22.033Z
Learnt from: dylanturpin
Repo: newton-physics/newton PR: 806
File: newton/_src/sim/ik/ik_objectives.py:0-0
Timestamp: 2025-09-25T16:14:22.033Z
Learning: wp.transform in NVIDIA Warp supports indexing using numerical indices (e.g., body_tf[0], body_tf[3], etc.) to access translation and rotation components. The indexing approach used in the Newton codebase is valid and compiles correctly.
Applied to files:
newton/_src/solvers/vbd/particle_vbd_kernels.py
📚 Learning: 2025-09-26T05:58:21.013Z
Learnt from: WenchaoHuang
Repo: newton-physics/newton PR: 835
File: newton/_src/solvers/style3d/collision/collision.py:49-53
Timestamp: 2025-09-26T05:58:21.013Z
Learning: In newton/_src/solvers/style3d/collision/collision.py, the broad_phase buffers (broad_phase_ee, broad_phase_ef, broad_phase_vf) created with wp.array() don't need zero-initialization because they follow a write-first-read-later pattern: BVH query kernels in frame_begin() populate these buffers completely (write-only operations), and collision kernels only read from them afterward in accumulate_contact_force(), ensuring no undefined reads occur.
Applied to files:
newton/_src/solvers/vbd/particle_vbd_kernels.pynewton/_src/solvers/style3d/collision/bvh/bvh.py
📚 Learning: 2025-08-12T05:17:34.423Z
Learnt from: shi-eric
Repo: newton-physics/newton PR: 521
File: newton/examples/example_cloth_hanging.py:36-36
Timestamp: 2025-08-12T05:17:34.423Z
Learning: The STYLE3D solver in Newton is a new solver that did not exist in warp.sim, so it does not require any migration documentation.
Applied to files:
newton/_src/solvers/style3d/linear_solver.pynewton/_src/sim/style3d/builder_style3d.py
📚 Learning: 2025-08-25T20:10:59.536Z
Learnt from: dylanturpin
Repo: newton-physics/newton PR: 634
File: newton/examples/ik/example_ik_franka.py:0-0
Timestamp: 2025-08-25T20:10:59.536Z
Learning: In Newton's IK examples, when creating solver arrays with `wp.array(source_array, shape=new_shape)`, this creates a view into the same underlying memory rather than a copy. This means updates to the reshaped array are automatically reflected in the original array without needing explicit copy operations like `wp.copy()`.
Applied to files:
newton/_src/solvers/style3d/linear_solver.py
📚 Learning: 2025-08-12T17:58:16.929Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/tests/test_ik.py:25-26
Timestamp: 2025-08-12T17:58:16.929Z
Learning: In the Newton physics engine codebase, it's acceptable for tests to import and use private `_src` internal modules and functions when needed for testing purposes, even though this breaks the public API boundary. This is an intentional project decision for test code.
Applied to files:
newton/_src/solvers/style3d/linear_solver.pynewton/tests/test_coloring.py
📚 Learning: 2025-12-12T08:45:43.428Z
Learnt from: nvtw
Repo: newton-physics/newton PR: 1221
File: newton/examples/example_sdf.py:277-287
Timestamp: 2025-12-12T08:45:43.428Z
Learning: In Newtown (Newton) example code, specifically files under newton/examples, computing contacts once per frame and reusing them across all substeps is an intentional design choice, not a bug. Reviewers should verify that contacts are computed before the substep loop and reused for every substep within the same frame. This pattern reduces redundant work and preserves frame-consistency; do not flag as a regression unless the behavior is changed for correctness or performance reasons.
Applied to files:
newton/examples/diffsim/example_diffsim_soft_body.pynewton/examples/diffsim/example_diffsim_ball.pynewton/examples/robot/example_robot_anymal_c_walk.pynewton/examples/diffsim/example_diffsim_spring_cage.pynewton/examples/diffsim/example_diffsim_drone.pynewton/examples/diffsim/example_diffsim_cloth.py
📚 Learning: 2025-09-17T21:34:05.267Z
Learnt from: gdaviet
Repo: newton-physics/newton PR: 750
File: newton/examples/mpm/example_mpm_granular.py:44-47
Timestamp: 2025-09-17T21:34:05.267Z
Learning: wp.Mesh (Warp mesh objects) expose triangle indices through the `indices` attribute, not `triangles`. The correct usage is `wp.Mesh(...).indices`, not `wp.Mesh(...).triangles`.
Applied to files:
newton/_src/sim/style3d/builder_style3d.pynewton/_src/solvers/style3d/collision/bvh/bvh.pynewton/_src/sim/builder.py
📚 Learning: 2025-08-12T17:58:00.815Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/_src/solvers/featherstone/kernels.py:18-20
Timestamp: 2025-08-12T17:58:00.815Z
Learning: In newton/_src/core/__init__.py, the function transform_twist is properly re-exported from the spatial module via "from .spatial import (..., transform_twist, ...)" and included in __all__, making it available for import as "from ...core import transform_twist" from other modules.
Applied to files:
newton/_src/core/types.py
📚 Learning: 2025-07-23T14:36:42.182Z
Learnt from: shi-eric
Repo: newton-physics/newton PR: 461
File: asv/benchmarks/envs/example_humanoid.py:40-41
Timestamp: 2025-07-23T14:36:42.182Z
Learning: In Warp benchmarks, explicit wp.init() calls are not needed in most circumstances since the first Warp API call that requires initialization will automatically call wp.init(). Explicit wp.init() in setup() methods is helpful when the ASV benchmark is measuring a Warp API call, as wp.init() has non-trivial overhead that should be excluded from the benchmark timing.
Applied to files:
newton/examples/robot/example_robot_anymal_c_walk.py
📚 Learning: 2025-09-26T05:58:21.013Z
Learnt from: WenchaoHuang
Repo: newton-physics/newton PR: 835
File: newton/_src/solvers/style3d/collision/collision.py:49-53
Timestamp: 2025-09-26T05:58:21.013Z
Learning: In newton/_src/solvers/style3d/collision/collision.py, the broad_phase buffers (broad_phase_ee, broad_phase_ef, broad_phase_vf) created with wp.array() don't need zero-initialization because the BVH query kernels that use them always write the count to query_results[0, tid] = 0 first before populating any data, ensuring no undefined reads occur.
Applied to files:
newton/_src/solvers/style3d/collision/bvh/bvh.py
📚 Learning: 2025-10-30T07:28:13.112Z
Learnt from: nvtw
Repo: newton-physics/newton PR: 984
File: newton/_src/geometry/broad_phase_nxn.py:318-336
Timestamp: 2025-10-30T07:28:13.112Z
Learning: In Newton's BroadPhaseAllPairs class (newton/_src/geometry/broad_phase_nxn.py), device management is the caller's responsibility. The library intentionally does not perform automatic device transfers for precomputed arrays in the launch method, even if there's a device mismatch. Users must ensure that the device specified in __init__ matches the device used in launch.
Applied to files:
newton/_src/solvers/style3d/collision/bvh/bvh.py
📚 Learning: 2025-08-18T15:56:26.587Z
Learnt from: adenzler-nvidia
Repo: newton-physics/newton PR: 552
File: newton/_src/solvers/mujoco/solver_mujoco.py:0-0
Timestamp: 2025-08-18T15:56:26.587Z
Learning: In Newton's MuJoCo solver, when transforming joint axes from Newton's internal frame to MuJoCo's expected frame, use wp.quat_rotate(joint_rot, axis) not wp.quat_rotate_inv(joint_rot, axis). The joint_rot represents rotation from joint-local to body frame, so forward rotation is correct.
Applied to files:
newton/_src/solvers/vbd/rigid_vbd_kernels.py
📚 Learning: 2025-11-24T10:44:09.613Z
Learnt from: gdaviet
Repo: newton-physics/newton PR: 1108
File: newton/_src/solvers/implicit_mpm/rasterized_collisions.py:94-129
Timestamp: 2025-11-24T10:44:09.613Z
Learning: In Warp, wp.normalize() returns a zero vector (or zero quaternion) when given a zero-length input, so explicit zero-length checks before normalization are not required.
Applied to files:
newton/_src/solvers/vbd/rigid_vbd_kernels.pynewton/_src/utils/import_mjcf.py
📚 Learning: 2025-12-01T17:00:28.889Z
Learnt from: camevor
Repo: newton-physics/newton PR: 1161
File: newton/_src/solvers/mujoco/kernels.py:1268-1268
Timestamp: 2025-12-01T17:00:28.889Z
Learning: MuJoCo Warp spatial vectors (e.g., cacc, cvel) use the convention (angular, linear), which is opposite to Newton's (linear, angular) convention. When converting from MuJoCo Warp to Newton format, spatial_top() on MuJoCo Warp data extracts the angular component, and spatial_bottom() extracts the linear component.
Applied to files:
newton/_src/solvers/vbd/rigid_vbd_kernels.pynewton/_src/utils/import_mjcf.py
📚 Learning: 2025-11-28T11:12:40.805Z
Learnt from: camevor
Repo: newton-physics/newton PR: 1146
File: newton/examples/basic/example_basic_joints.py:206-213
Timestamp: 2025-11-28T11:12:40.805Z
Learning: In Newton's standard solvers (XPBD, SemiImplicit, SolverMuJoCo), spatial vectors in State.body_qd use the ordering (linear, angular): wp.spatial_top(qd) returns linear velocity and wp.spatial_bottom(qd) returns angular velocity. This is the opposite of typical Modern Robotics spatial twist notation where (angular, linear) is used.
Applied to files:
newton/_src/solvers/vbd/rigid_vbd_kernels.py
📚 Learning: 2025-11-28T11:12:40.030Z
Learnt from: camevor
Repo: newton-physics/newton PR: 1146
File: newton/examples/basic/example_basic_joints.py:215-222
Timestamp: 2025-11-28T11:12:40.030Z
Learning: In Warp's spatial vector convention used by Newton: spatial_bottom() extracts the angular velocity component (omega) and spatial_top() extracts the linear velocity component (v) from a spatial twist (qd). Similarly for spatial wrenches: spatial_bottom() is torque and spatial_top() is force.
Applied to files:
newton/_src/solvers/vbd/rigid_vbd_kernels.py
📚 Learning: 2025-09-09T11:03:41.928Z
Learnt from: gdaviet
Repo: newton-physics/newton PR: 750
File: newton/_src/solvers/implicit_mpm/solve_rheology.py:892-895
Timestamp: 2025-09-09T11:03:41.928Z
Learning: In newton/_src/solvers/implicit_mpm/solve_rheology.py, passing None for compliance_mat_diagonal is intentional to avoid loading zeros from global memory when compliance_mat is None, rather than creating a zero matrix and extracting its diagonal.
Applied to files:
newton/_src/solvers/implicit_mpm/solve_rheology.py
📚 Learning: 2025-09-22T21:03:39.624Z
Learnt from: dylanturpin
Repo: newton-physics/newton PR: 806
File: newton/_src/sim/ik/ik_lbfgs_optimizer.py:739-752
Timestamp: 2025-09-22T21:03:39.624Z
Learning: The L-BFGS optimizer in newton/_src/sim/ik/ik_lbfgs_optimizer.py currently intentionally only supports additive updates (assuming n_coords == n_dofs). Velocity space integration for joints with mismatched coordinate/DOF dimensions (like free/ball joints) is planned for future work and should not be flagged as an issue in current reviews.
Applied to files:
newton/_src/solvers/implicit_mpm/solve_rheology.py
📚 Learning: 2025-08-19T12:27:30.629Z
Learnt from: preist-nvidia
Repo: newton-physics/newton PR: 579
File: newton/examples/example_mujoco.py:350-354
Timestamp: 2025-08-19T12:27:30.629Z
Learning: In Newton examples, there's a distinction between solver parameters and Example class attributes. The Example class can have its own use_mujoco attribute for controlling example-level behavior (like CUDA graphs, rendering logic), while the solver uses use_mujoco_cpu for backend selection. These serve different purposes and should not be conflated during API renames.
Applied to files:
newton/_src/solvers/implicit_mpm/solver_implicit_mpm.py
📚 Learning: 2025-12-12T15:23:30.014Z
Learnt from: vastsoun
Repo: newton-physics/newton PR: 1019
File: newton/_src/solvers/kamino/examples/sim/example_sim_basics_boxes_fourbar.py:149-163
Timestamp: 2025-12-12T15:23:30.014Z
Learning: In Kamino simulation examples under newton/_src/solvers/kamino/examples/sim/, the pattern where logging=True and use_cuda_graph=True creates a mismatch (SimulationLogger constructed but settings.compute_metrics and logger.log() calls guarded by `if not self.use_cuda_graph`) should not be flagged. These examples will be refactored in a future commit, and this pattern is intentionally deferred.
Applied to files:
newton/_src/solvers/implicit_mpm/solver_implicit_mpm.py
📚 Learning: 2025-10-29T14:55:48.171Z
Learnt from: gdaviet
Repo: newton-physics/newton PR: 940
File: newton/examples/mpm/example_mpm_granular.py:92-101
Timestamp: 2025-10-29T14:55:48.171Z
Learning: In newton/examples/mpm/example_mpm_granular.py, the capture() method intentionally advances the simulation state once during CUDA graph capture. This is expected behavior because CUDA graph capture records exact memory addresses, so the state arrays (state_0, state_1) cannot be reset or reallocated after capture without invalidating the graph.
Applied to files:
newton/_src/solvers/implicit_mpm/solver_implicit_mpm.py
📚 Learning: 2025-08-19T12:27:30.629Z
Learnt from: preist-nvidia
Repo: newton-physics/newton PR: 579
File: newton/examples/example_mujoco.py:350-354
Timestamp: 2025-08-19T12:27:30.629Z
Learning: In Newton examples, Example.use_mujoco is a high-level attribute that controls whether to use MuJoCo solver vs other solvers (like XPBD), while SolverMuJoCo.use_mujoco_cpu controls the backend within MuJoCo (CPU vs Warp). These are separate concepts serving different purposes - the PR rename only applies to the solver parameter, not the Example class attributes.
Applied to files:
newton/_src/solvers/implicit_mpm/solver_implicit_mpm.py
📚 Learning: 2025-08-25T20:10:51.009Z
Learnt from: dylanturpin
Repo: newton-physics/newton PR: 634
File: newton/examples/ik/example_ik_h1.py:0-0
Timestamp: 2025-08-25T20:10:51.009Z
Learning: In Warp, creating a new wp.array() with an existing array and different shape (e.g., wp.array(existing_array, shape=new_shape)) creates a view into the same underlying memory buffer, not a copy. This means modifications through either view are automatically reflected in both arrays.
Applied to files:
newton/_src/utils/recorder.py
🧬 Code graph analysis (4)
newton/_src/solvers/solver.py (1)
newton/_src/sim/contacts.py (1)
device(110-114)
newton/_src/solvers/style3d/collision/bvh/bvh.py (2)
newton/_src/sim/contacts.py (1)
device(110-114)newton/_src/solvers/solver.py (1)
device(169-176)
newton/tests/test_coloring.py (2)
newton/_src/sim/builder.py (1)
particle_count(990-994)newton/_src/sim/graph_coloring.py (1)
ColoringAlgorithm(23-25)
newton/examples/diffsim/example_diffsim_cloth.py (2)
newton/examples/diffsim/example_diffsim_ball.py (1)
render(176-206)newton/examples/diffsim/example_diffsim_soft_body.py (1)
render(331-359)
🪛 GitHub Actions: Pull Request
newton/_src/core/types.py
[error] 26-26: ImportError: cannot import name 'DeviceLike' from 'warp' while importing the newton package during 'uv run python -c "import newton; print(f'Newton {newton.version} imported successfully')"'.
🪛 Ruff (0.14.10)
newton/_src/viewer/viewer_gl.py
611-611: Undefined name warp
(F821)
newton/_src/solvers/style3d/linear_solver.py
230-230: Unused noqa directive (non-enabled: PLC0415)
Remove unused noqa directive
(RUF100)
newton/_src/viewer/viewer.py
586-586: Unused noqa directive (non-enabled: PLC0415)
Remove unused noqa directive
(RUF100)
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Run GPU Benchmarks / Run GPU Benchmarks on AWS EC2
🔇 Additional comments (28)
docs/generate_api.py (1)
107-109: LGTM! Updated to use dedicated struct type checker.The change from
isinstance(attr, wp.codegen.Struct)towp.types.type_is_struct(attr)correctly updates the struct detection mechanism to align with the internal API migration.newton/_src/solvers/solver.py (1)
169-169: LGTM! Type annotation updated to wp.Device.The change from
wp.context.Devicetowp.Devicecorrectly updates the type annotation to align with the updated Warp API structure. The runtime behavior remains unchanged.newton/_src/utils/import_mjcf.py (1)
236-238: LGTM! Vector constructor updated to internal type API.The changes from
wp.vec(...)towp.types.vector(...)correctly update the vector constructor usage to align with the internal Warp type API. The runtime behavior is preserved - the same vector values are created.newton/_src/sim/style3d/builder_style3d.py (1)
601-601: LGTM! Internal API migration addresses deprecation warning.The update from
wp.utils.MeshAdjacencytowp._src.utils.MeshAdjacencycorrectly addresses the Warp v1.11.0 deprecation. This internal module usage is appropriate for Newton's internal code.newton/_src/solvers/style3d/linear_solver.py (1)
230-245: LGTM! Internal Warp API migration is correct.The migration from
warp.context.runtimetowarp._src.context.runtimeand fromwp.types.type_lengthtowp._src.types.type_lengthcorrectly addresses the Warp v1.11.0 deprecation warnings.newton/examples/robot/example_robot_anymal_c_walk.py (1)
81-81: LGTM! Updated to use Warp's namespaced API.The change from importing
device_to_torchto usingwp.device_to_torch()directly aligns with Warp's updated API structure and addresses the deprecation warnings.newton/_src/utils/selection.py (1)
511-511: LGTM! Improved by using public Warp API.Replacing the
isinstance(attrib, wp.codegen.StructInstance)check withwp.types.is_struct(attrib)is a better approach that uses Warp's public API instead of internal implementation details. This makes the code more maintainable.newton/_src/utils/recorder.py (2)
556-557: LGTM! Updated to use public Device type.The change from
wp.context.Devicetowp.Devicecorrectly uses Warp's public API for the Device type, addressing the deprecation warning.
762-762: LGTM! Corrected dtype resolution namespace.The change from
getattr(wp.types, dtype_str)togetattr(wp, dtype_str)correctly resolves Warp dtypes from the publicwpnamespace where they are exposed (e.g.,wp.float32,wp.vec3), rather than the internalwp.typesmodule.newton/_src/geometry/sdf_mc.py (1)
63-66: Switch towp._src.marching_cubesmaintains the same MC table behaviorThe new lookups for
tri_range_table,tri_local_inds_table, andcorner_offsets_tableare device‑correct and consistent with how these tables are consumed later (types and indexing still line up). This looks like a pure import‑path update to silence Warp’s deprecation warnings, with no functional change.Please just confirm your pinned Warp version is recent enough that
wp._src.marching_cubesexposes these symbols and that the marching‑cubes tests pass on both CPU and CUDA devices.newton/_src/sim/builder.py (2)
1611-1617: Usingwp._src.context.runtime.core.wp_builtin_mul_transformf_transformfkeeps add_builder semantics intactResolving the C transform‑multiply entry point from
wp._src.context.runtime.coreinstead of the deprecated public path preserves the existingtransform_mulbehavior (float32 transforms in/out, same ctypes call pattern) while avoiding repeated overload resolution. This is a straight import‑path update with no logic change in the builder.Given this now depends on an internal
_srcsymbol, please verify your Warp pin matches the version that exposeswp_builtin_mul_transformf_transformfunderwp._src.context.runtime.coreand thatadd_builderis exercised in your model‑composition tests. Based on learnings, relying on_srcis acceptable here because the project already targets nightly Warp builds.
5205-5215: Mesh adjacency viawp._src.utils.MeshAdjacencyis consistent with prior behaviorConstructing
MeshAdjacencyfromself.tri_indices[start_tri:end_tri]andend_tri - start_triis unchanged semantically; only the class is now resolved fromwp._src.utilsinstead ofwp.utils. The subsequent edge extraction and calls intoadd_edgesstill operate on the same(o0, o1, v0, v1)layout, so cloth bending edge generation remains correct.Since this now uses
wp._src.utils.MeshAdjacency, please confirm your Warp version exposes that symbol and that cloth/MPM tests (especially ones exercisingadd_cloth_mesh) pass on your supported devices.newton/_src/solvers/vbd/particle_vbd_kernels.py (1)
54-55: LGTM! Explicit type references address deprecation warnings.The update to use
wp.types.matrixandwp.float32instead of directly imported aliases is more explicit and aligns with Warp's updated API patterns. This eliminates reliance on legacy type imports that were marked for deprecation.newton/_src/solvers/implicit_mpm/solver_implicit_mpm.py (1)
1741-1741: LGTM! Simplified CUDA graph enablement logic.The direct boolean check is cleaner than the previous try/except guarded approach. This change is consistent with the similar update in
newton/_src/utils/__init__.pyand aligns with the PR's goal of addressing Warp deprecation warnings.newton/_src/utils/__init__.py (1)
222-229: LGTM! Simplified API usage aligns with Warp deprecation fixes.The direct boolean check via
wp.is_conditional_graph_supported()is cleaner than the previous try/except guarded assertion approach. This simplification aligns with the PR's goal of addressing Warp v1.11.0 deprecation warnings.newton/_src/solvers/vbd/rigid_vbd_kernels.py (1)
68-68: LGTM: Clean migration to fully-qualified Warp type path.The update from the old import pattern to
wp.types.vector(length=6, dtype=wp.float32)correctly addresses the Warp v1.11.0 deprecation warnings while maintaining the same runtime behavior.newton/_src/solvers/implicit_mpm/solve_rheology.py (2)
23-23: LGTM: Import path updated to match Warp's internal reorganization.The migration of
symmetric_eigenvalues_qrfromwarp.fem.utilstowarp.fem.linalgaligns with Warp's internal module restructuring.
986-991: LGTM: Correct computation of velocity delta.The explicit
beta=-1.0parameter correctly computesprev_collider_velocity = collider_velocity - prev_collider_velocity, which is then used asdelta_velocityon line 992. This maintains the documented behavior:collider_velocity += rigidity_mat @ (collider_velocity - prev_collider_velocity).newton/_src/solvers/style3d/collision/bvh/bvh.py (2)
69-69: LGTM: Device type annotation updated to current Warp API.The change from
wp.context.Devicetowp.Deviceaddresses the Warp v1.11.0 deprecation warnings. This pattern is consistently applied across all BVH class constructors (lines 69, 248, 394).
552-553: LGTM: Device retrieval updated to non-deprecated API.The test code correctly uses
wp.get_device()instead of the deprecatedwp.context.get_device().newton/examples/diffsim/example_diffsim_ball.py (1)
31-31: LGTM: Import path updated to internal Warp API.The migration to
warp._src.render.utilsis consistent with similar changes across other diffsim examples and aligns with Warp v1.11.0's internal API structure.newton/_src/core/types.py (1)
26-26: The import statement is correct and works in Warp v1.11+.The code
from warp import DeviceLike as Devicelikeis valid. DeviceLike is exported at the top level of the warp module in version 1.11.0 and later, which matches Newton's requirement ofwarp-lang>=1.11.0.dev20251205. The CI minimal-import-test confirms thatimport newtonsucceeds across multiple Python versions, which would fail if this import were broken.Likely an incorrect or invalid review comment.
newton/_src/sim/graph_coloring.py (1)
233-238: LGTM: Internal module appropriately uses Warp internal APIs.The migration from
wp.context.runtime.coretowp._src.context.runtime.corefor graph coloring functions is appropriate since this code is within Newton's internal_srcmodule. Internal modules using internal Warp APIs is the expected pattern.Also applies to: 241-247
newton/tests/test_coloring.py (1)
142-147: LGTM: Test code appropriately uses Warp internal APIs.The migration to
wp._src.context.runtime.corefor graph coloring functions in test code is acceptable. Based on learnings, tests in Newton can import and use private_srcinternal modules when needed for testing purposes.Also applies to: 155-160, 170-175, 176-182, 190-195, 196-202
newton/examples/diffsim/example_diffsim_spring_cage.py (1)
29-29: Address internal Warp API dependency across multiple examples and internal code.The import of
bourke_color_mapfromwarp._src.render.utilsappears in at least 5 example files (example_diffsim_drone.py, example_diffsim_cloth.py, example_diffsim_ball.py, example_diffsim_soft_body.py, and this file) as well as Newton's internal viewer code. This pattern suggests deprecation of a previous public API, but exposes Newton to stability risks if Warp changes this internal module.Clarify whether Warp provides a public API alternative for
bourke_color_mapor documentswarp._src.render.utilsas the official migration path. If no public alternative exists, consider requesting one upstream from Warp or documenting this constraint in Newton's examples.newton/examples/diffsim/example_diffsim_cloth.py (2)
214-214: LGTM!The usage of
bourke_color_mapis correct and consistent with the imported function.
31-31: Using internal_srcAPI in example code that users may copy.Warp v1.11.0 does not expose
bourke_color_mapthrough its public rendering API; it is only available viawarp._src.render.utils. While this imports an internal API that may change without notice, this is the necessary interim solution. The approach is consistent across all examples in this PR (cloth, ball, drone, soft_body, spring_cage), and as noted in the PR description, this is temporary while awaiting Warp's public API to stabilize.newton/_src/sim/contacts.py (1)
20-20: Good refactoring from internal to public API.This change correctly moves from the internal
warp.context.Devicelikepath to the publicwarp.DeviceLikeAPI. The alias maintains Newton's internal naming convention (Devicelikewith lowercase 'l').
02ad8ec to
4ecbf43
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Fix all issues with AI Agents 🤖
In @newton/_src/viewer/viewer_gl.py:
- Line 611: The code references an undefined name "warp" when calling
warp._src.render.render_opengl.copy_rgb_frame_uint8; update that reference to
use the imported alias "wp" instead (i.e., call
wp._src.render.render_opengl.copy_rgb_frame_uint8) so the correct module object
is used; locate the occurrence in viewer_gl.py where copy_rgb_frame_uint8 is
referenced and replace "warp" with "wp".
🧹 Nitpick comments (1)
newton/_src/viewer/viewer.py (1)
586-586: Remove unused noqa directive.The
# noqa: PLC0415directive is unnecessary since PLC0415 (import-outside-toplevel) is not enabled in the Ruff configuration.🔎 Proposed fix
- from warp._src.render.utils import solidify_mesh # noqa: PLC0415 + from warp._src.render.utils import solidify_mesh
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (27)
docs/generate_api.pynewton/_src/core/types.pynewton/_src/geometry/sdf_mc.pynewton/_src/sim/builder.pynewton/_src/sim/contacts.pynewton/_src/sim/graph_coloring.pynewton/_src/sim/style3d/builder_style3d.pynewton/_src/solvers/implicit_mpm/solve_rheology.pynewton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/_src/solvers/solver.pynewton/_src/solvers/style3d/collision/bvh/bvh.pynewton/_src/solvers/style3d/linear_solver.pynewton/_src/solvers/vbd/particle_vbd_kernels.pynewton/_src/solvers/vbd/rigid_vbd_kernels.pynewton/_src/utils/__init__.pynewton/_src/utils/import_mjcf.pynewton/_src/utils/recorder.pynewton/_src/utils/selection.pynewton/_src/viewer/viewer.pynewton/_src/viewer/viewer_gl.pynewton/examples/diffsim/example_diffsim_ball.pynewton/examples/diffsim/example_diffsim_cloth.pynewton/examples/diffsim/example_diffsim_drone.pynewton/examples/diffsim/example_diffsim_soft_body.pynewton/examples/diffsim/example_diffsim_spring_cage.pynewton/examples/robot/example_robot_anymal_c_walk.pynewton/tests/test_coloring.py
🚧 Files skipped from review as they are similar to previous changes (16)
- newton/_src/sim/style3d/builder_style3d.py
- newton/_src/utils/recorder.py
- newton/_src/sim/graph_coloring.py
- newton/_src/utils/init.py
- newton/examples/diffsim/example_diffsim_ball.py
- newton/_src/solvers/vbd/particle_vbd_kernels.py
- newton/_src/solvers/solver.py
- newton/_src/sim/contacts.py
- newton/_src/utils/import_mjcf.py
- newton/_src/solvers/implicit_mpm/solver_implicit_mpm.py
- newton/_src/sim/builder.py
- newton/examples/diffsim/example_diffsim_drone.py
- newton/_src/core/types.py
- newton/examples/diffsim/example_diffsim_spring_cage.py
- newton/examples/robot/example_robot_anymal_c_walk.py
- newton/_src/geometry/sdf_mc.py
🧰 Additional context used
🧠 Learnings (23)
📓 Common learnings
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/_src/solvers/featherstone/kernels.py:75-75
Timestamp: 2025-08-12T18:04:06.577Z
Learning: The Newton physics framework requires nightly Warp builds, which means compatibility concerns with older stable Warp versions (like missing functions such as wp.spatial_adjoint) are not relevant for this project.
Learnt from: shi-eric
Repo: newton-physics/newton PR: 521
File: newton/examples/example_cloth_hanging.py:36-36
Timestamp: 2025-08-12T05:17:34.423Z
Learning: The Newton migration guide (docs/migration.rst) is specifically for documenting how to migrate existing warp.sim functionality to Newton equivalents. New Newton-only features that didn't exist in warp.sim do not need migration documentation.
📚 Learning: 2025-08-12T17:58:16.929Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/tests/test_ik.py:25-26
Timestamp: 2025-08-12T17:58:16.929Z
Learning: In the Newton physics engine codebase, it's acceptable for tests to import and use private `_src` internal modules and functions when needed for testing purposes, even though this breaks the public API boundary. This is an intentional project decision for test code.
Applied to files:
newton/tests/test_coloring.pynewton/_src/solvers/style3d/linear_solver.py
📚 Learning: 2025-08-12T17:52:15.009Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/_src/utils/import_mjcf.py:226-231
Timestamp: 2025-08-12T17:52:15.009Z
Learning: In the Newton codebase, when passing array-like objects (numpy arrays, lists, tuples) to wp.vec3(), the consistent pattern is to use the unpacking operator: wp.vec3(*array) rather than wp.vec3(array). This pattern is used throughout newton/_src/utils/import_mjcf.py and newton/_src/core/types.py.
Applied to files:
newton/_src/utils/selection.pynewton/_src/solvers/vbd/rigid_vbd_kernels.py
📚 Learning: 2025-09-18T07:05:56.836Z
Learnt from: gdaviet
Repo: newton-physics/newton PR: 750
File: newton/_src/solvers/implicit_mpm/solve_rheology.py:969-986
Timestamp: 2025-09-18T07:05:56.836Z
Learning: In newton/_src/solvers/implicit_mpm/solve_rheology.py, transposed_strain_mat parameter cannot be None - the type signature was corrected to reflect this guarantee, eliminating the need for None checks when accessing transposed_strain_mat.offsets.
Applied to files:
newton/_src/solvers/implicit_mpm/solve_rheology.pynewton/_src/solvers/style3d/linear_solver.py
📚 Learning: 2025-09-09T11:03:41.928Z
Learnt from: gdaviet
Repo: newton-physics/newton PR: 750
File: newton/_src/solvers/implicit_mpm/solve_rheology.py:892-895
Timestamp: 2025-09-09T11:03:41.928Z
Learning: In newton/_src/solvers/implicit_mpm/solve_rheology.py, passing None for compliance_mat_diagonal is intentional to avoid loading zeros from global memory when compliance_mat is None, rather than creating a zero matrix and extracting its diagonal.
Applied to files:
newton/_src/solvers/implicit_mpm/solve_rheology.py
📚 Learning: 2025-08-12T05:17:34.423Z
Learnt from: shi-eric
Repo: newton-physics/newton PR: 521
File: newton/examples/example_cloth_hanging.py:36-36
Timestamp: 2025-08-12T05:17:34.423Z
Learning: The Newton migration guide (docs/migration.rst) is specifically for documenting how to migrate existing warp.sim functionality to Newton equivalents. New Newton-only features that didn't exist in warp.sim do not need migration documentation.
Applied to files:
newton/_src/solvers/implicit_mpm/solve_rheology.pynewton/examples/diffsim/example_diffsim_soft_body.pynewton/_src/solvers/vbd/rigid_vbd_kernels.pynewton/_src/solvers/style3d/linear_solver.pynewton/_src/viewer/viewer.py
📚 Learning: 2025-08-12T05:17:34.423Z
Learnt from: shi-eric
Repo: newton-physics/newton PR: 521
File: newton/examples/example_cloth_hanging.py:36-36
Timestamp: 2025-08-12T05:17:34.423Z
Learning: The STYLE3D solver in Newton is a new solver that did not exist in warp.sim, so it does not require any migration documentation.
Applied to files:
newton/_src/solvers/implicit_mpm/solve_rheology.pynewton/_src/solvers/style3d/linear_solver.py
📚 Learning: 2025-12-12T08:45:43.428Z
Learnt from: nvtw
Repo: newton-physics/newton PR: 1221
File: newton/examples/example_sdf.py:277-287
Timestamp: 2025-12-12T08:45:43.428Z
Learning: In Newtown (Newton) example code, specifically files under newton/examples, computing contacts once per frame and reusing them across all substeps is an intentional design choice, not a bug. Reviewers should verify that contacts are computed before the substep loop and reused for every substep within the same frame. This pattern reduces redundant work and preserves frame-consistency; do not flag as a regression unless the behavior is changed for correctness or performance reasons.
Applied to files:
newton/examples/diffsim/example_diffsim_cloth.pynewton/examples/diffsim/example_diffsim_soft_body.py
📚 Learning: 2025-08-12T18:04:06.577Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/_src/solvers/featherstone/kernels.py:75-75
Timestamp: 2025-08-12T18:04:06.577Z
Learning: The Newton physics framework requires nightly Warp builds, which means compatibility concerns with older stable Warp versions (like missing functions such as wp.spatial_adjoint) are not relevant for this project.
Applied to files:
newton/_src/solvers/vbd/rigid_vbd_kernels.pynewton/_src/solvers/style3d/linear_solver.pynewton/_src/viewer/viewer_gl.py
📚 Learning: 2025-09-22T21:08:31.901Z
Learnt from: dylanturpin
Repo: newton-physics/newton PR: 806
File: newton/examples/ik/example_ik_franka.py:121-123
Timestamp: 2025-09-22T21:08:31.901Z
Learning: In the newton physics framework, when creating warp arrays for IK solver joint variables using wp.array(self.model.joint_q, shape=(1, coord_count)), the resulting array acts as a reference/pointer to the original model's joint coordinates, so updates from the IK solver automatically reflect in the model's joint_q buffer used for rendering.
Applied to files:
newton/_src/solvers/vbd/rigid_vbd_kernels.pynewton/_src/solvers/style3d/linear_solver.pynewton/_src/viewer/viewer_gl.py
📚 Learning: 2025-09-22T21:08:31.901Z
Learnt from: dylanturpin
Repo: newton-physics/newton PR: 806
File: newton/examples/ik/example_ik_franka.py:121-123
Timestamp: 2025-09-22T21:08:31.901Z
Learning: In the newton physics framework, when creating warp arrays for IK solver joint variables using wp.array(self.model.joint_q, shape=(1, coord_count)), the resulting array acts as a reference/pointer to the original model's joint coordinates, so updates from the IK solver automatically reflect in the model's joint_q buffer used for rendering, despite the general warp documentation suggesting copies are made by default.
Applied to files:
newton/_src/solvers/vbd/rigid_vbd_kernels.pynewton/_src/solvers/style3d/linear_solver.pynewton/_src/viewer/viewer_gl.py
📚 Learning: 2025-08-18T15:56:26.587Z
Learnt from: adenzler-nvidia
Repo: newton-physics/newton PR: 552
File: newton/_src/solvers/mujoco/solver_mujoco.py:0-0
Timestamp: 2025-08-18T15:56:26.587Z
Learning: In Newton's MuJoCo solver, when transforming joint axes from Newton's internal frame to MuJoCo's expected frame, use wp.quat_rotate(joint_rot, axis) not wp.quat_rotate_inv(joint_rot, axis). The joint_rot represents rotation from joint-local to body frame, so forward rotation is correct.
Applied to files:
newton/_src/solvers/vbd/rigid_vbd_kernels.py
📚 Learning: 2025-09-25T16:14:22.033Z
Learnt from: dylanturpin
Repo: newton-physics/newton PR: 806
File: newton/_src/sim/ik/ik_objectives.py:0-0
Timestamp: 2025-09-25T16:14:22.033Z
Learning: In NVIDIA Warp's Newton physics library, wp.transform supports direct numerical indexing (e.g., body_tf[0], body_tf[1], body_tf[2] for position and body_tf[3], body_tf[4], body_tf[5], body_tf[6] for quaternion components) to access its elements. This is the standard API used throughout the codebase.
Applied to files:
newton/_src/solvers/vbd/rigid_vbd_kernels.py
📚 Learning: 2025-11-24T10:44:09.613Z
Learnt from: gdaviet
Repo: newton-physics/newton PR: 1108
File: newton/_src/solvers/implicit_mpm/rasterized_collisions.py:94-129
Timestamp: 2025-11-24T10:44:09.613Z
Learning: In Warp, wp.normalize() returns a zero vector (or zero quaternion) when given a zero-length input, so explicit zero-length checks before normalization are not required.
Applied to files:
newton/_src/solvers/vbd/rigid_vbd_kernels.py
📚 Learning: 2025-12-01T17:00:28.889Z
Learnt from: camevor
Repo: newton-physics/newton PR: 1161
File: newton/_src/solvers/mujoco/kernels.py:1268-1268
Timestamp: 2025-12-01T17:00:28.889Z
Learning: MuJoCo Warp spatial vectors (e.g., cacc, cvel) use the convention (angular, linear), which is opposite to Newton's (linear, angular) convention. When converting from MuJoCo Warp to Newton format, spatial_top() on MuJoCo Warp data extracts the angular component, and spatial_bottom() extracts the linear component.
Applied to files:
newton/_src/solvers/vbd/rigid_vbd_kernels.pynewton/_src/solvers/style3d/linear_solver.py
📚 Learning: 2025-11-28T11:12:40.805Z
Learnt from: camevor
Repo: newton-physics/newton PR: 1146
File: newton/examples/basic/example_basic_joints.py:206-213
Timestamp: 2025-11-28T11:12:40.805Z
Learning: In Newton's standard solvers (XPBD, SemiImplicit, SolverMuJoCo), spatial vectors in State.body_qd use the ordering (linear, angular): wp.spatial_top(qd) returns linear velocity and wp.spatial_bottom(qd) returns angular velocity. This is the opposite of typical Modern Robotics spatial twist notation where (angular, linear) is used.
Applied to files:
newton/_src/solvers/vbd/rigid_vbd_kernels.py
📚 Learning: 2025-09-26T05:58:21.013Z
Learnt from: WenchaoHuang
Repo: newton-physics/newton PR: 835
File: newton/_src/solvers/style3d/collision/collision.py:49-53
Timestamp: 2025-09-26T05:58:21.013Z
Learning: In newton/_src/solvers/style3d/collision/collision.py, the broad_phase buffers (broad_phase_ee, broad_phase_ef, broad_phase_vf) created with wp.array() don't need zero-initialization because they follow a write-first-read-later pattern: BVH query kernels in frame_begin() populate these buffers completely (write-only operations), and collision kernels only read from them afterward in accumulate_contact_force(), ensuring no undefined reads occur.
Applied to files:
newton/_src/solvers/style3d/collision/bvh/bvh.py
📚 Learning: 2025-09-26T05:58:21.013Z
Learnt from: WenchaoHuang
Repo: newton-physics/newton PR: 835
File: newton/_src/solvers/style3d/collision/collision.py:49-53
Timestamp: 2025-09-26T05:58:21.013Z
Learning: In newton/_src/solvers/style3d/collision/collision.py, the broad_phase buffers (broad_phase_ee, broad_phase_ef, broad_phase_vf) created with wp.array() don't need zero-initialization because the BVH query kernels that use them always write the count to query_results[0, tid] = 0 first before populating any data, ensuring no undefined reads occur.
Applied to files:
newton/_src/solvers/style3d/collision/bvh/bvh.py
📚 Learning: 2025-10-30T07:28:13.112Z
Learnt from: nvtw
Repo: newton-physics/newton PR: 984
File: newton/_src/geometry/broad_phase_nxn.py:318-336
Timestamp: 2025-10-30T07:28:13.112Z
Learning: In Newton's BroadPhaseAllPairs class (newton/_src/geometry/broad_phase_nxn.py), device management is the caller's responsibility. The library intentionally does not perform automatic device transfers for precomputed arrays in the launch method, even if there's a device mismatch. Users must ensure that the device specified in __init__ matches the device used in launch.
Applied to files:
newton/_src/solvers/style3d/collision/bvh/bvh.py
📚 Learning: 2025-09-17T21:34:05.267Z
Learnt from: gdaviet
Repo: newton-physics/newton PR: 750
File: newton/examples/mpm/example_mpm_granular.py:44-47
Timestamp: 2025-09-17T21:34:05.267Z
Learning: wp.Mesh (Warp mesh objects) expose triangle indices through the `indices` attribute, not `triangles`. The correct usage is `wp.Mesh(...).indices`, not `wp.Mesh(...).triangles`.
Applied to files:
newton/_src/solvers/style3d/collision/bvh/bvh.py
📚 Learning: 2025-08-25T20:10:59.536Z
Learnt from: dylanturpin
Repo: newton-physics/newton PR: 634
File: newton/examples/ik/example_ik_franka.py:0-0
Timestamp: 2025-08-25T20:10:59.536Z
Learning: In Newton's IK examples, when creating solver arrays with `wp.array(source_array, shape=new_shape)`, this creates a view into the same underlying memory rather than a copy. This means updates to the reshaped array are automatically reflected in the original array without needing explicit copy operations like `wp.copy()`.
Applied to files:
newton/_src/solvers/style3d/linear_solver.py
📚 Learning: 2025-08-12T17:58:00.815Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/_src/solvers/featherstone/kernels.py:18-20
Timestamp: 2025-08-12T17:58:00.815Z
Learning: In newton/_src/core/__init__.py, the function transform_twist is properly re-exported from the spatial module via "from .spatial import (..., transform_twist, ...)" and included in __all__, making it available for import as "from ...core import transform_twist" from other modules.
Applied to files:
newton/_src/solvers/style3d/linear_solver.py
📚 Learning: 2025-07-23T14:36:42.182Z
Learnt from: shi-eric
Repo: newton-physics/newton PR: 461
File: asv/benchmarks/envs/example_humanoid.py:40-41
Timestamp: 2025-07-23T14:36:42.182Z
Learning: In Warp benchmarks, explicit wp.init() calls are not needed in most circumstances since the first Warp API call that requires initialization will automatically call wp.init(). Explicit wp.init() in setup() methods is helpful when the ASV benchmark is measuring a Warp API call, as wp.init() has non-trivial overhead that should be excluded from the benchmark timing.
Applied to files:
newton/_src/viewer/viewer_gl.py
🧬 Code graph analysis (4)
newton/tests/test_coloring.py (2)
newton/_src/sim/builder.py (1)
particle_count(990-994)newton/_src/sim/graph_coloring.py (1)
ColoringAlgorithm(23-25)
newton/examples/diffsim/example_diffsim_cloth.py (2)
newton/examples/diffsim/example_diffsim_ball.py (1)
render(176-206)newton/examples/diffsim/example_diffsim_soft_body.py (1)
render(331-359)
newton/examples/diffsim/example_diffsim_soft_body.py (2)
newton/examples/diffsim/example_diffsim_ball.py (1)
render(176-206)newton/examples/diffsim/example_diffsim_cloth.py (1)
render(190-218)
newton/_src/solvers/style3d/collision/bvh/bvh.py (2)
newton/_src/sim/contacts.py (1)
device(110-114)newton/_src/solvers/solver.py (1)
device(169-176)
🪛 Ruff (0.14.10)
newton/_src/solvers/style3d/linear_solver.py
230-230: Unused noqa directive (non-enabled: PLC0415)
Remove unused noqa directive
(RUF100)
newton/_src/viewer/viewer.py
586-586: Unused noqa directive (non-enabled: PLC0415)
Remove unused noqa directive
(RUF100)
newton/_src/viewer/viewer_gl.py
611-611: Undefined name warp
(F821)
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Run GPU Benchmarks / Run GPU Benchmarks on AWS EC2
🔇 Additional comments (16)
newton/examples/diffsim/example_diffsim_soft_body.py (1)
32-32: LGTM! Import and usage correctly updated to internal path.The import path and function call have been consistently updated to use the internal
warp._src.render.utilsmodule, aligning with the PR's objective to address Warp v1.11.0 deprecation warnings.Also applies to: 355-355
newton/examples/diffsim/example_diffsim_cloth.py (1)
31-31: LGTM! Import and usage correctly updated to internal path.The import path and function call have been consistently updated to use the internal
warp._src.render.utilsmodule, aligning with the PR's objective to address Warp v1.11.0 deprecation warnings.Also applies to: 214-214
newton/_src/solvers/vbd/rigid_vbd_kernels.py (1)
68-68: LGTM! Public API paths verified correct.The change correctly addresses deprecation warnings by using fully-qualified public API paths (
wp.types.vectorandwp.float32) instead of internal symbols. Both are confirmed as public APIs in Warp v1.11.0, and the pattern is consistent with usage throughout the codebase (e.g.,solve_rheology.py,ray.py). The 32-bit float precision is preserved.newton/tests/test_coloring.py (4)
142-147: Internal API usage acceptable for tests.The migration to
wp._src.context.runtime.core.wp_graph_coloringis consistent with the project's practice of allowing tests to use internal_srcmodules when needed.Based on learnings, this is an intentional project decision for test code.
155-166: LGTM!Consistent with the internal API migration for graph coloring.
170-188: LGTM!Both
wp_graph_coloringandwp_balance_coloringcorrectly migrated to internal_srcpaths.
190-208: LGTM!MCS algorithm coloring and balancing correctly use the internal API paths.
docs/generate_api.py (1)
107-109: LGTM! Struct type detection migrated to public API.The change from
isinstance(attr, wp.codegen.Struct)towp.types.type_is_struct(attr)correctly addresses the deprecation by using Warp's public type-checking function. This properly categorizes struct types in the generated API documentation.newton/_src/utils/selection.py (1)
511-511: LGTM! Struct detection migrated to public API.The change from
isinstance(attrib, wp.codegen.StructInstance)towp.types.is_struct(attrib)correctly uses Warp's public type-checking API introduced in 1.11.0. The unwrapping logic remains intact.newton/_src/solvers/style3d/linear_solver.py (2)
230-230: Remove the unusednoqadirective.The
# noqa: PLC0415directive is flagged as unused because PLC0415 (import-outside-toplevel) is not enabled in the Ruff configuration.🔎 Proposed fix
- from warp._src.context import runtime # noqa: PLC0415 + from warp._src.context import runtime⛔ Skipped due to learnings
Learnt from: daniela-hase Repo: newton-physics/newton PR: 1044 File: newton/_src/sensors/tiled_camera_sensor.py:224-256 Timestamp: 2025-11-07T01:42:36.906Z Learning: In newton/_src/sensors/tiled_camera_sensor.py, the `# noqa: PLC0415` directives on the local PIL imports (lines 224 and 256 in save_color_image and save_depth_image methods) should be kept because they are required by the pre-commit configuration. The local imports are intentional for optional dependency handling.Learnt from: nvlukasz Repo: newton-physics/newton PR: 519 File: newton/_src/solvers/featherstone/kernels.py:75-75 Timestamp: 2025-08-12T18:04:06.577Z Learning: The Newton physics framework requires nightly Warp builds, which means compatibility concerns with older stable Warp versions (like missing functions such as wp.spatial_adjoint) are not relevant for this project.
230-230: Warp's_srcAPIs are explicitly unstable and undocumented for public use.Per NVIDIA Warp's official guidance, any symbols in the
_srcnamespace are internal implementation details without API/ABI stability guarantees and may change without notice across releases. Your code directly depends onwarp._src.context.runtimeandwarp._src.types.type_lengthto access Warp's C++ runtime core functions. While this change addresses Warp v1.11.0 deprecation warnings, it creates ongoing maintenance risk as Newton updates to newer Warp versions.Also applies to: 244-244
newton/_src/solvers/implicit_mpm/solve_rheology.py (3)
986-991: LGTM! Correct usage of migratedarray_axpyfunction.The function call correctly uses the imported
array_axpyfromwarp.fem.linalg, computing the velocity delta (prev_collider_velocity = collider_velocity - prev_collider_velocity) as intended. The parameters are preserved and semantics remain unchanged.
1440-1440: LGTM! Correct usage of migratedarray_axpyfunction.The function call correctly uses the imported
array_axpyfromwarp.fem.linalg, accumulatingdelta_stressintolocal_stressfor the Jacobi solver iteration. The parameters are preserved and semantics remain unchanged.
23-23: Import migration to warp.fem.linalg is correct for Warp v1.11.0.The functions
array_axpyandsymmetric_eigenvalues_qrhave been properly migrated towarp.fem.linalgper Warp v1.11.0 API reorganization. No remaining references to the deprecatedwarp.fem.utilsimport path exist in the codebase.newton/_src/solvers/style3d/collision/bvh/bvh.py (2)
552-553: LGTM! Test code updated to use public device API.The test code correctly uses
wp.get_device()instead ofwp.context.get_device(), consistent with the migration to Warp's public API.
69-69: INCORRECT: Changes appear to move away from the canonical public API.According to Warp v1.11.0 documentation,
wp.context.Deviceis the canonical public Device class, notwp.Device. The type annotation changes fromwp.context.Devicetowp.Devicemove away from the public API toward older notation, contradicting the review comment's claim that they "use the public API."The
wp.get_device()usage in test code is correct as it is part of the public API; however, the type annotations should remain aswp.context.Devicerather thanwp.Device.Likely an incorrect or invalid review comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Fix all issues with AI Agents 🤖
In @pyproject.toml:
- Line 28: The dependency constraint in pyproject.toml is invalid for the NVIDIA
PyPI index because stable warp-lang 1.11.0 doesn't exist there; update the
dependencies line that currently reads `dependencies = ["warp-lang>=1.11.0"]` to
reference a nightly build available on the NVIDIA index (for example
`warp-lang>=1.12.0.dev0` or a specific `1.12.0.dev*` release you verify exists)
so the package resolver can find warp-lang from the configured NVIDIA source.
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
uv.lockis excluded by!**/*.lock
📒 Files selected for processing (1)
pyproject.toml
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/_src/solvers/featherstone/kernels.py:75-75
Timestamp: 2025-08-12T18:04:06.577Z
Learning: The Newton physics framework requires nightly Warp builds, which means compatibility concerns with older stable Warp versions (like missing functions such as wp.spatial_adjoint) are not relevant for this project.
Learnt from: shi-eric
Repo: newton-physics/newton PR: 521
File: newton/examples/example_cloth_hanging.py:36-36
Timestamp: 2025-08-12T05:17:34.423Z
Learning: The Newton migration guide (docs/migration.rst) is specifically for documenting how to migrate existing warp.sim functionality to Newton equivalents. New Newton-only features that didn't exist in warp.sim do not need migration documentation.
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/tests/test_ik.py:25-26
Timestamp: 2025-08-12T17:58:16.929Z
Learning: In the Newton physics engine codebase, it's acceptable for tests to import and use private `_src` internal modules and functions when needed for testing purposes, even though this breaks the public API boundary. This is an intentional project decision for test code.
Learnt from: shi-eric
Repo: newton-physics/newton PR: 461
File: asv/benchmarks/envs/example_humanoid.py:40-41
Timestamp: 2025-07-23T14:36:42.182Z
Learning: In Warp benchmarks, explicit wp.init() calls are not needed in most circumstances since the first Warp API call that requires initialization will automatically call wp.init(). Explicit wp.init() in setup() methods is helpful when the ASV benchmark is measuring a Warp API call, as wp.init() has non-trivial overhead that should be excluded from the benchmark timing.
📚 Learning: 2025-08-27T23:33:32.527Z
Learnt from: shi-eric
Repo: newton-physics/newton PR: 660
File: pyproject.toml:28-28
Timestamp: 2025-08-27T23:33:32.527Z
Learning: In Python projects, it's normal and correct to have different warp-lang version specifications across files: pyproject.toml should specify minimum compatible versions using >= for flexibility, while specific environments like asv.conf.json can pin exact versions using == for reproducibility. These serve different purposes and should not be "aligned" to the same version.
Applied to files:
pyproject.toml
📚 Learning: 2025-08-21T15:51:07.824Z
Learnt from: shi-eric
Repo: newton-physics/newton PR: 592
File: pyproject.toml:64-70
Timestamp: 2025-08-21T15:51:07.824Z
Learning: Self-referencing optional dependencies (e.g., "package[extra]") have been supported since pip 21.2 and are valid in pyproject.toml. However, build backends differ in metadata emission: some flatten dependencies while others preserve self-references. This can affect lockfile generators and tooling. Testing with the specific build backend and dependency tools is recommended to ensure expected behavior.
Applied to files:
pyproject.toml
📚 Learning: 2025-08-12T18:04:06.577Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/_src/solvers/featherstone/kernels.py:75-75
Timestamp: 2025-08-12T18:04:06.577Z
Learning: The Newton physics framework requires nightly Warp builds, which means compatibility concerns with older stable Warp versions (like missing functions such as wp.spatial_adjoint) are not relevant for this project.
Applied to files:
pyproject.toml
📚 Learning: 2025-08-27T23:32:48.670Z
Learnt from: shi-eric
Repo: newton-physics/newton PR: 660
File: pyproject.toml:54-59
Timestamp: 2025-08-27T23:32:48.670Z
Learning: In the newton project's pyproject.toml, self-referential extras (e.g., `examples = ["newton[sim]", "newton[importers]", ...]`) are normal and encouraged for dependency management, rather than inlining the dependencies.
Applied to files:
pyproject.toml
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Run GPU Benchmarks / Run GPU Benchmarks on AWS EC2
- GitHub Check: Run GPU Tests / Run GPU Unit Tests on AWS EC2
3c90440 to
8334066
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
newton/_src/solvers/style3d/linear_solver.py (1)
230-245:array_innerinternals look correct; adjust lint suppression commentThe switch to
warp._src.context.runtimeandwp.types.type_size(a.dtype)matches the Warp-internal API and the expected signature forwp_array_inner_float_*. The only issue is the# noqa: PLC0415marker, which Ruff flags as an unusednoqa(RUF100).Consider making this a Pylint-only suppression to avoid Ruff warnings:
Proposed lint-only change
- from warp._src.context import runtime # noqa: PLC0415 + from warp._src.context import runtime # pylint: disable=import-outside-toplevelnewton/_src/viewer/viewer.py (1)
580-592:solidify_meshimport path is fine; fix unusednoqadirectiveUsing
warp._src.render.utils.solidify_meshhere is consistent with the rest of the PR. However, the inline# noqa: PLC0415is flagged by Ruff as an unusednoqadirective.If you still want to silence Pylint for this local import, prefer a Pylint-specific disable instead of
# noqa:Proposed lint-only change
- from warp._src.render.utils import solidify_mesh # noqa: PLC0415 + from warp._src.render.utils import solidify_mesh # pylint: disable=import-outside-toplevel
🧹 Nitpick comments (1)
newton/_src/sim/builder.py (1)
1609-1617: Direct use ofwp._srctransform cfunc looks fine; consider a small robustness guardThe switch to
wp._src.context.runtime.core.wp_builtin_mul_transformf_transformfkeeps the existing call pattern and should preserve behavior while satisfying Warp’s deprecation changes. Given this is an internal_srcsymbol, you might optionally wrap the lookup in a smalltry/exceptto fail with a clearer message if Warp ever shuffles internals:Optional defensive guard
- transform_mul_cfunc = wp._src.context.runtime.core.wp_builtin_mul_transformf_transformf + try: + transform_mul_cfunc = wp._src.context.runtime.core.wp_builtin_mul_transformf_transformf + except AttributeError as e: + raise RuntimeError( + "Required Warp symbol 'wp_builtin_mul_transformf_transformf' not found. " + "Ensure you are running a compatible Warp (>=1.11.x) build." + ) from ePlease also double‑check that this symbol path matches the Warp 1.11+ version you are targeting. Based on learnings, depending on
wp._srcin core Newton code is acceptable for this project.
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
uv.lockis excluded by!**/*.lock
📒 Files selected for processing (28)
docs/generate_api.pynewton/_src/core/types.pynewton/_src/geometry/sdf_mc.pynewton/_src/sim/builder.pynewton/_src/sim/contacts.pynewton/_src/sim/graph_coloring.pynewton/_src/sim/style3d/builder_style3d.pynewton/_src/solvers/implicit_mpm/solve_rheology.pynewton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/_src/solvers/solver.pynewton/_src/solvers/style3d/collision/bvh/bvh.pynewton/_src/solvers/style3d/linear_solver.pynewton/_src/solvers/vbd/particle_vbd_kernels.pynewton/_src/solvers/vbd/rigid_vbd_kernels.pynewton/_src/utils/__init__.pynewton/_src/utils/import_mjcf.pynewton/_src/utils/recorder.pynewton/_src/utils/selection.pynewton/_src/viewer/viewer.pynewton/_src/viewer/viewer_gl.pynewton/examples/diffsim/example_diffsim_ball.pynewton/examples/diffsim/example_diffsim_cloth.pynewton/examples/diffsim/example_diffsim_drone.pynewton/examples/diffsim/example_diffsim_soft_body.pynewton/examples/diffsim/example_diffsim_spring_cage.pynewton/examples/robot/example_robot_anymal_c_walk.pynewton/tests/test_coloring.pypyproject.toml
🚧 Files skipped from review as they are similar to previous changes (14)
- newton/_src/utils/selection.py
- newton/examples/diffsim/example_diffsim_drone.py
- newton/_src/utils/recorder.py
- newton/_src/solvers/style3d/collision/bvh/bvh.py
- newton/examples/robot/example_robot_anymal_c_walk.py
- newton/_src/core/types.py
- newton/_src/sim/style3d/builder_style3d.py
- newton/examples/diffsim/example_diffsim_soft_body.py
- newton/examples/diffsim/example_diffsim_ball.py
- newton/_src/sim/contacts.py
- newton/examples/diffsim/example_diffsim_spring_cage.py
- pyproject.toml
- newton/_src/solvers/vbd/rigid_vbd_kernels.py
- newton/_src/utils/import_mjcf.py
🧰 Additional context used
🧠 Learnings (24)
📓 Common learnings
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/_src/solvers/featherstone/kernels.py:75-75
Timestamp: 2025-08-12T18:04:06.577Z
Learning: The Newton physics framework requires nightly Warp builds, which means compatibility concerns with older stable Warp versions (like missing functions such as wp.spatial_adjoint) are not relevant for this project.
Learnt from: shi-eric
Repo: newton-physics/newton PR: 521
File: newton/examples/example_cloth_hanging.py:36-36
Timestamp: 2025-08-12T05:17:34.423Z
Learning: The Newton migration guide (docs/migration.rst) is specifically for documenting how to migrate existing warp.sim functionality to Newton equivalents. New Newton-only features that didn't exist in warp.sim do not need migration documentation.
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/tests/test_ik.py:25-26
Timestamp: 2025-08-12T17:58:16.929Z
Learning: In the Newton physics engine codebase, it's acceptable for tests to import and use private `_src` internal modules and functions when needed for testing purposes, even though this breaks the public API boundary. This is an intentional project decision for test code.
Learnt from: shi-eric
Repo: newton-physics/newton PR: 461
File: asv/benchmarks/envs/example_humanoid.py:40-41
Timestamp: 2025-07-23T14:36:42.182Z
Learning: In Warp benchmarks, explicit wp.init() calls are not needed in most circumstances since the first Warp API call that requires initialization will automatically call wp.init(). Explicit wp.init() in setup() methods is helpful when the ASV benchmark is measuring a Warp API call, as wp.init() has non-trivial overhead that should be excluded from the benchmark timing.
📚 Learning: 2025-08-12T05:17:34.423Z
Learnt from: shi-eric
Repo: newton-physics/newton PR: 521
File: newton/examples/example_cloth_hanging.py:36-36
Timestamp: 2025-08-12T05:17:34.423Z
Learning: The Newton migration guide (docs/migration.rst) is specifically for documenting how to migrate existing warp.sim functionality to Newton equivalents. New Newton-only features that didn't exist in warp.sim do not need migration documentation.
Applied to files:
newton/_src/utils/__init__.pynewton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/_src/sim/builder.pynewton/_src/viewer/viewer.pynewton/_src/solvers/implicit_mpm/solve_rheology.pynewton/_src/solvers/style3d/linear_solver.py
📚 Learning: 2025-08-12T18:04:06.577Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/_src/solvers/featherstone/kernels.py:75-75
Timestamp: 2025-08-12T18:04:06.577Z
Learning: The Newton physics framework requires nightly Warp builds, which means compatibility concerns with older stable Warp versions (like missing functions such as wp.spatial_adjoint) are not relevant for this project.
Applied to files:
newton/_src/utils/__init__.pynewton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/_src/sim/builder.pynewton/_src/solvers/vbd/particle_vbd_kernels.pynewton/_src/solvers/implicit_mpm/solve_rheology.pynewton/_src/solvers/style3d/linear_solver.pynewton/_src/viewer/viewer_gl.py
📚 Learning: 2025-09-18T07:05:56.836Z
Learnt from: gdaviet
Repo: newton-physics/newton PR: 750
File: newton/_src/solvers/implicit_mpm/solve_rheology.py:969-986
Timestamp: 2025-09-18T07:05:56.836Z
Learning: In newton/_src/solvers/implicit_mpm/solve_rheology.py, transposed_strain_mat parameter cannot be None - the type signature was corrected to reflect this guarantee, eliminating the need for None checks when accessing transposed_strain_mat.offsets.
Applied to files:
newton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/_src/solvers/implicit_mpm/solve_rheology.pynewton/_src/solvers/style3d/linear_solver.py
📚 Learning: 2025-12-12T15:23:30.014Z
Learnt from: vastsoun
Repo: newton-physics/newton PR: 1019
File: newton/_src/solvers/kamino/examples/sim/example_sim_basics_boxes_fourbar.py:149-163
Timestamp: 2025-12-12T15:23:30.014Z
Learning: In Kamino simulation examples under newton/_src/solvers/kamino/examples/sim/, the pattern where logging=True and use_cuda_graph=True creates a mismatch (SimulationLogger constructed but settings.compute_metrics and logger.log() calls guarded by `if not self.use_cuda_graph`) should not be flagged. These examples will be refactored in a future commit, and this pattern is intentionally deferred.
Applied to files:
newton/_src/solvers/implicit_mpm/solver_implicit_mpm.py
📚 Learning: 2025-08-19T12:27:30.629Z
Learnt from: preist-nvidia
Repo: newton-physics/newton PR: 579
File: newton/examples/example_mujoco.py:350-354
Timestamp: 2025-08-19T12:27:30.629Z
Learning: In Newton examples, there's a distinction between solver parameters and Example class attributes. The Example class can have its own use_mujoco attribute for controlling example-level behavior (like CUDA graphs, rendering logic), while the solver uses use_mujoco_cpu for backend selection. These serve different purposes and should not be conflated during API renames.
Applied to files:
newton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/_src/solvers/solver.py
📚 Learning: 2025-10-29T14:55:48.171Z
Learnt from: gdaviet
Repo: newton-physics/newton PR: 940
File: newton/examples/mpm/example_mpm_granular.py:92-101
Timestamp: 2025-10-29T14:55:48.171Z
Learning: In newton/examples/mpm/example_mpm_granular.py, the capture() method intentionally advances the simulation state once during CUDA graph capture. This is expected behavior because CUDA graph capture records exact memory addresses, so the state arrays (state_0, state_1) cannot be reset or reallocated after capture without invalidating the graph.
Applied to files:
newton/_src/solvers/implicit_mpm/solver_implicit_mpm.py
📚 Learning: 2025-08-19T12:27:30.629Z
Learnt from: preist-nvidia
Repo: newton-physics/newton PR: 579
File: newton/examples/example_mujoco.py:350-354
Timestamp: 2025-08-19T12:27:30.629Z
Learning: In Newton examples, Example.use_mujoco is a high-level attribute that controls whether to use MuJoCo solver vs other solvers (like XPBD), while SolverMuJoCo.use_mujoco_cpu controls the backend within MuJoCo (CPU vs Warp). These are separate concepts serving different purposes - the PR rename only applies to the solver parameter, not the Example class attributes.
Applied to files:
newton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/_src/solvers/solver.py
📚 Learning: 2025-09-17T21:34:05.267Z
Learnt from: gdaviet
Repo: newton-physics/newton PR: 750
File: newton/examples/mpm/example_mpm_granular.py:44-47
Timestamp: 2025-09-17T21:34:05.267Z
Learning: wp.Mesh (Warp mesh objects) expose triangle indices through the `indices` attribute, not `triangles`. The correct usage is `wp.Mesh(...).indices`, not `wp.Mesh(...).triangles`.
Applied to files:
newton/_src/sim/builder.py
📚 Learning: 2025-08-12T17:51:37.474Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/geometry.py:16-22
Timestamp: 2025-08-12T17:51:37.474Z
Learning: In the Newton public API refactor, common geometry symbols like ParticleFlags and ShapeFlags are now exposed at the top level in newton/__init__.py rather than through newton.geometry. The newton/geometry.py module is intentionally focused only on broad-phase collision detection classes (BroadPhaseAllPairs, BroadPhaseExplicit, BroadPhaseSAP).
Applied to files:
newton/_src/solvers/vbd/particle_vbd_kernels.py
📚 Learning: 2025-08-12T17:52:15.009Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/_src/utils/import_mjcf.py:226-231
Timestamp: 2025-08-12T17:52:15.009Z
Learning: In the Newton codebase, when passing array-like objects (numpy arrays, lists, tuples) to wp.vec3(), the consistent pattern is to use the unpacking operator: wp.vec3(*array) rather than wp.vec3(array). This pattern is used throughout newton/_src/utils/import_mjcf.py and newton/_src/core/types.py.
Applied to files:
newton/_src/solvers/vbd/particle_vbd_kernels.py
📚 Learning: 2025-09-25T16:14:22.033Z
Learnt from: dylanturpin
Repo: newton-physics/newton PR: 806
File: newton/_src/sim/ik/ik_objectives.py:0-0
Timestamp: 2025-09-25T16:14:22.033Z
Learning: In NVIDIA Warp's Newton physics library, wp.transform supports direct numerical indexing (e.g., body_tf[0], body_tf[1], body_tf[2] for position and body_tf[3], body_tf[4], body_tf[5], body_tf[6] for quaternion components) to access its elements. This is the standard API used throughout the codebase.
Applied to files:
newton/_src/solvers/vbd/particle_vbd_kernels.py
📚 Learning: 2025-09-22T21:08:31.901Z
Learnt from: dylanturpin
Repo: newton-physics/newton PR: 806
File: newton/examples/ik/example_ik_franka.py:121-123
Timestamp: 2025-09-22T21:08:31.901Z
Learning: In the newton physics framework, when creating warp arrays for IK solver joint variables using wp.array(self.model.joint_q, shape=(1, coord_count)), the resulting array acts as a reference/pointer to the original model's joint coordinates, so updates from the IK solver automatically reflect in the model's joint_q buffer used for rendering.
Applied to files:
newton/_src/solvers/vbd/particle_vbd_kernels.pynewton/_src/solvers/style3d/linear_solver.pynewton/_src/viewer/viewer_gl.py
📚 Learning: 2025-09-22T21:08:31.901Z
Learnt from: dylanturpin
Repo: newton-physics/newton PR: 806
File: newton/examples/ik/example_ik_franka.py:121-123
Timestamp: 2025-09-22T21:08:31.901Z
Learning: In the newton physics framework, when creating warp arrays for IK solver joint variables using wp.array(self.model.joint_q, shape=(1, coord_count)), the resulting array acts as a reference/pointer to the original model's joint coordinates, so updates from the IK solver automatically reflect in the model's joint_q buffer used for rendering, despite the general warp documentation suggesting copies are made by default.
Applied to files:
newton/_src/solvers/vbd/particle_vbd_kernels.pynewton/_src/solvers/style3d/linear_solver.pynewton/_src/viewer/viewer_gl.py
📚 Learning: 2025-09-25T16:14:22.033Z
Learnt from: dylanturpin
Repo: newton-physics/newton PR: 806
File: newton/_src/sim/ik/ik_objectives.py:0-0
Timestamp: 2025-09-25T16:14:22.033Z
Learning: wp.transform in NVIDIA Warp supports indexing using numerical indices (e.g., body_tf[0], body_tf[3], etc.) to access translation and rotation components. The indexing approach used in the Newton codebase is valid and compiles correctly.
Applied to files:
newton/_src/solvers/vbd/particle_vbd_kernels.py
📚 Learning: 2025-09-26T05:58:21.013Z
Learnt from: WenchaoHuang
Repo: newton-physics/newton PR: 835
File: newton/_src/solvers/style3d/collision/collision.py:49-53
Timestamp: 2025-09-26T05:58:21.013Z
Learning: In newton/_src/solvers/style3d/collision/collision.py, the broad_phase buffers (broad_phase_ee, broad_phase_ef, broad_phase_vf) created with wp.array() don't need zero-initialization because they follow a write-first-read-later pattern: BVH query kernels in frame_begin() populate these buffers completely (write-only operations), and collision kernels only read from them afterward in accumulate_contact_force(), ensuring no undefined reads occur.
Applied to files:
newton/_src/solvers/vbd/particle_vbd_kernels.py
📚 Learning: 2025-12-12T08:45:43.428Z
Learnt from: nvtw
Repo: newton-physics/newton PR: 1221
File: newton/examples/example_sdf.py:277-287
Timestamp: 2025-12-12T08:45:43.428Z
Learning: In Newtown (Newton) example code, specifically files under newton/examples, computing contacts once per frame and reusing them across all substeps is an intentional design choice, not a bug. Reviewers should verify that contacts are computed before the substep loop and reused for every substep within the same frame. This pattern reduces redundant work and preserves frame-consistency; do not flag as a regression unless the behavior is changed for correctness or performance reasons.
Applied to files:
newton/examples/diffsim/example_diffsim_cloth.py
📚 Learning: 2025-08-12T17:58:16.929Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/tests/test_ik.py:25-26
Timestamp: 2025-08-12T17:58:16.929Z
Learning: In the Newton physics engine codebase, it's acceptable for tests to import and use private `_src` internal modules and functions when needed for testing purposes, even though this breaks the public API boundary. This is an intentional project decision for test code.
Applied to files:
newton/tests/test_coloring.py
📚 Learning: 2025-09-09T11:03:41.928Z
Learnt from: gdaviet
Repo: newton-physics/newton PR: 750
File: newton/_src/solvers/implicit_mpm/solve_rheology.py:892-895
Timestamp: 2025-09-09T11:03:41.928Z
Learning: In newton/_src/solvers/implicit_mpm/solve_rheology.py, passing None for compliance_mat_diagonal is intentional to avoid loading zeros from global memory when compliance_mat is None, rather than creating a zero matrix and extracting its diagonal.
Applied to files:
newton/_src/solvers/implicit_mpm/solve_rheology.py
📚 Learning: 2025-08-12T05:17:34.423Z
Learnt from: shi-eric
Repo: newton-physics/newton PR: 521
File: newton/examples/example_cloth_hanging.py:36-36
Timestamp: 2025-08-12T05:17:34.423Z
Learning: The STYLE3D solver in Newton is a new solver that did not exist in warp.sim, so it does not require any migration documentation.
Applied to files:
newton/_src/solvers/implicit_mpm/solve_rheology.pynewton/_src/solvers/style3d/linear_solver.py
📚 Learning: 2025-08-25T20:10:59.536Z
Learnt from: dylanturpin
Repo: newton-physics/newton PR: 634
File: newton/examples/ik/example_ik_franka.py:0-0
Timestamp: 2025-08-25T20:10:59.536Z
Learning: In Newton's IK examples, when creating solver arrays with `wp.array(source_array, shape=new_shape)`, this creates a view into the same underlying memory rather than a copy. This means updates to the reshaped array are automatically reflected in the original array without needing explicit copy operations like `wp.copy()`.
Applied to files:
newton/_src/solvers/style3d/linear_solver.py
📚 Learning: 2025-12-01T17:00:28.889Z
Learnt from: camevor
Repo: newton-physics/newton PR: 1161
File: newton/_src/solvers/mujoco/kernels.py:1268-1268
Timestamp: 2025-12-01T17:00:28.889Z
Learning: MuJoCo Warp spatial vectors (e.g., cacc, cvel) use the convention (angular, linear), which is opposite to Newton's (linear, angular) convention. When converting from MuJoCo Warp to Newton format, spatial_top() on MuJoCo Warp data extracts the angular component, and spatial_bottom() extracts the linear component.
Applied to files:
newton/_src/solvers/style3d/linear_solver.py
📚 Learning: 2025-11-12T23:53:29.478Z
Learnt from: daniela-hase
Repo: newton-physics/newton PR: 1044
File: newton/_src/sensors/tiled_camera_sensor.py:451-466
Timestamp: 2025-11-12T23:53:29.478Z
Learning: In newton/_src/sensors/tiled_camera_sensor.py, the convert_camera_to_warp_arrays method extracts [:3, :3] from camera.get_view_matrix().reshape(4, 4) without transposing. This is correct because Pyglet's Mat4.look_at returns a column-major view matrix, and reshaping it as row-major in NumPy creates an implicit transpose, converting the world→camera rotation into the camera→world rotation that the renderer expects.
Applied to files:
newton/_src/viewer/viewer_gl.py
📚 Learning: 2025-08-25T20:10:51.009Z
Learnt from: dylanturpin
Repo: newton-physics/newton PR: 634
File: newton/examples/ik/example_ik_h1.py:0-0
Timestamp: 2025-08-25T20:10:51.009Z
Learning: In Warp, creating a new wp.array() with an existing array and different shape (e.g., wp.array(existing_array, shape=new_shape)) creates a view into the same underlying memory buffer, not a copy. This means modifications through either view are automatically reflected in both arrays.
Applied to files:
newton/_src/viewer/viewer_gl.py
🧬 Code graph analysis (4)
newton/_src/solvers/implicit_mpm/solver_implicit_mpm.py (2)
newton/_src/sim/contacts.py (1)
device(110-114)newton/_src/solvers/solver.py (1)
device(169-176)
newton/examples/diffsim/example_diffsim_cloth.py (3)
newton/examples/diffsim/example_diffsim_ball.py (1)
render(176-206)newton/examples/diffsim/example_diffsim_drone.py (1)
render(763-796)newton/examples/diffsim/example_diffsim_soft_body.py (1)
render(331-359)
newton/tests/test_coloring.py (2)
newton/_src/sim/builder.py (1)
particle_count(990-994)newton/_src/sim/graph_coloring.py (1)
ColoringAlgorithm(23-25)
newton/_src/solvers/solver.py (1)
newton/_src/sim/contacts.py (1)
device(110-114)
🪛 Ruff (0.14.10)
newton/_src/viewer/viewer.py
586-586: Unused noqa directive (non-enabled: PLC0415)
Remove unused noqa directive
(RUF100)
newton/_src/solvers/style3d/linear_solver.py
230-230: Unused noqa directive (non-enabled: PLC0415)
Remove unused noqa directive
(RUF100)
newton/_src/viewer/viewer_gl.py
611-611: Undefined name warp
(F821)
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Run GPU Tests / Run GPU Unit Tests on AWS EC2
- GitHub Check: Run GPU Benchmarks / Run GPU Benchmarks on AWS EC2
🔇 Additional comments (14)
newton/_src/utils/__init__.py (1)
222-229: Direct delegation incheck_conditional_graph_supportlooks goodReturning
wp.is_conditional_graph_supported()directly matches the documented intent and simplifies the helper without changing its external contract.newton/_src/solvers/vbd/particle_vbd_kernels.py (1)
54-56: Updatedmat32matrix type aligns with newer Warp type patternsDefining
mat32viawp.types.matrix(shape=(3, 2), dtype=wp.float32)preserves the original 3×2 layout and integrates cleanly with the existing uses ofmat32in this module.newton/_src/solvers/implicit_mpm/solve_rheology.py (3)
986-991: LGTM! Usage updated consistently with import change.The call to
array_axpy()correctly uses the updated import fromwarp.fem.linalg.
1440-1440: LGTM! Usage updated consistently with import change.The call to
array_axpy()correctly uses the updated import fromwarp.fem.linalg.
23-23: LGTM! Import paths updated to new Warp module organization.The import change from
warp.fem.utilstowarp.fem.linalgforarray_axpyandsymmetric_eigenvalues_qrreflects Warp's module reorganization, appropriately placing linear algebra operations in thelinalgmodule. Both functions are present in Warp 1.11.0'sfem.linalgmodule and are correctly used throughout the file.newton/examples/diffsim/example_diffsim_cloth.py (2)
214-214: Usage consistent with updated import.The usage of
bourke_color_map()correctly matches the updated import fromwarp._src.render.utils.
31-31: No action required—the code correctly uses the public Warp API.The file already imports and uses
wp.render.bourke_color_mapfrom the publicwarp.rendermodule (line 31:import warp.render, line 214:wp.render.bourke_color_map(...)). The review comment references a non-existent internal import path (warp._src.render.utils.bourke_color_map). Web search confirms thatbourke_color_mapis documented and available in Warp 1.11.0's publicwarp.renderAPI, so the current implementation follows best practices and requires no changes.Likely an incorrect or invalid review comment.
newton/_src/solvers/solver.py (1)
169-169: Type annotation correctly uses Warp's public Device API.The return type annotation
wp.Deviceis the recommended public type for device type hints in Warp, as documented in the official Warp Device API reference. Using the public export instead of the internalwp.context.Devicepath is correct and aligns with Warp's best practices.newton/_src/geometry/sdf_mc.py (1)
63-65: Reconsider dependency on internal Warp marching cubes lookup table functions.Lines 63-65 access internal Warp APIs from
wp._src.marching_cubesto obtain lookup tables for marching cubes implementation. While Warp 1.11.0 provides public marching cubes APIs (extract_surface_marching_cubesfunction andMarchingCubesclass), the code requires low-level lookup table access to implement custom GPU kernels. Verify whether public APIs expose equivalent lookup table access or if internal dependency is unavoidable. If internal usage is necessary, document the justification to acknowledge the maintainability risk.docs/generate_api.py (1)
107-107: Acknowledge new file using appropriate Warp public API functions.This file is newly created and correctly uses the public Warp API functions
wp.types.type_is_struct()andwp.types.type_is_value()to identify struct and value types rather than relying on internal implementation details. The implementation is sound.newton/_src/sim/builder.py (1)
5205-5218:MeshAdjacency_srcpath change is consistent with the existing usageUsing
wp._src.utils.MeshAdjacency(self.tri_indices[start_tri:end_tri], end_tri - start_tri)keeps the previous semantics: you pass the local triangle slice plus its count and then derive edge tuples as before. This should address the Warp deprecation without changing behavior.Please just confirm that
MeshAdjacencyis indeed exported fromwp._src.utilsin the Warp version you pin to (>=1.11.x). Based on learnings, relying on_srchere is in line with the project’s acceptance of Warp internals.newton/tests/test_coloring.py (1)
142-142: Test usage of internal Warp API is acceptable per project guidelines.The migration from
wp.context.runtime.core.wp_graph_coloringandwp.context.runtime.core.wp_balance_coloringto their_srcequivalents is consistent with the project's approach to testing. Based on learnings, test code in Newton intentionally uses private internal modules when needed for testing purposes.Also applies to: 155-155, 170-170, 176-176, 190-190, 196-196
newton/_src/sim/graph_coloring.py (1)
233-238: Clarify the stability and migration plan for internal Warp APIs.This code uses internal Warp APIs (
wp._src.context.runtime.core.wp_graph_coloringandwp._src.context.runtime.core.wp_balance_coloring) at lines 233 and 241. While Newton's design around nightly Warp builds is established, internal API dependencies still warrant clarity:
- Confirm whether these internal APIs have stability guarantees across nightly Warp releases
- Clarify if there are plans to migrate to public APIs when available, or if these will remain the recommended approach for this functionality in nightly builds
- Note that the same APIs are also used directly in tests (test_coloring.py), suggesting intentional design; document whether this pattern is expected to continue
The PR notes mention "further changes" for other
_srcreferences—confirm whether these graph coloring APIs are included in that effort.newton/_src/solvers/implicit_mpm/solver_implicit_mpm.py (1)
1741-1741: The code change uses proper public API — no concerns.
wp.is_conditional_graph_supported()is part of the stable public Warp API (documented in the Warp API index and runtime reference) and reports CUDA-graph conditional-node availability. The simplified logic is appropriate and cleaner than the previous try/except approach.
9933d6e to
44e0fbd
Compare
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🤖 Fix all issues with AI agents
In `@newton/_src/utils/mesh.py`:
- Around line 652-686: The kernel currently computes a per-triangle normal and
writes offsets into shared slots out_vertices[i*2], out_vertices[j*2], etc.,
causing race conditions when vertices are shared; fix by adding a separate pass
to compute per-vertex normals (e.g., implement a compute_vertex_normals kernel
that accumulates area-weighted triangle normals into a vertex_normals array
using indices and vertices, normalizes them, and returns vertex_normals) and
then modify the solidification kernel to use vertex_normals[i],
vertex_normals[j], vertex_normals[k] (replace the per-triangle normal and
ti/tj/tk computations) so each vertex gets a deterministic offset using
thickness[i] * vertex_normals[i]; alternatively (if you prefer no
precomputation) avoid shared writes by allocating unique triangle-local vertices
(use tid*6..tid*6+5 indices instead of i*2/j*2/k*2) so each thread writes its
own vertices.
In `@newton/_src/utils/render.py`:
- Around line 21-60: The function bourke_color_map can divide by dv = high - low
which may be zero or negative; modify bourke_color_map to detect if high <= low
and handle it before computing dv by either returning a neutral color (e.g.,
[1.0,1.0,1.0] or a grayscale) or by setting high = low + eps (or dv = 1.0) and
clamping v to low so subsequent math never divides by zero; ensure you update
the early clamping logic for v and then proceed with the existing branch logic
so all divisions use a non-zero positive dv.
In `@newton/utils.py`:
- Around line 61-64: Remove the unnecessary noqa directive on the import from
._src.utils.render; the E402 suppression is not needed. Edit the import
statement that brings in bourke_color_map and copy_rgb_frame_uint8 and delete
the trailing "# noqa: E402" so Ruff no longer flags an unused directive.
🧹 Nitpick comments (5)
newton/_src/solvers/style3d/linear_solver.py (1)
230-230: Remove unusednoqadirective.The
noqa: PLC0415directive is unnecessary since that rule is not enabled in the project's linter configuration.Proposed fix
- from warp._src.context import runtime # noqa: PLC0415 + from warp._src.context import runtimeAdditionally, as noted in the PR description, this import still relies on Warp's internal
_srcnamespace and will need to be addressed in follow-up work.newton/_src/solvers/implicit_mpm/solver_implicit_mpm.py (1)
1741-1742: Consider a tiny compatibility guard aroundwp.is_conditional_graph_supported().
If that symbol is missing in any supported Warp build, solver init will crash now. If that’s impossible given your Warp constraints, ignore; otherwise considergetattrfallback.Proposed diff
- self._use_cuda_graph = self.model.device.is_cuda and wp.is_conditional_graph_supported() + is_graph_supported = getattr(wp, "is_conditional_graph_supported", lambda: False)() + self._use_cuda_graph = self.model.device.is_cuda and is_graph_supportednewton/_src/utils/render.py (1)
63-93: Add a defensive bounds check incopy_rgb_frame_uint8()to tolerate launch/arg mismatches.
Ifdim,width/height, oroutput_imgdisagree, this can go OOB; a cheap early-return keeps it safe.Proposed diff
`@wp.kernel` def copy_rgb_frame_uint8( @@ ): @@ w, v = wp.tid() + if w >= width or v >= height: + return pixel = v * width + w pixel *= 3newton/_src/utils/mesh.py (2)
65-72: Consider prefixing unused parameter with underscore.The
num_trisparameter is documented as unused but kept for API compatibility. Consider using the conventional underscore prefix (_num_tris) to signal intent to static analysis tools and readers.Suggested change
- def __init__(self, indices, num_tris): + def __init__(self, indices, _num_tris=None): """Build edge adjacency from triangle indices. Args: indices: Array-like of triangle indices, where each element is a sequence of 3 vertex indices defining a triangle. - num_tris: Number of triangles (currently unused, kept for API compatibility). + _num_tris: Number of triangles (currently unused, kept for API compatibility). """
744-745: Consider simplifying thickness scalar handling.The type check can be made more concise using
np.isscalar()or a single check.Suggested simplification
- if not isinstance(thickness, np.ndarray) and not isinstance(thickness, list): + if np.isscalar(thickness): thickness = [thickness] * len(vertices)
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
uv.lockis excluded by!**/*.lock
📒 Files selected for processing (31)
docs/generate_api.pynewton/_src/core/types.pynewton/_src/geometry/sdf_mc.pynewton/_src/sim/builder.pynewton/_src/sim/contacts.pynewton/_src/sim/graph_coloring.pynewton/_src/sim/style3d/builder_style3d.pynewton/_src/solvers/implicit_mpm/solve_rheology.pynewton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/_src/solvers/solver.pynewton/_src/solvers/style3d/collision/bvh/bvh.pynewton/_src/solvers/style3d/linear_solver.pynewton/_src/solvers/vbd/particle_vbd_kernels.pynewton/_src/solvers/vbd/rigid_vbd_kernels.pynewton/_src/utils/__init__.pynewton/_src/utils/import_mjcf.pynewton/_src/utils/mesh.pynewton/_src/utils/recorder.pynewton/_src/utils/render.pynewton/_src/utils/selection.pynewton/_src/viewer/viewer.pynewton/_src/viewer/viewer_gl.pynewton/examples/diffsim/example_diffsim_ball.pynewton/examples/diffsim/example_diffsim_cloth.pynewton/examples/diffsim/example_diffsim_drone.pynewton/examples/diffsim/example_diffsim_soft_body.pynewton/examples/diffsim/example_diffsim_spring_cage.pynewton/examples/robot/example_robot_anymal_c_walk.pynewton/tests/test_coloring.pynewton/utils.pypyproject.toml
🚧 Files skipped from review as they are similar to previous changes (17)
- newton/_src/viewer/viewer_gl.py
- newton/_src/sim/style3d/builder_style3d.py
- newton/_src/sim/graph_coloring.py
- newton/_src/geometry/sdf_mc.py
- newton/_src/sim/contacts.py
- newton/_src/utils/selection.py
- newton/examples/robot/example_robot_anymal_c_walk.py
- newton/_src/utils/recorder.py
- newton/examples/diffsim/example_diffsim_spring_cage.py
- newton/_src/utils/import_mjcf.py
- newton/examples/diffsim/example_diffsim_ball.py
- newton/examples/diffsim/example_diffsim_drone.py
- newton/_src/sim/builder.py
- newton/_src/solvers/vbd/particle_vbd_kernels.py
- newton/_src/solvers/implicit_mpm/solve_rheology.py
- newton/_src/solvers/style3d/collision/bvh/bvh.py
- newton/_src/viewer/viewer.py
🧰 Additional context used
📓 Path-based instructions (5)
newton/_src/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
The
newton/_src/directory is internal library implementation only and must not be imported by user code (examples, documentation, or external users)
Files:
newton/_src/core/types.pynewton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/_src/utils/render.pynewton/_src/solvers/style3d/linear_solver.pynewton/_src/solvers/vbd/rigid_vbd_kernels.pynewton/_src/utils/mesh.pynewton/_src/solvers/solver.pynewton/_src/utils/__init__.py
newton/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
Any user-facing class/function/object added under
_srcmust be exposed via the public Newton API through re-exports
Files:
newton/_src/core/types.pynewton/examples/diffsim/example_diffsim_cloth.pynewton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/_src/utils/render.pynewton/_src/solvers/style3d/linear_solver.pynewton/_src/solvers/vbd/rigid_vbd_kernels.pynewton/_src/utils/mesh.pynewton/examples/diffsim/example_diffsim_soft_body.pynewton/tests/test_coloring.pynewton/_src/solvers/solver.pynewton/utils.pynewton/_src/utils/__init__.py
**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
**/*.py: Use prefix-first naming for classes:ActuatorPD,ActuatorPID(notPDActuator,PIDActuator)
Use prefix-first naming for methods:add_shape_sphere()(notadd_sphere_shape())
Method names must usesnake_case
Prefer nested classes when self-contained: if a helper type or enum is only meaningful inside one parent class and doesn't need a public identity, define it as a nested class instead of a top-level class/module
Follow PEP 8 for Python code
Use Google-style docstrings with clear, concise explanations of what functions do, their parameters, and return values
Files:
newton/_src/core/types.pynewton/examples/diffsim/example_diffsim_cloth.pynewton/_src/solvers/implicit_mpm/solver_implicit_mpm.pydocs/generate_api.pynewton/_src/utils/render.pynewton/_src/solvers/style3d/linear_solver.pynewton/_src/solvers/vbd/rigid_vbd_kernels.pynewton/_src/utils/mesh.pynewton/examples/diffsim/example_diffsim_soft_body.pynewton/tests/test_coloring.pynewton/_src/solvers/solver.pynewton/utils.pynewton/_src/utils/__init__.py
**/*
📄 CodeRabbit inference engine (AGENTS.md)
CLI arguments must use
kebab-case(e.g.,--use-cuda-graph, not--use_cuda_graph)
Files:
newton/_src/core/types.pypyproject.tomlnewton/examples/diffsim/example_diffsim_cloth.pynewton/_src/solvers/implicit_mpm/solver_implicit_mpm.pydocs/generate_api.pynewton/_src/utils/render.pynewton/_src/solvers/style3d/linear_solver.pynewton/_src/solvers/vbd/rigid_vbd_kernels.pynewton/_src/utils/mesh.pynewton/examples/diffsim/example_diffsim_soft_body.pynewton/tests/test_coloring.pynewton/_src/solvers/solver.pynewton/utils.pynewton/_src/utils/__init__.py
newton/examples/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
newton/examples/**/*.py: Examples must not import fromnewton._src, only from the public Newton API
Examples must follow the format with anExampleclass and must be registered inREADME.mdwith auv runcommand and screenshot
Examples must implement atest_final()method that verifies the simulation state is valid after the example has run
Examples may optionally implement atest_post_step()method that is evaluated after everystep()call
Files:
newton/examples/diffsim/example_diffsim_cloth.pynewton/examples/diffsim/example_diffsim_soft_body.py
🧠 Learnings (32)
📓 Common learnings
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/_src/solvers/featherstone/kernels.py:75-75
Timestamp: 2025-08-12T18:04:06.577Z
Learning: The Newton physics framework requires nightly Warp builds, which means compatibility concerns with older stable Warp versions (like missing functions such as wp.spatial_adjoint) are not relevant for this project.
Learnt from: shi-eric
Repo: newton-physics/newton PR: 521
File: newton/examples/example_cloth_hanging.py:36-36
Timestamp: 2025-08-12T05:17:34.423Z
Learning: The Newton migration guide (docs/migration.rst) is specifically for documenting how to migrate existing warp.sim functionality to Newton equivalents. New Newton-only features that didn't exist in warp.sim do not need migration documentation.
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/tests/test_ik.py:25-26
Timestamp: 2025-08-12T17:58:16.929Z
Learning: In the Newton physics engine codebase, it's acceptable for tests to import and use private `_src` internal modules and functions when needed for testing purposes, even though this breaks the public API boundary. This is an intentional project decision for test code.
Learnt from: shi-eric
Repo: newton-physics/newton PR: 461
File: asv/benchmarks/envs/example_humanoid.py:40-41
Timestamp: 2025-07-23T14:36:42.182Z
Learning: In Warp benchmarks, explicit wp.init() calls are not needed in most circumstances since the first Warp API call that requires initialization will automatically call wp.init(). Explicit wp.init() in setup() methods is helpful when the ASV benchmark is measuring a Warp API call, as wp.init() has non-trivial overhead that should be excluded from the benchmark timing.
Learnt from: CR
Repo: newton-physics/newton PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-13T07:40:13.635Z
Learning: Applies to newton/**/*.py : Any user-facing class/function/object added under `_src` must be exposed via the public Newton API through re-exports
📚 Learning: 2025-08-12T05:17:34.423Z
Learnt from: shi-eric
Repo: newton-physics/newton PR: 521
File: newton/examples/example_cloth_hanging.py:36-36
Timestamp: 2025-08-12T05:17:34.423Z
Learning: The Newton migration guide (docs/migration.rst) is specifically for documenting how to migrate existing warp.sim functionality to Newton equivalents. New Newton-only features that didn't exist in warp.sim do not need migration documentation.
Applied to files:
newton/_src/core/types.pypyproject.tomlnewton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/examples/diffsim/example_diffsim_soft_body.pynewton/_src/utils/__init__.py
📚 Learning: 2025-08-12T17:51:37.474Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/geometry.py:16-22
Timestamp: 2025-08-12T17:51:37.474Z
Learning: In the Newton public API refactor, common geometry symbols like ParticleFlags and ShapeFlags are now exposed at the top level in newton/__init__.py rather than through newton.geometry. The newton/geometry.py module is intentionally focused only on broad-phase collision detection classes (BroadPhaseAllPairs, BroadPhaseExplicit, BroadPhaseSAP).
Applied to files:
newton/_src/core/types.pynewton/utils.py
📚 Learning: 2026-01-13T07:40:13.635Z
Learnt from: CR
Repo: newton-physics/newton PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-13T07:40:13.635Z
Learning: Applies to newton/**/*.py : Any user-facing class/function/object added under `_src` must be exposed via the public Newton API through re-exports
Applied to files:
newton/_src/core/types.pynewton/utils.py
📚 Learning: 2026-01-13T03:11:40.556Z
Learnt from: jumyungc
Repo: newton-physics/newton PR: 1333
File: newton/_src/sim/builder.py:0-0
Timestamp: 2026-01-13T03:11:40.556Z
Learning: Ensure all VBD damping semantics follow Rayleigh-style damping and are unitless. This convention, demonstrated in SolverVBD, should be applied consistently across all VBD-related constraints in the codebase. In newton/_src/sim/builder.py, validate that any damping terms use the same normalization and are treated as dimensionless; add comments and unit tests to enforce consistency across VBD components.
Applied to files:
newton/_src/core/types.pynewton/examples/diffsim/example_diffsim_cloth.pynewton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/_src/utils/render.pynewton/_src/solvers/style3d/linear_solver.pynewton/_src/solvers/vbd/rigid_vbd_kernels.pynewton/_src/utils/mesh.pynewton/examples/diffsim/example_diffsim_soft_body.pynewton/tests/test_coloring.pynewton/_src/solvers/solver.pynewton/utils.pynewton/_src/utils/__init__.py
📚 Learning: 2025-08-27T23:33:32.527Z
Learnt from: shi-eric
Repo: newton-physics/newton PR: 660
File: pyproject.toml:28-28
Timestamp: 2025-08-27T23:33:32.527Z
Learning: In Python projects, it's normal and correct to have different warp-lang version specifications across files: pyproject.toml should specify minimum compatible versions using >= for flexibility, while specific environments like asv.conf.json can pin exact versions using == for reproducibility. These serve different purposes and should not be "aligned" to the same version.
Applied to files:
pyproject.toml
📚 Learning: 2025-08-12T18:04:06.577Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/_src/solvers/featherstone/kernels.py:75-75
Timestamp: 2025-08-12T18:04:06.577Z
Learning: The Newton physics framework requires nightly Warp builds, which means compatibility concerns with older stable Warp versions (like missing functions such as wp.spatial_adjoint) are not relevant for this project.
Applied to files:
pyproject.tomlnewton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/_src/solvers/style3d/linear_solver.pynewton/_src/solvers/vbd/rigid_vbd_kernels.pynewton/examples/diffsim/example_diffsim_soft_body.pynewton/_src/utils/__init__.py
📚 Learning: 2025-10-04T06:44:52.713Z
Learnt from: shi-eric
Repo: newton-physics/newton PR: 879
File: .gitlab-ci.yml:125-145
Timestamp: 2025-10-04T06:44:52.713Z
Learning: In the Newton project, the "linux-x86_64 test warp nightly" GitLab CI job intentionally runs on every pipeline (not limited to `.test_common` rules) to detect Warp nightly integration issues early, since Warp nightly releases are unpredictable. This design is acceptable because `allow_failure: true` prevents blocking the pipeline.
Applied to files:
pyproject.toml
📚 Learning: 2025-08-27T23:32:48.670Z
Learnt from: shi-eric
Repo: newton-physics/newton PR: 660
File: pyproject.toml:54-59
Timestamp: 2025-08-27T23:32:48.670Z
Learning: In the newton project's pyproject.toml, self-referential extras (e.g., `examples = ["newton[sim]", "newton[importers]", ...]`) are normal and encouraged for dependency management, rather than inlining the dependencies.
Applied to files:
pyproject.toml
📚 Learning: 2025-09-22T21:08:31.901Z
Learnt from: dylanturpin
Repo: newton-physics/newton PR: 806
File: newton/examples/ik/example_ik_franka.py:121-123
Timestamp: 2025-09-22T21:08:31.901Z
Learning: In the newton physics framework, when creating warp arrays for IK solver joint variables using wp.array(self.model.joint_q, shape=(1, coord_count)), the resulting array acts as a reference/pointer to the original model's joint coordinates, so updates from the IK solver automatically reflect in the model's joint_q buffer used for rendering, despite the general warp documentation suggesting copies are made by default.
Applied to files:
newton/examples/diffsim/example_diffsim_cloth.pynewton/_src/solvers/style3d/linear_solver.pynewton/_src/solvers/vbd/rigid_vbd_kernels.pynewton/examples/diffsim/example_diffsim_soft_body.py
📚 Learning: 2025-12-12T08:45:43.428Z
Learnt from: nvtw
Repo: newton-physics/newton PR: 1221
File: newton/examples/example_sdf.py:277-287
Timestamp: 2025-12-12T08:45:43.428Z
Learning: In Newtown (Newton) example code, specifically files under newton/examples, computing contacts once per frame and reusing them across all substeps is an intentional design choice, not a bug. Reviewers should verify that contacts are computed before the substep loop and reused for every substep within the same frame. This pattern reduces redundant work and preserves frame-consistency; do not flag as a regression unless the behavior is changed for correctness or performance reasons.
Applied to files:
newton/examples/diffsim/example_diffsim_cloth.pynewton/examples/diffsim/example_diffsim_soft_body.py
📚 Learning: 2025-12-12T15:23:30.014Z
Learnt from: vastsoun
Repo: newton-physics/newton PR: 1019
File: newton/_src/solvers/kamino/examples/sim/example_sim_basics_boxes_fourbar.py:149-163
Timestamp: 2025-12-12T15:23:30.014Z
Learning: In Kamino simulation examples under newton/_src/solvers/kamino/examples/sim/, the pattern where logging=True and use_cuda_graph=True creates a mismatch (SimulationLogger constructed but settings.compute_metrics and logger.log() calls guarded by `if not self.use_cuda_graph`) should not be flagged. These examples will be refactored in a future commit, and this pattern is intentionally deferred.
Applied to files:
newton/_src/solvers/implicit_mpm/solver_implicit_mpm.py
📚 Learning: 2025-09-18T07:05:56.836Z
Learnt from: gdaviet
Repo: newton-physics/newton PR: 750
File: newton/_src/solvers/implicit_mpm/solve_rheology.py:969-986
Timestamp: 2025-09-18T07:05:56.836Z
Learning: In newton/_src/solvers/implicit_mpm/solve_rheology.py, transposed_strain_mat parameter cannot be None - the type signature was corrected to reflect this guarantee, eliminating the need for None checks when accessing transposed_strain_mat.offsets.
Applied to files:
newton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/_src/solvers/style3d/linear_solver.py
📚 Learning: 2025-08-19T12:27:30.629Z
Learnt from: preist-nvidia
Repo: newton-physics/newton PR: 579
File: newton/examples/example_mujoco.py:350-354
Timestamp: 2025-08-19T12:27:30.629Z
Learning: In Newton examples, there's a distinction between solver parameters and Example class attributes. The Example class can have its own use_mujoco attribute for controlling example-level behavior (like CUDA graphs, rendering logic), while the solver uses use_mujoco_cpu for backend selection. These serve different purposes and should not be conflated during API renames.
Applied to files:
newton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/_src/solvers/solver.py
📚 Learning: 2025-10-29T14:55:48.171Z
Learnt from: gdaviet
Repo: newton-physics/newton PR: 940
File: newton/examples/mpm/example_mpm_granular.py:92-101
Timestamp: 2025-10-29T14:55:48.171Z
Learning: In newton/examples/mpm/example_mpm_granular.py, the capture() method intentionally advances the simulation state once during CUDA graph capture. This is expected behavior because CUDA graph capture records exact memory addresses, so the state arrays (state_0, state_1) cannot be reset or reallocated after capture without invalidating the graph.
Applied to files:
newton/_src/solvers/implicit_mpm/solver_implicit_mpm.py
📚 Learning: 2025-08-25T20:10:59.536Z
Learnt from: dylanturpin
Repo: newton-physics/newton PR: 634
File: newton/examples/ik/example_ik_franka.py:0-0
Timestamp: 2025-08-25T20:10:59.536Z
Learning: In Newton's IK examples, when creating solver arrays with `wp.array(source_array, shape=new_shape)`, this creates a view into the same underlying memory rather than a copy. This means updates to the reshaped array are automatically reflected in the original array without needing explicit copy operations like `wp.copy()`.
Applied to files:
newton/_src/solvers/style3d/linear_solver.py
📚 Learning: 2025-08-12T17:52:15.009Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/_src/utils/import_mjcf.py:226-231
Timestamp: 2025-08-12T17:52:15.009Z
Learning: In the Newton codebase, when passing array-like objects (numpy arrays, lists, tuples) to wp.vec3(), the consistent pattern is to use the unpacking operator: wp.vec3(*array) rather than wp.vec3(array). This pattern is used throughout newton/_src/utils/import_mjcf.py and newton/_src/core/types.py.
Applied to files:
newton/_src/solvers/style3d/linear_solver.pynewton/_src/solvers/vbd/rigid_vbd_kernels.py
📚 Learning: 2025-08-12T05:17:34.423Z
Learnt from: shi-eric
Repo: newton-physics/newton PR: 521
File: newton/examples/example_cloth_hanging.py:36-36
Timestamp: 2025-08-12T05:17:34.423Z
Learning: The STYLE3D solver in Newton is a new solver that did not exist in warp.sim, so it does not require any migration documentation.
Applied to files:
newton/_src/solvers/style3d/linear_solver.py
📚 Learning: 2025-09-22T21:08:31.901Z
Learnt from: dylanturpin
Repo: newton-physics/newton PR: 806
File: newton/examples/ik/example_ik_franka.py:121-123
Timestamp: 2025-09-22T21:08:31.901Z
Learning: In the newton physics framework, when creating warp arrays for IK solver joint variables using wp.array(self.model.joint_q, shape=(1, coord_count)), the resulting array acts as a reference/pointer to the original model's joint coordinates, so updates from the IK solver automatically reflect in the model's joint_q buffer used for rendering.
Applied to files:
newton/_src/solvers/style3d/linear_solver.pynewton/_src/solvers/vbd/rigid_vbd_kernels.py
📚 Learning: 2025-08-25T20:10:51.009Z
Learnt from: dylanturpin
Repo: newton-physics/newton PR: 634
File: newton/examples/ik/example_ik_h1.py:0-0
Timestamp: 2025-08-25T20:10:51.009Z
Learning: In Warp, creating a new wp.array() with an existing array and different shape (e.g., wp.array(existing_array, shape=new_shape)) creates a view into the same underlying memory buffer, not a copy. This means modifications through either view are automatically reflected in both arrays.
Applied to files:
newton/_src/solvers/style3d/linear_solver.py
📚 Learning: 2025-09-26T05:58:21.013Z
Learnt from: WenchaoHuang
Repo: newton-physics/newton PR: 835
File: newton/_src/solvers/style3d/collision/collision.py:49-53
Timestamp: 2025-09-26T05:58:21.013Z
Learning: In newton/_src/solvers/style3d/collision/collision.py, the broad_phase buffers (broad_phase_ee, broad_phase_ef, broad_phase_vf) created with wp.array() don't need zero-initialization because they follow a write-first-read-later pattern: BVH query kernels in frame_begin() populate these buffers completely (write-only operations), and collision kernels only read from them afterward in accumulate_contact_force(), ensuring no undefined reads occur.
Applied to files:
newton/_src/solvers/style3d/linear_solver.py
📚 Learning: 2025-08-18T15:56:26.587Z
Learnt from: adenzler-nvidia
Repo: newton-physics/newton PR: 552
File: newton/_src/solvers/mujoco/solver_mujoco.py:0-0
Timestamp: 2025-08-18T15:56:26.587Z
Learning: In Newton's MuJoCo solver, when transforming joint axes from Newton's internal frame to MuJoCo's expected frame, use wp.quat_rotate(joint_rot, axis) not wp.quat_rotate_inv(joint_rot, axis). The joint_rot represents rotation from joint-local to body frame, so forward rotation is correct.
Applied to files:
newton/_src/solvers/vbd/rigid_vbd_kernels.py
📚 Learning: 2025-09-25T16:14:22.033Z
Learnt from: dylanturpin
Repo: newton-physics/newton PR: 806
File: newton/_src/sim/ik/ik_objectives.py:0-0
Timestamp: 2025-09-25T16:14:22.033Z
Learning: In NVIDIA Warp's Newton physics library, wp.transform supports direct numerical indexing (e.g., body_tf[0], body_tf[1], body_tf[2] for position and body_tf[3], body_tf[4], body_tf[5], body_tf[6] for quaternion components) to access its elements. This is the standard API used throughout the codebase.
Applied to files:
newton/_src/solvers/vbd/rigid_vbd_kernels.py
📚 Learning: 2025-11-24T10:44:09.613Z
Learnt from: gdaviet
Repo: newton-physics/newton PR: 1108
File: newton/_src/solvers/implicit_mpm/rasterized_collisions.py:94-129
Timestamp: 2025-11-24T10:44:09.613Z
Learning: In Warp, wp.normalize() returns a zero vector (or zero quaternion) when given a zero-length input, so explicit zero-length checks before normalization are not required.
Applied to files:
newton/_src/solvers/vbd/rigid_vbd_kernels.py
📚 Learning: 2025-12-01T17:00:28.889Z
Learnt from: camevor
Repo: newton-physics/newton PR: 1161
File: newton/_src/solvers/mujoco/kernels.py:1268-1268
Timestamp: 2025-12-01T17:00:28.889Z
Learning: MuJoCo Warp spatial vectors (e.g., cacc, cvel) use the convention (angular, linear), which is opposite to Newton's (linear, angular) convention. When converting from MuJoCo Warp to Newton format, spatial_top() on MuJoCo Warp data extracts the angular component, and spatial_bottom() extracts the linear component.
Applied to files:
newton/_src/solvers/vbd/rigid_vbd_kernels.py
📚 Learning: 2025-11-28T11:12:40.805Z
Learnt from: camevor
Repo: newton-physics/newton PR: 1146
File: newton/examples/basic/example_basic_joints.py:206-213
Timestamp: 2025-11-28T11:12:40.805Z
Learning: In Newton's standard solvers (XPBD, SemiImplicit, SolverMuJoCo), spatial vectors in State.body_qd use the ordering (linear, angular): wp.spatial_top(qd) returns linear velocity and wp.spatial_bottom(qd) returns angular velocity. This is the opposite of typical Modern Robotics spatial twist notation where (angular, linear) is used.
Applied to files:
newton/_src/solvers/vbd/rigid_vbd_kernels.py
📚 Learning: 2025-09-17T21:34:05.267Z
Learnt from: gdaviet
Repo: newton-physics/newton PR: 750
File: newton/examples/mpm/example_mpm_granular.py:44-47
Timestamp: 2025-09-17T21:34:05.267Z
Learning: wp.Mesh (Warp mesh objects) expose triangle indices through the `indices` attribute, not `triangles`. The correct usage is `wp.Mesh(...).indices`, not `wp.Mesh(...).triangles`.
Applied to files:
newton/_src/utils/mesh.py
📚 Learning: 2025-08-12T17:58:16.929Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/tests/test_ik.py:25-26
Timestamp: 2025-08-12T17:58:16.929Z
Learning: In the Newton physics engine codebase, it's acceptable for tests to import and use private `_src` internal modules and functions when needed for testing purposes, even though this breaks the public API boundary. This is an intentional project decision for test code.
Applied to files:
newton/tests/test_coloring.py
📚 Learning: 2025-08-19T12:27:30.629Z
Learnt from: preist-nvidia
Repo: newton-physics/newton PR: 579
File: newton/examples/example_mujoco.py:350-354
Timestamp: 2025-08-19T12:27:30.629Z
Learning: In Newton examples, Example.use_mujoco is a high-level attribute that controls whether to use MuJoCo solver vs other solvers (like XPBD), while SolverMuJoCo.use_mujoco_cpu controls the backend within MuJoCo (CPU vs Warp). These are separate concepts serving different purposes - the PR rename only applies to the solver parameter, not the Example class attributes.
Applied to files:
newton/_src/solvers/solver.py
📚 Learning: 2026-01-13T07:40:13.635Z
Learnt from: CR
Repo: newton-physics/newton PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-13T07:40:13.635Z
Learning: Applies to newton/examples/**/*.py : Examples must not import from `newton._src`, only from the public Newton API
Applied to files:
newton/utils.py
📚 Learning: 2025-08-12T17:58:00.815Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/_src/solvers/featherstone/kernels.py:18-20
Timestamp: 2025-08-12T17:58:00.815Z
Learning: In newton/_src/core/__init__.py, the function transform_twist is properly re-exported from the spatial module via "from .spatial import (..., transform_twist, ...)" and included in __all__, making it available for import as "from ...core import transform_twist" from other modules.
Applied to files:
newton/utils.py
📚 Learning: 2025-08-14T17:38:36.106Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/__init__.py:25-29
Timestamp: 2025-08-14T17:38:36.106Z
Learning: The Newton project prefers incremental __all__ building using __all__ += [...] pattern to group exports with their related imports, rather than a single consolidated __all__ at the end of the file.
Applied to files:
newton/utils.py
🧬 Code graph analysis (6)
newton/examples/diffsim/example_diffsim_cloth.py (1)
newton/_src/utils/render.py (1)
bourke_color_map(21-60)
newton/_src/utils/mesh.py (1)
newton/_src/sim/builder.py (1)
add_edge(5144-5197)
newton/examples/diffsim/example_diffsim_soft_body.py (1)
newton/_src/utils/render.py (1)
bourke_color_map(21-60)
newton/tests/test_coloring.py (2)
newton/_src/sim/builder.py (1)
particle_count(1157-1161)newton/_src/sim/graph_coloring.py (1)
ColoringAlgorithm(24-26)
newton/_src/solvers/solver.py (1)
newton/_src/sim/contacts.py (1)
device(110-114)
newton/utils.py (2)
newton/_src/utils/mesh.py (3)
MeshAdjacency(53-111)MeshEdge(27-50)solidify_mesh(715-754)newton/_src/utils/render.py (2)
bourke_color_map(21-60)copy_rgb_frame_uint8(64-93)
🪛 Ruff (0.14.11)
newton/_src/solvers/style3d/linear_solver.py
230-230: Unused noqa directive (non-enabled: PLC0415)
Remove unused noqa directive
(RUF100)
newton/_src/utils/mesh.py
65-65: Unused method argument: num_tris
(ARG002)
newton/utils.py
61-61: Unused noqa directive (non-enabled: E402)
Remove unused noqa directive
(RUF100)
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Run GPU Tests / Run GPU Unit Tests on AWS EC2
- GitHub Check: Run GPU Benchmarks / Run GPU Benchmarks on AWS EC2
🔇 Additional comments (14)
docs/generate_api.py (1)
107-109: LGTM! Correct migration to public Warp API.This change appropriately replaces access to the internal
wp.codegen.Structwith the publicwp.types.type_is_struct()API, addressing the Warp v1.11.0 deprecation warnings as intended by this PR.newton/_src/solvers/style3d/linear_solver.py (1)
237-245: The change fromtype_lengthtotype_sizeis correct.
wp.types.type_size()returns the number of scalar components (e.g., 3 forvec3), as confirmed by the NVIDIA Warp API documentation. This is the semantically correct replacement for the deprecatedtype_length()function and will not break the inner product calculation.newton/_src/utils/__init__.py (1)
222-229: LGTM! Clean simplification using public Warp API.The switch from the deprecated
assert_conditional_graph_supporttry/except pattern to directly usingwp.is_conditional_graph_supported()is a good improvement. This removes internal API usage and simplifies the control flow while maintaining the same public interface.newton/tests/test_coloring.py (1)
142-147: Appropriate use of internal Warp APIs in test code.The switch to
wp._src.context.runtime.core.wp_graph_coloringandwp._src.context.runtime.core.wp_balance_coloringis acceptable for test code. Based on learnings, Newton tests are permitted to use private_srcinternal modules when needed for testing purposes. The function signatures and arguments remain unchanged, and this aligns with the corresponding changes innewton/_src/sim/graph_coloring.py.Also applies to: 155-160, 170-182, 190-202
newton/_src/solvers/solver.py (1)
168-176: LGTM! Type annotation updated to use public Warp API.The change from
wp.context.Devicetowp.Devicecorrectly uses the public type alias instead of the internal path, consistent with the PR's objective of addressing deprecation warnings. The runtime behavior remains unchanged.newton/examples/diffsim/example_diffsim_cloth.py (2)
35-35: LGTM! Import correctly uses public Newton API.The import of
bourke_color_mapfromnewton.utilsinstead ofwp.rendercomplies with the coding guidelines that examples must only import from the public Newton API. As per coding guidelines, examples must not import fromnewton._src.
214-214: LGTM! Function call updated to use imported utility.The call to
bourke_color_mapcorrectly uses the function imported from the public Newton API with the same arguments as before.pyproject.toml (1)
28-28: Version 1.12.0.dev20251219 is available on NVIDIA PyPI and supports all major platforms (macOS ARM64, Linux x86_64, Linux aarch64, Windows x86_64). The dependency specification is valid.newton/_src/solvers/vbd/rigid_vbd_kernels.py (1)
68-71:vec6type migration looks right; please confirm Warp supports this subclassing pattern.
Moving towp.types.vector(..., dtype=wp.float32)is consistent with the Warp public API direction, but this relies on Warp allowing subclassing of the type factory result (vs using a simple alias). Please confirm this works in the repo’s pinned/nightly Warp build.newton/_src/core/types.py (1)
25-27: VerifyDeviceLikeis exported fromwarp(not justwarp.context).
The aliasing approach is clean, but it will hard-fail on environments wherewarp.DeviceLikeisn’t present. Please confirm this matches the minimum Warp version used in CI.newton/utils.py (1)
32-56: Good: new_srcutilities are properly re-exported vianewton.utils.
This matches the project expectation that user-facing additions under_srcare exposed through the public API. Based on learnings, this is the right shape.Also applies to: 58-69
newton/examples/diffsim/example_diffsim_soft_body.py (1)
37-37: LGTM!The import correctly uses the public Newton API (
newton.utils) instead of the deprecated Warp internal API (warp.render), aligning with the PR objectives and coding guidelines for examples.newton/_src/utils/mesh.py (2)
16-20: LGTM!Appropriate imports for the new dataclass, warning handling, and Warp kernel functionality.
26-51: LGTM!Well-documented dataclass with clear field descriptions. The edge representation is consistent with edge handling patterns elsewhere in the codebase (e.g.,
add_edgeinbuilder.py).
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@newton/_src/utils/mesh.py`:
- Around line 627-713: The kernel solidify_mesh_kernel currently has a race
where multiple threads write to shared out_vertices entries (out_vertices[i*2],
out_vertices[i*2+1]) because normals are computed per-face; fix by either (A)
computing/feeding per-vertex averaged normals on the host and replace the
per-face normal math in solidify_mesh_kernel so each thread only reads and
writes its unique per-vertex outputs deterministically, or (B) change the output
layout to per-face duplicated vertices (allocate out_vertices of size
num_triangles*6 and use per-triangle local indices instead of i0/i1/j0/j1/k0/k1)
so each thread writes only its own slice; update out_indices logic to match the
chosen layout (references: solidify_mesh_kernel, indices, vertices, thickness,
out_vertices, out_indices).
In `@newton/_src/utils/render.py`:
- Around line 21-60: Protect against division-by-zero in bourke_color_map by
checking dv = high - low immediately after it's computed; if dv == 0, return the
default color (c) or another sensible constant instead of performing the
subsequent divisions. This change in the bourke_color_map function prevents
ZeroDivisionError when low == high while preserving the existing return type and
value range.
🧹 Nitpick comments (2)
newton/_src/utils/selection.py (1)
511-514: Use consistent direct import foris_structalongsideis_array.The migration from the internal API to
wp.types.is_struct()is correct. However, for consistency with howis_arrayis imported and used elsewhere in the file, importis_structdirectly:-from warp.types import is_array +from warp.types import is_array, is_structThen update line 511:
- if wp.types.is_struct(attrib): + if is_struct(attrib):This matches the pattern used on line 586 where
is_arrayis called directly.newton/_src/solvers/style3d/linear_solver.py (1)
230-230: Remove unusednoqadirective.Per static analysis,
PLC0415is not enabled, making this directive unnecessary.Suggested fix
- from warp._src.context import runtime # noqa: PLC0415 + from warp._src.context import runtime
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
uv.lockis excluded by!**/*.lock
📒 Files selected for processing (31)
docs/generate_api.pynewton/_src/core/types.pynewton/_src/geometry/sdf_mc.pynewton/_src/sim/builder.pynewton/_src/sim/contacts.pynewton/_src/sim/graph_coloring.pynewton/_src/sim/style3d/builder_style3d.pynewton/_src/solvers/implicit_mpm/solve_rheology.pynewton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/_src/solvers/solver.pynewton/_src/solvers/style3d/collision/bvh/bvh.pynewton/_src/solvers/style3d/linear_solver.pynewton/_src/solvers/vbd/particle_vbd_kernels.pynewton/_src/solvers/vbd/rigid_vbd_kernels.pynewton/_src/utils/__init__.pynewton/_src/utils/import_mjcf.pynewton/_src/utils/mesh.pynewton/_src/utils/recorder.pynewton/_src/utils/render.pynewton/_src/utils/selection.pynewton/_src/viewer/viewer.pynewton/_src/viewer/viewer_gl.pynewton/examples/diffsim/example_diffsim_ball.pynewton/examples/diffsim/example_diffsim_cloth.pynewton/examples/diffsim/example_diffsim_drone.pynewton/examples/diffsim/example_diffsim_soft_body.pynewton/examples/diffsim/example_diffsim_spring_cage.pynewton/examples/robot/example_robot_anymal_c_walk.pynewton/tests/test_coloring.pynewton/utils.pypyproject.toml
🚧 Files skipped from review as they are similar to previous changes (22)
- newton/_src/utils/recorder.py
- newton/_src/sim/graph_coloring.py
- newton/_src/utils/init.py
- newton/_src/sim/builder.py
- newton/_src/core/types.py
- newton/_src/utils/import_mjcf.py
- newton/examples/diffsim/example_diffsim_ball.py
- newton/_src/solvers/style3d/collision/bvh/bvh.py
- newton/examples/diffsim/example_diffsim_drone.py
- newton/_src/geometry/sdf_mc.py
- newton/_src/solvers/vbd/rigid_vbd_kernels.py
- newton/_src/solvers/vbd/particle_vbd_kernels.py
- newton/_src/viewer/viewer_gl.py
- newton/_src/viewer/viewer.py
- docs/generate_api.py
- newton/examples/robot/example_robot_anymal_c_walk.py
- pyproject.toml
- newton/examples/diffsim/example_diffsim_cloth.py
- newton/tests/test_coloring.py
- newton/_src/sim/style3d/builder_style3d.py
- newton/_src/solvers/implicit_mpm/solve_rheology.py
- newton/_src/sim/contacts.py
🧰 Additional context used
📓 Path-based instructions (5)
newton/_src/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
The
newton/_src/directory is internal library implementation only and must not be imported by user code (examples, documentation, or external users)
Files:
newton/_src/utils/render.pynewton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/_src/utils/selection.pynewton/_src/solvers/solver.pynewton/_src/utils/mesh.pynewton/_src/solvers/style3d/linear_solver.py
newton/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
Any user-facing class/function/object added under
_srcmust be exposed via the public Newton API through re-exports
Files:
newton/_src/utils/render.pynewton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/_src/utils/selection.pynewton/utils.pynewton/_src/solvers/solver.pynewton/examples/diffsim/example_diffsim_soft_body.pynewton/examples/diffsim/example_diffsim_spring_cage.pynewton/_src/utils/mesh.pynewton/_src/solvers/style3d/linear_solver.py
**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
**/*.py: Use prefix-first naming for classes:ActuatorPD,ActuatorPID(notPDActuator,PIDActuator)
Use prefix-first naming for methods:add_shape_sphere()(notadd_sphere_shape())
Method names must usesnake_case
Prefer nested classes when self-contained: if a helper type or enum is only meaningful inside one parent class and doesn't need a public identity, define it as a nested class instead of a top-level class/module
Follow PEP 8 for Python code
Use Google-style docstrings with clear, concise explanations of what functions do, their parameters, and return values
Files:
newton/_src/utils/render.pynewton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/_src/utils/selection.pynewton/utils.pynewton/_src/solvers/solver.pynewton/examples/diffsim/example_diffsim_soft_body.pynewton/examples/diffsim/example_diffsim_spring_cage.pynewton/_src/utils/mesh.pynewton/_src/solvers/style3d/linear_solver.py
**/*
📄 CodeRabbit inference engine (AGENTS.md)
CLI arguments must use
kebab-case(e.g.,--use-cuda-graph, not--use_cuda_graph)
Files:
newton/_src/utils/render.pynewton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/_src/utils/selection.pynewton/utils.pynewton/_src/solvers/solver.pynewton/examples/diffsim/example_diffsim_soft_body.pynewton/examples/diffsim/example_diffsim_spring_cage.pynewton/_src/utils/mesh.pynewton/_src/solvers/style3d/linear_solver.py
newton/examples/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
newton/examples/**/*.py: Examples must not import fromnewton._src, only from the public Newton API
Examples must follow the format with anExampleclass and must be registered inREADME.mdwith auv runcommand and screenshot
Examples must implement atest_final()method that verifies the simulation state is valid after the example has run
Examples may optionally implement atest_post_step()method that is evaluated after everystep()call
Files:
newton/examples/diffsim/example_diffsim_soft_body.pynewton/examples/diffsim/example_diffsim_spring_cage.py
🧠 Learnings (20)
📓 Common learnings
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/_src/solvers/featherstone/kernels.py:75-75
Timestamp: 2025-08-12T18:04:06.577Z
Learning: The Newton physics framework requires nightly Warp builds, which means compatibility concerns with older stable Warp versions (like missing functions such as wp.spatial_adjoint) are not relevant for this project.
Learnt from: shi-eric
Repo: newton-physics/newton PR: 521
File: newton/examples/example_cloth_hanging.py:36-36
Timestamp: 2025-08-12T05:17:34.423Z
Learning: The Newton migration guide (docs/migration.rst) is specifically for documenting how to migrate existing warp.sim functionality to Newton equivalents. New Newton-only features that didn't exist in warp.sim do not need migration documentation.
📚 Learning: 2026-01-13T03:11:40.556Z
Learnt from: jumyungc
Repo: newton-physics/newton PR: 1333
File: newton/_src/sim/builder.py:0-0
Timestamp: 2026-01-13T03:11:40.556Z
Learning: Ensure all VBD damping semantics follow Rayleigh-style damping and are unitless. This convention, demonstrated in SolverVBD, should be applied consistently across all VBD-related constraints in the codebase. In newton/_src/sim/builder.py, validate that any damping terms use the same normalization and are treated as dimensionless; add comments and unit tests to enforce consistency across VBD components.
Applied to files:
newton/_src/utils/render.pynewton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/_src/utils/selection.pynewton/utils.pynewton/_src/solvers/solver.pynewton/examples/diffsim/example_diffsim_soft_body.pynewton/examples/diffsim/example_diffsim_spring_cage.pynewton/_src/utils/mesh.pynewton/_src/solvers/style3d/linear_solver.py
📚 Learning: 2025-09-18T07:05:56.836Z
Learnt from: gdaviet
Repo: newton-physics/newton PR: 750
File: newton/_src/solvers/implicit_mpm/solve_rheology.py:969-986
Timestamp: 2025-09-18T07:05:56.836Z
Learning: In newton/_src/solvers/implicit_mpm/solve_rheology.py, transposed_strain_mat parameter cannot be None - the type signature was corrected to reflect this guarantee, eliminating the need for None checks when accessing transposed_strain_mat.offsets.
Applied to files:
newton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/_src/solvers/style3d/linear_solver.py
📚 Learning: 2025-08-19T12:27:30.629Z
Learnt from: preist-nvidia
Repo: newton-physics/newton PR: 579
File: newton/examples/example_mujoco.py:350-354
Timestamp: 2025-08-19T12:27:30.629Z
Learning: In Newton examples, there's a distinction between solver parameters and Example class attributes. The Example class can have its own use_mujoco attribute for controlling example-level behavior (like CUDA graphs, rendering logic), while the solver uses use_mujoco_cpu for backend selection. These serve different purposes and should not be conflated during API renames.
Applied to files:
newton/_src/solvers/implicit_mpm/solver_implicit_mpm.py
📚 Learning: 2025-10-29T14:55:48.171Z
Learnt from: gdaviet
Repo: newton-physics/newton PR: 940
File: newton/examples/mpm/example_mpm_granular.py:92-101
Timestamp: 2025-10-29T14:55:48.171Z
Learning: In newton/examples/mpm/example_mpm_granular.py, the capture() method intentionally advances the simulation state once during CUDA graph capture. This is expected behavior because CUDA graph capture records exact memory addresses, so the state arrays (state_0, state_1) cannot be reset or reallocated after capture without invalidating the graph.
Applied to files:
newton/_src/solvers/implicit_mpm/solver_implicit_mpm.py
📚 Learning: 2025-12-12T15:23:30.014Z
Learnt from: vastsoun
Repo: newton-physics/newton PR: 1019
File: newton/_src/solvers/kamino/examples/sim/example_sim_basics_boxes_fourbar.py:149-163
Timestamp: 2025-12-12T15:23:30.014Z
Learning: In Kamino simulation examples under newton/_src/solvers/kamino/examples/sim/, the pattern where logging=True and use_cuda_graph=True creates a mismatch (SimulationLogger constructed but settings.compute_metrics and logger.log() calls guarded by `if not self.use_cuda_graph`) should not be flagged. These examples will be refactored in a future commit, and this pattern is intentionally deferred.
Applied to files:
newton/_src/solvers/implicit_mpm/solver_implicit_mpm.py
📚 Learning: 2025-08-12T18:04:06.577Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/_src/solvers/featherstone/kernels.py:75-75
Timestamp: 2025-08-12T18:04:06.577Z
Learning: The Newton physics framework requires nightly Warp builds, which means compatibility concerns with older stable Warp versions (like missing functions such as wp.spatial_adjoint) are not relevant for this project.
Applied to files:
newton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/examples/diffsim/example_diffsim_soft_body.pynewton/_src/solvers/style3d/linear_solver.py
📚 Learning: 2025-08-12T05:17:34.423Z
Learnt from: shi-eric
Repo: newton-physics/newton PR: 521
File: newton/examples/example_cloth_hanging.py:36-36
Timestamp: 2025-08-12T05:17:34.423Z
Learning: The Newton migration guide (docs/migration.rst) is specifically for documenting how to migrate existing warp.sim functionality to Newton equivalents. New Newton-only features that didn't exist in warp.sim do not need migration documentation.
Applied to files:
newton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/examples/diffsim/example_diffsim_soft_body.pynewton/examples/diffsim/example_diffsim_spring_cage.pynewton/_src/solvers/style3d/linear_solver.py
📚 Learning: 2025-08-12T17:52:15.009Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/_src/utils/import_mjcf.py:226-231
Timestamp: 2025-08-12T17:52:15.009Z
Learning: In the Newton codebase, when passing array-like objects (numpy arrays, lists, tuples) to wp.vec3(), the consistent pattern is to use the unpacking operator: wp.vec3(*array) rather than wp.vec3(array). This pattern is used throughout newton/_src/utils/import_mjcf.py and newton/_src/core/types.py.
Applied to files:
newton/_src/utils/selection.py
📚 Learning: 2026-01-13T07:40:13.635Z
Learnt from: CR
Repo: newton-physics/newton PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-13T07:40:13.635Z
Learning: Applies to newton/**/*.py : Any user-facing class/function/object added under `_src` must be exposed via the public Newton API through re-exports
Applied to files:
newton/utils.py
📚 Learning: 2025-08-12T17:51:37.474Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/geometry.py:16-22
Timestamp: 2025-08-12T17:51:37.474Z
Learning: In the Newton public API refactor, common geometry symbols like ParticleFlags and ShapeFlags are now exposed at the top level in newton/__init__.py rather than through newton.geometry. The newton/geometry.py module is intentionally focused only on broad-phase collision detection classes (BroadPhaseAllPairs, BroadPhaseExplicit, BroadPhaseSAP).
Applied to files:
newton/utils.py
📚 Learning: 2025-08-14T17:38:36.106Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/__init__.py:25-29
Timestamp: 2025-08-14T17:38:36.106Z
Learning: The Newton project prefers incremental __all__ building using __all__ += [...] pattern to group exports with their related imports, rather than a single consolidated __all__ at the end of the file.
Applied to files:
newton/utils.py
📚 Learning: 2026-01-13T07:40:13.635Z
Learnt from: CR
Repo: newton-physics/newton PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-13T07:40:13.635Z
Learning: Applies to newton/examples/**/*.py : Examples must not import from `newton._src`, only from the public Newton API
Applied to files:
newton/utils.py
📚 Learning: 2025-08-12T17:58:00.815Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/_src/solvers/featherstone/kernels.py:18-20
Timestamp: 2025-08-12T17:58:00.815Z
Learning: In newton/_src/core/__init__.py, the function transform_twist is properly re-exported from the spatial module via "from .spatial import (..., transform_twist, ...)" and included in __all__, making it available for import as "from ...core import transform_twist" from other modules.
Applied to files:
newton/utils.py
📚 Learning: 2026-01-13T07:40:13.635Z
Learnt from: CR
Repo: newton-physics/newton PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-13T07:40:13.635Z
Learning: Applies to newton/_src/**/*.py : The `newton/_src/` directory is internal library implementation only and must not be imported by user code (examples, documentation, or external users)
Applied to files:
newton/utils.py
📚 Learning: 2025-09-22T21:08:31.901Z
Learnt from: dylanturpin
Repo: newton-physics/newton PR: 806
File: newton/examples/ik/example_ik_franka.py:121-123
Timestamp: 2025-09-22T21:08:31.901Z
Learning: In the newton physics framework, when creating warp arrays for IK solver joint variables using wp.array(self.model.joint_q, shape=(1, coord_count)), the resulting array acts as a reference/pointer to the original model's joint coordinates, so updates from the IK solver automatically reflect in the model's joint_q buffer used for rendering, despite the general warp documentation suggesting copies are made by default.
Applied to files:
newton/examples/diffsim/example_diffsim_soft_body.pynewton/examples/diffsim/example_diffsim_spring_cage.pynewton/_src/solvers/style3d/linear_solver.py
📚 Learning: 2025-12-12T08:45:43.428Z
Learnt from: nvtw
Repo: newton-physics/newton PR: 1221
File: newton/examples/example_sdf.py:277-287
Timestamp: 2025-12-12T08:45:43.428Z
Learning: In Newtown (Newton) example code, specifically files under newton/examples, computing contacts once per frame and reusing them across all substeps is an intentional design choice, not a bug. Reviewers should verify that contacts are computed before the substep loop and reused for every substep within the same frame. This pattern reduces redundant work and preserves frame-consistency; do not flag as a regression unless the behavior is changed for correctness or performance reasons.
Applied to files:
newton/examples/diffsim/example_diffsim_soft_body.pynewton/examples/diffsim/example_diffsim_spring_cage.py
📚 Learning: 2025-09-17T21:34:05.267Z
Learnt from: gdaviet
Repo: newton-physics/newton PR: 750
File: newton/examples/mpm/example_mpm_granular.py:44-47
Timestamp: 2025-09-17T21:34:05.267Z
Learning: wp.Mesh (Warp mesh objects) expose triangle indices through the `indices` attribute, not `triangles`. The correct usage is `wp.Mesh(...).indices`, not `wp.Mesh(...).triangles`.
Applied to files:
newton/_src/utils/mesh.py
📚 Learning: 2025-08-12T05:17:34.423Z
Learnt from: shi-eric
Repo: newton-physics/newton PR: 521
File: newton/examples/example_cloth_hanging.py:36-36
Timestamp: 2025-08-12T05:17:34.423Z
Learning: The STYLE3D solver in Newton is a new solver that did not exist in warp.sim, so it does not require any migration documentation.
Applied to files:
newton/_src/solvers/style3d/linear_solver.py
📚 Learning: 2025-08-25T20:10:59.536Z
Learnt from: dylanturpin
Repo: newton-physics/newton PR: 634
File: newton/examples/ik/example_ik_franka.py:0-0
Timestamp: 2025-08-25T20:10:59.536Z
Learning: In Newton's IK examples, when creating solver arrays with `wp.array(source_array, shape=new_shape)`, this creates a view into the same underlying memory rather than a copy. This means updates to the reshaped array are automatically reflected in the original array without needing explicit copy operations like `wp.copy()`.
Applied to files:
newton/_src/solvers/style3d/linear_solver.py
🧬 Code graph analysis (4)
newton/_src/solvers/implicit_mpm/solver_implicit_mpm.py (2)
newton/_src/sim/contacts.py (1)
device(110-114)newton/_src/solvers/solver.py (1)
device(169-176)
newton/utils.py (2)
newton/_src/utils/mesh.py (3)
MeshAdjacency(53-111)MeshEdge(27-50)solidify_mesh(715-754)newton/_src/utils/render.py (2)
bourke_color_map(21-60)copy_rgb_frame_uint8(64-93)
newton/_src/solvers/solver.py (1)
newton/_src/sim/contacts.py (1)
device(110-114)
newton/examples/diffsim/example_diffsim_soft_body.py (1)
newton/_src/utils/render.py (1)
bourke_color_map(21-60)
🪛 Ruff (0.14.11)
newton/utils.py
61-61: Unused noqa directive (non-enabled: E402)
Remove unused noqa directive
(RUF100)
newton/_src/utils/mesh.py
65-65: Unused method argument: num_tris
(ARG002)
newton/_src/solvers/style3d/linear_solver.py
230-230: Unused noqa directive (non-enabled: PLC0415)
Remove unused noqa directive
(RUF100)
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Run GPU Benchmarks / Run GPU Benchmarks on AWS EC2
🔇 Additional comments (13)
newton/_src/solvers/solver.py (1)
168-176: LGTM!The return type annotation update from
wp.context.Devicetowp.Devicecorrectly addresses the Warp deprecation warning by using the public API instead of the internal path. The docstring is already consistent with the new type annotation.newton/_src/solvers/implicit_mpm/solver_implicit_mpm.py (1)
1741-1741: LGTM! Clean simplification of CUDA graph support check.The change correctly uses the public Warp API
wp.is_conditional_graph_supported()to gate CUDA graph usage on both device type and runtime capability.newton/_src/utils/render.py (1)
63-93: LGTM!The kernel correctly handles the coordinate flip from OpenGL's bottom-left origin to top-left origin. The launch dimension documentation is clear and the indexing logic is sound.
newton/examples/diffsim/example_diffsim_spring_cage.py (2)
33-33: LGTM!Correctly imports
bourke_color_mapfrom the public Newton API (newton.utils) instead of internal Warp symbols, adhering to the coding guidelines.
268-268: LGTM!The call site correctly uses the imported
bourke_color_mapfunction with the expected arguments.newton/_src/utils/mesh.py (4)
26-51: LGTM!Well-documented dataclass with clear field descriptions and boundary edge handling conventions.
65-79: LGTM!The
num_trisparameter is intentionally kept for API compatibility as documented. The edge construction correctly processes all three edges per triangle.
81-112: LGTM!Correct edge adjacency logic with proper handling of boundary edges and non-manifold detection.
715-754: LGTM on the wrapper logic.The function correctly handles thickness conversion and array marshalling. The main concern is the kernel's race condition noted above.
newton/utils.py (2)
32-56: LGTM!Correctly re-exports
MeshAdjacency,MeshEdge, andsolidify_meshfrom the internal implementation to the public API surface, following the established pattern.
58-69: LGTM!Correctly exposes
bourke_color_mapandcopy_rgb_frame_uint8via the public API. Thenoqa: E402comment maintains consistency with the rest of the file's import pattern, though Ruff notes it may be unnecessary.newton/examples/diffsim/example_diffsim_soft_body.py (2)
37-37: LGTM!Correctly imports
bourke_color_mapfrom the public Newton API (newton.utils) instead of internal Warp symbols, adhering to the coding guidelines.
356-356: LGTM!The call site correctly uses the imported
bourke_color_mapfunction. Theloss_historyaccess is safe sincerender()is called afterstep()which populates the list.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
44e0fbd to
aad7eac
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@pyproject.toml`:
- Line 28: The specified nightly version in the dependency string dependencies =
["warp-lang>=1.12.0.dev20251219"] is invalid on the NVIDIA PyPI index; update
that version to an existing nightly (for example change it to dependencies =
["warp-lang>=1.12.0.dev20251231"] or a newer dev build) so the package resolver
can find the release.
♻️ Duplicate comments (3)
newton/_src/utils/mesh.py (1)
652-713: Race condition on shared vertex writes persists.This issue was identified in previous reviews but remains unaddressed. The kernel computes a per-triangle face normal and writes to
out_vertices[i*2],out_vertices[j*2], etc. When a vertex is shared by multiple triangles with different face normals, multiple threads write conflicting values to the same output locations, resulting in non-deterministic geometry.The recommended fixes from previous reviews remain valid:
- Pre-compute per-vertex averaged normals in a separate kernel pass
- Duplicate vertices per-face (change output to
num_triangles * 6vertices)newton/utils.py (1)
61-64: Remove unused# noqa: E402directive.Ruff reports this directive is unused since E402 is not enabled.
Proposed diff
-from ._src.utils.render import ( # noqa: E402 +from ._src.utils.render import ( bourke_color_map, copy_rgb_frame_uint8, )newton/_src/utils/render.py (1)
21-60: Guard against division by zero whenlow == high.When
low == high,dv = 0and the subsequent divisions will raiseZeroDivisionError. This edge case can occur when all values in a dataset are identical.Proposed fix
if v > high: v = high dv = high - low + + if dv == 0.0: + return c # Return default white color for degenerate range if v < (low + 0.25 * dv):
🧹 Nitpick comments (2)
newton/_src/solvers/style3d/linear_solver.py (1)
230-230: Remove unusednoqadirective.The
# noqa: PLC0415directive is flagged as unused because thePLC0415rule (import-outside-toplevel) is not enabled in the linter configuration.Suggested fix
- from warp._src.context import runtime # noqa: PLC0415 + from warp._src.context import runtimenewton/_src/sim/builder.py (1)
5481-5494: MeshAdjacency swap looks correct; consider locking dtype foredge_indices.np.fromiter(..., int)produces platformint(often int64), then gets fed into later int32 paths; not usually wrong, but easy to make deterministic/consistent. Also, ensure MeshEdge fieldso0/o1/v0/v1match the new MeshEdge definition.Proposed tweak (dtype stability)
- edge_indices = np.fromiter( + edge_indices = np.fromiter( (x for e in adj.edges.values() for x in (e.o0, e.o1, e.v0, e.v1)), - int, + dtype=np.int32, ).reshape(-1, 4)
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
uv.lockis excluded by!**/*.lock
📒 Files selected for processing (31)
docs/generate_api.pynewton/_src/core/types.pynewton/_src/geometry/sdf_mc.pynewton/_src/sim/builder.pynewton/_src/sim/contacts.pynewton/_src/sim/graph_coloring.pynewton/_src/sim/style3d/builder_style3d.pynewton/_src/solvers/implicit_mpm/solve_rheology.pynewton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/_src/solvers/solver.pynewton/_src/solvers/style3d/collision/bvh/bvh.pynewton/_src/solvers/style3d/linear_solver.pynewton/_src/solvers/vbd/particle_vbd_kernels.pynewton/_src/solvers/vbd/rigid_vbd_kernels.pynewton/_src/utils/__init__.pynewton/_src/utils/import_mjcf.pynewton/_src/utils/mesh.pynewton/_src/utils/recorder.pynewton/_src/utils/render.pynewton/_src/utils/selection.pynewton/_src/viewer/viewer.pynewton/_src/viewer/viewer_gl.pynewton/examples/diffsim/example_diffsim_ball.pynewton/examples/diffsim/example_diffsim_cloth.pynewton/examples/diffsim/example_diffsim_drone.pynewton/examples/diffsim/example_diffsim_soft_body.pynewton/examples/diffsim/example_diffsim_spring_cage.pynewton/examples/robot/example_robot_anymal_c_walk.pynewton/tests/test_coloring.pynewton/utils.pypyproject.toml
🚧 Files skipped from review as they are similar to previous changes (15)
- newton/examples/diffsim/example_diffsim_soft_body.py
- newton/_src/viewer/viewer.py
- newton/_src/solvers/solver.py
- newton/_src/utils/init.py
- newton/_src/sim/graph_coloring.py
- newton/tests/test_coloring.py
- newton/_src/utils/import_mjcf.py
- newton/_src/geometry/sdf_mc.py
- newton/examples/robot/example_robot_anymal_c_walk.py
- newton/_src/core/types.py
- newton/_src/solvers/vbd/particle_vbd_kernels.py
- docs/generate_api.py
- newton/_src/viewer/viewer_gl.py
- newton/examples/diffsim/example_diffsim_cloth.py
- newton/_src/solvers/style3d/collision/bvh/bvh.py
🧰 Additional context used
📓 Path-based instructions (5)
newton/_src/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
The
newton/_src/directory is internal library implementation only and must not be imported by user code (examples, documentation, or external users)
Files:
newton/_src/solvers/style3d/linear_solver.pynewton/_src/sim/style3d/builder_style3d.pynewton/_src/utils/recorder.pynewton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/_src/utils/render.pynewton/_src/solvers/vbd/rigid_vbd_kernels.pynewton/_src/utils/mesh.pynewton/_src/sim/builder.pynewton/_src/solvers/implicit_mpm/solve_rheology.pynewton/_src/utils/selection.pynewton/_src/sim/contacts.py
newton/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
Any user-facing class/function/object added under
_srcmust be exposed via the public Newton API through re-exports
Files:
newton/_src/solvers/style3d/linear_solver.pynewton/_src/sim/style3d/builder_style3d.pynewton/examples/diffsim/example_diffsim_spring_cage.pynewton/examples/diffsim/example_diffsim_ball.pynewton/_src/utils/recorder.pynewton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/_src/utils/render.pynewton/examples/diffsim/example_diffsim_drone.pynewton/_src/solvers/vbd/rigid_vbd_kernels.pynewton/_src/utils/mesh.pynewton/_src/sim/builder.pynewton/_src/solvers/implicit_mpm/solve_rheology.pynewton/_src/utils/selection.pynewton/_src/sim/contacts.pynewton/utils.py
**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
**/*.py: Use prefix-first naming for classes:ActuatorPD,ActuatorPID(notPDActuator,PIDActuator)
Use prefix-first naming for methods:add_shape_sphere()(notadd_sphere_shape())
Method names must usesnake_case
Prefer nested classes when self-contained: if a helper type or enum is only meaningful inside one parent class and doesn't need a public identity, define it as a nested class instead of a top-level class/module
Follow PEP 8 for Python code
Use Google-style docstrings with clear, concise explanations of what functions do, their parameters, and return values
Files:
newton/_src/solvers/style3d/linear_solver.pynewton/_src/sim/style3d/builder_style3d.pynewton/examples/diffsim/example_diffsim_spring_cage.pynewton/examples/diffsim/example_diffsim_ball.pynewton/_src/utils/recorder.pynewton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/_src/utils/render.pynewton/examples/diffsim/example_diffsim_drone.pynewton/_src/solvers/vbd/rigid_vbd_kernels.pynewton/_src/utils/mesh.pynewton/_src/sim/builder.pynewton/_src/solvers/implicit_mpm/solve_rheology.pynewton/_src/utils/selection.pynewton/_src/sim/contacts.pynewton/utils.py
**/*
📄 CodeRabbit inference engine (AGENTS.md)
CLI arguments must use
kebab-case(e.g.,--use-cuda-graph, not--use_cuda_graph)
Files:
newton/_src/solvers/style3d/linear_solver.pynewton/_src/sim/style3d/builder_style3d.pynewton/examples/diffsim/example_diffsim_spring_cage.pynewton/examples/diffsim/example_diffsim_ball.pypyproject.tomlnewton/_src/utils/recorder.pynewton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/_src/utils/render.pynewton/examples/diffsim/example_diffsim_drone.pynewton/_src/solvers/vbd/rigid_vbd_kernels.pynewton/_src/utils/mesh.pynewton/_src/sim/builder.pynewton/_src/solvers/implicit_mpm/solve_rheology.pynewton/_src/utils/selection.pynewton/_src/sim/contacts.pynewton/utils.py
newton/examples/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
newton/examples/**/*.py: Examples must not import fromnewton._src, only from the public Newton API
Examples must follow the format with anExampleclass and must be registered inREADME.mdwith auv runcommand and screenshot
Examples must implement atest_final()method that verifies the simulation state is valid after the example has run
Examples may optionally implement atest_post_step()method that is evaluated after everystep()call
Files:
newton/examples/diffsim/example_diffsim_spring_cage.pynewton/examples/diffsim/example_diffsim_ball.pynewton/examples/diffsim/example_diffsim_drone.py
🧠 Learnings (36)
📓 Common learnings
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/_src/solvers/featherstone/kernels.py:75-75
Timestamp: 2025-08-12T18:04:06.577Z
Learning: The Newton physics framework requires nightly Warp builds, which means compatibility concerns with older stable Warp versions (like missing functions such as wp.spatial_adjoint) are not relevant for this project.
Learnt from: shi-eric
Repo: newton-physics/newton PR: 521
File: newton/examples/example_cloth_hanging.py:36-36
Timestamp: 2025-08-12T05:17:34.423Z
Learning: The Newton migration guide (docs/migration.rst) is specifically for documenting how to migrate existing warp.sim functionality to Newton equivalents. New Newton-only features that didn't exist in warp.sim do not need migration documentation.
Learnt from: shi-eric
Repo: newton-physics/newton PR: 461
File: asv/benchmarks/envs/example_humanoid.py:40-41
Timestamp: 2025-07-23T14:36:42.182Z
Learning: In Warp benchmarks, explicit wp.init() calls are not needed in most circumstances since the first Warp API call that requires initialization will automatically call wp.init(). Explicit wp.init() in setup() methods is helpful when the ASV benchmark is measuring a Warp API call, as wp.init() has non-trivial overhead that should be excluded from the benchmark timing.
📚 Learning: 2025-08-12T05:17:34.423Z
Learnt from: shi-eric
Repo: newton-physics/newton PR: 521
File: newton/examples/example_cloth_hanging.py:36-36
Timestamp: 2025-08-12T05:17:34.423Z
Learning: The STYLE3D solver in Newton is a new solver that did not exist in warp.sim, so it does not require any migration documentation.
Applied to files:
newton/_src/solvers/style3d/linear_solver.pynewton/_src/solvers/implicit_mpm/solve_rheology.py
📚 Learning: 2025-09-18T07:05:56.836Z
Learnt from: gdaviet
Repo: newton-physics/newton PR: 750
File: newton/_src/solvers/implicit_mpm/solve_rheology.py:969-986
Timestamp: 2025-09-18T07:05:56.836Z
Learning: In newton/_src/solvers/implicit_mpm/solve_rheology.py, transposed_strain_mat parameter cannot be None - the type signature was corrected to reflect this guarantee, eliminating the need for None checks when accessing transposed_strain_mat.offsets.
Applied to files:
newton/_src/solvers/style3d/linear_solver.pynewton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/_src/solvers/implicit_mpm/solve_rheology.py
📚 Learning: 2025-08-12T05:17:34.423Z
Learnt from: shi-eric
Repo: newton-physics/newton PR: 521
File: newton/examples/example_cloth_hanging.py:36-36
Timestamp: 2025-08-12T05:17:34.423Z
Learning: The Newton migration guide (docs/migration.rst) is specifically for documenting how to migrate existing warp.sim functionality to Newton equivalents. New Newton-only features that didn't exist in warp.sim do not need migration documentation.
Applied to files:
newton/_src/solvers/style3d/linear_solver.pynewton/examples/diffsim/example_diffsim_spring_cage.pypyproject.tomlnewton/_src/utils/recorder.pynewton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/examples/diffsim/example_diffsim_drone.pynewton/_src/solvers/vbd/rigid_vbd_kernels.pynewton/_src/sim/builder.pynewton/_src/solvers/implicit_mpm/solve_rheology.pynewton/_src/sim/contacts.py
📚 Learning: 2025-09-22T21:08:31.901Z
Learnt from: dylanturpin
Repo: newton-physics/newton PR: 806
File: newton/examples/ik/example_ik_franka.py:121-123
Timestamp: 2025-09-22T21:08:31.901Z
Learning: In the newton physics framework, when creating warp arrays for IK solver joint variables using wp.array(self.model.joint_q, shape=(1, coord_count)), the resulting array acts as a reference/pointer to the original model's joint coordinates, so updates from the IK solver automatically reflect in the model's joint_q buffer used for rendering, despite the general warp documentation suggesting copies are made by default.
Applied to files:
newton/_src/solvers/style3d/linear_solver.pynewton/examples/diffsim/example_diffsim_spring_cage.pynewton/examples/diffsim/example_diffsim_drone.pynewton/_src/solvers/vbd/rigid_vbd_kernels.py
📚 Learning: 2025-08-12T18:04:06.577Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/_src/solvers/featherstone/kernels.py:75-75
Timestamp: 2025-08-12T18:04:06.577Z
Learning: The Newton physics framework requires nightly Warp builds, which means compatibility concerns with older stable Warp versions (like missing functions such as wp.spatial_adjoint) are not relevant for this project.
Applied to files:
newton/_src/solvers/style3d/linear_solver.pynewton/examples/diffsim/example_diffsim_spring_cage.pypyproject.tomlnewton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/_src/solvers/vbd/rigid_vbd_kernels.pynewton/_src/sim/builder.py
📚 Learning: 2026-01-13T03:11:40.556Z
Learnt from: jumyungc
Repo: newton-physics/newton PR: 1333
File: newton/_src/sim/builder.py:0-0
Timestamp: 2026-01-13T03:11:40.556Z
Learning: Ensure all VBD damping semantics follow Rayleigh-style damping and are unitless. This convention, demonstrated in SolverVBD, should be applied consistently across all VBD-related constraints in the codebase. In newton/_src/sim/builder.py, validate that any damping terms use the same normalization and are treated as dimensionless; add comments and unit tests to enforce consistency across VBD components.
Applied to files:
newton/_src/solvers/style3d/linear_solver.pynewton/_src/sim/style3d/builder_style3d.pynewton/examples/diffsim/example_diffsim_spring_cage.pynewton/examples/diffsim/example_diffsim_ball.pynewton/_src/utils/recorder.pynewton/_src/solvers/implicit_mpm/solver_implicit_mpm.pynewton/_src/utils/render.pynewton/examples/diffsim/example_diffsim_drone.pynewton/_src/solvers/vbd/rigid_vbd_kernels.pynewton/_src/utils/mesh.pynewton/_src/sim/builder.pynewton/_src/solvers/implicit_mpm/solve_rheology.pynewton/_src/utils/selection.pynewton/_src/sim/contacts.pynewton/utils.py
📚 Learning: 2025-09-17T21:34:05.267Z
Learnt from: gdaviet
Repo: newton-physics/newton PR: 750
File: newton/examples/mpm/example_mpm_granular.py:44-47
Timestamp: 2025-09-17T21:34:05.267Z
Learning: wp.Mesh (Warp mesh objects) expose triangle indices through the `indices` attribute, not `triangles`. The correct usage is `wp.Mesh(...).indices`, not `wp.Mesh(...).triangles`.
Applied to files:
newton/_src/sim/style3d/builder_style3d.pynewton/_src/utils/mesh.pynewton/_src/sim/builder.py
📚 Learning: 2025-12-12T08:45:43.428Z
Learnt from: nvtw
Repo: newton-physics/newton PR: 1221
File: newton/examples/example_sdf.py:277-287
Timestamp: 2025-12-12T08:45:43.428Z
Learning: In Newtown (Newton) example code, specifically files under newton/examples, computing contacts once per frame and reusing them across all substeps is an intentional design choice, not a bug. Reviewers should verify that contacts are computed before the substep loop and reused for every substep within the same frame. This pattern reduces redundant work and preserves frame-consistency; do not flag as a regression unless the behavior is changed for correctness or performance reasons.
Applied to files:
newton/examples/diffsim/example_diffsim_spring_cage.pynewton/examples/diffsim/example_diffsim_ball.pynewton/examples/diffsim/example_diffsim_drone.py
📚 Learning: 2026-01-13T07:40:13.635Z
Learnt from: CR
Repo: newton-physics/newton PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-13T07:40:13.635Z
Learning: Applies to newton/examples/**/*.py : Examples must not import from `newton._src`, only from the public Newton API
Applied to files:
newton/examples/diffsim/example_diffsim_ball.pynewton/utils.py
📚 Learning: 2025-08-27T23:33:32.527Z
Learnt from: shi-eric
Repo: newton-physics/newton PR: 660
File: pyproject.toml:28-28
Timestamp: 2025-08-27T23:33:32.527Z
Learning: In Python projects, it's normal and correct to have different warp-lang version specifications across files: pyproject.toml should specify minimum compatible versions using >= for flexibility, while specific environments like asv.conf.json can pin exact versions using == for reproducibility. These serve different purposes and should not be "aligned" to the same version.
Applied to files:
pyproject.toml
📚 Learning: 2025-10-04T06:44:52.713Z
Learnt from: shi-eric
Repo: newton-physics/newton PR: 879
File: .gitlab-ci.yml:125-145
Timestamp: 2025-10-04T06:44:52.713Z
Learning: In the Newton project, the "linux-x86_64 test warp nightly" GitLab CI job intentionally runs on every pipeline (not limited to `.test_common` rules) to detect Warp nightly integration issues early, since Warp nightly releases are unpredictable. This design is acceptable because `allow_failure: true` prevents blocking the pipeline.
Applied to files:
pyproject.toml
📚 Learning: 2025-08-27T23:32:48.670Z
Learnt from: shi-eric
Repo: newton-physics/newton PR: 660
File: pyproject.toml:54-59
Timestamp: 2025-08-27T23:32:48.670Z
Learning: In the newton project's pyproject.toml, self-referential extras (e.g., `examples = ["newton[sim]", "newton[importers]", ...]`) are normal and encouraged for dependency management, rather than inlining the dependencies.
Applied to files:
pyproject.toml
📚 Learning: 2025-08-25T20:10:51.009Z
Learnt from: dylanturpin
Repo: newton-physics/newton PR: 634
File: newton/examples/ik/example_ik_h1.py:0-0
Timestamp: 2025-08-25T20:10:51.009Z
Learning: In Warp, creating a new wp.array() with an existing array and different shape (e.g., wp.array(existing_array, shape=new_shape)) creates a view into the same underlying memory buffer, not a copy. This means modifications through either view are automatically reflected in both arrays.
Applied to files:
newton/_src/utils/recorder.py
📚 Learning: 2025-08-19T12:27:30.629Z
Learnt from: preist-nvidia
Repo: newton-physics/newton PR: 579
File: newton/examples/example_mujoco.py:350-354
Timestamp: 2025-08-19T12:27:30.629Z
Learning: In Newton examples, there's a distinction between solver parameters and Example class attributes. The Example class can have its own use_mujoco attribute for controlling example-level behavior (like CUDA graphs, rendering logic), while the solver uses use_mujoco_cpu for backend selection. These serve different purposes and should not be conflated during API renames.
Applied to files:
newton/_src/solvers/implicit_mpm/solver_implicit_mpm.py
📚 Learning: 2025-12-12T15:23:30.014Z
Learnt from: vastsoun
Repo: newton-physics/newton PR: 1019
File: newton/_src/solvers/kamino/examples/sim/example_sim_basics_boxes_fourbar.py:149-163
Timestamp: 2025-12-12T15:23:30.014Z
Learning: In Kamino simulation examples under newton/_src/solvers/kamino/examples/sim/, the pattern where logging=True and use_cuda_graph=True creates a mismatch (SimulationLogger constructed but settings.compute_metrics and logger.log() calls guarded by `if not self.use_cuda_graph`) should not be flagged. These examples will be refactored in a future commit, and this pattern is intentionally deferred.
Applied to files:
newton/_src/solvers/implicit_mpm/solver_implicit_mpm.py
📚 Learning: 2025-10-29T14:55:48.171Z
Learnt from: gdaviet
Repo: newton-physics/newton PR: 940
File: newton/examples/mpm/example_mpm_granular.py:92-101
Timestamp: 2025-10-29T14:55:48.171Z
Learning: In newton/examples/mpm/example_mpm_granular.py, the capture() method intentionally advances the simulation state once during CUDA graph capture. This is expected behavior because CUDA graph capture records exact memory addresses, so the state arrays (state_0, state_1) cannot be reset or reallocated after capture without invalidating the graph.
Applied to files:
newton/_src/solvers/implicit_mpm/solver_implicit_mpm.py
📚 Learning: 2025-08-19T12:27:30.629Z
Learnt from: preist-nvidia
Repo: newton-physics/newton PR: 579
File: newton/examples/example_mujoco.py:350-354
Timestamp: 2025-08-19T12:27:30.629Z
Learning: In Newton examples, Example.use_mujoco is a high-level attribute that controls whether to use MuJoCo solver vs other solvers (like XPBD), while SolverMuJoCo.use_mujoco_cpu controls the backend within MuJoCo (CPU vs Warp). These are separate concepts serving different purposes - the PR rename only applies to the solver parameter, not the Example class attributes.
Applied to files:
newton/_src/solvers/implicit_mpm/solver_implicit_mpm.py
📚 Learning: 2025-08-12T17:52:15.009Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/_src/utils/import_mjcf.py:226-231
Timestamp: 2025-08-12T17:52:15.009Z
Learning: In the Newton codebase, when passing array-like objects (numpy arrays, lists, tuples) to wp.vec3(), the consistent pattern is to use the unpacking operator: wp.vec3(*array) rather than wp.vec3(array). This pattern is used throughout newton/_src/utils/import_mjcf.py and newton/_src/core/types.py.
Applied to files:
newton/_src/solvers/vbd/rigid_vbd_kernels.py
📚 Learning: 2025-09-22T21:08:31.901Z
Learnt from: dylanturpin
Repo: newton-physics/newton PR: 806
File: newton/examples/ik/example_ik_franka.py:121-123
Timestamp: 2025-09-22T21:08:31.901Z
Learning: In the newton physics framework, when creating warp arrays for IK solver joint variables using wp.array(self.model.joint_q, shape=(1, coord_count)), the resulting array acts as a reference/pointer to the original model's joint coordinates, so updates from the IK solver automatically reflect in the model's joint_q buffer used for rendering.
Applied to files:
newton/_src/solvers/vbd/rigid_vbd_kernels.py
📚 Learning: 2025-08-18T15:56:26.587Z
Learnt from: adenzler-nvidia
Repo: newton-physics/newton PR: 552
File: newton/_src/solvers/mujoco/solver_mujoco.py:0-0
Timestamp: 2025-08-18T15:56:26.587Z
Learning: In Newton's MuJoCo solver, when transforming joint axes from Newton's internal frame to MuJoCo's expected frame, use wp.quat_rotate(joint_rot, axis) not wp.quat_rotate_inv(joint_rot, axis). The joint_rot represents rotation from joint-local to body frame, so forward rotation is correct.
Applied to files:
newton/_src/solvers/vbd/rigid_vbd_kernels.py
📚 Learning: 2025-09-25T16:14:22.033Z
Learnt from: dylanturpin
Repo: newton-physics/newton PR: 806
File: newton/_src/sim/ik/ik_objectives.py:0-0
Timestamp: 2025-09-25T16:14:22.033Z
Learning: In NVIDIA Warp's Newton physics library, wp.transform supports direct numerical indexing (e.g., body_tf[0], body_tf[1], body_tf[2] for position and body_tf[3], body_tf[4], body_tf[5], body_tf[6] for quaternion components) to access its elements. This is the standard API used throughout the codebase.
Applied to files:
newton/_src/solvers/vbd/rigid_vbd_kernels.py
📚 Learning: 2025-11-24T10:44:09.613Z
Learnt from: gdaviet
Repo: newton-physics/newton PR: 1108
File: newton/_src/solvers/implicit_mpm/rasterized_collisions.py:94-129
Timestamp: 2025-11-24T10:44:09.613Z
Learning: In Warp, wp.normalize() returns a zero vector (or zero quaternion) when given a zero-length input, so explicit zero-length checks before normalization are not required.
Applied to files:
newton/_src/solvers/vbd/rigid_vbd_kernels.py
📚 Learning: 2025-12-01T17:00:28.889Z
Learnt from: camevor
Repo: newton-physics/newton PR: 1161
File: newton/_src/solvers/mujoco/kernels.py:1268-1268
Timestamp: 2025-12-01T17:00:28.889Z
Learning: MuJoCo Warp spatial vectors (e.g., cacc, cvel) use the convention (angular, linear), which is opposite to Newton's (linear, angular) convention. When converting from MuJoCo Warp to Newton format, spatial_top() on MuJoCo Warp data extracts the angular component, and spatial_bottom() extracts the linear component.
Applied to files:
newton/_src/solvers/vbd/rigid_vbd_kernels.py
📚 Learning: 2025-11-28T11:12:40.805Z
Learnt from: camevor
Repo: newton-physics/newton PR: 1146
File: newton/examples/basic/example_basic_joints.py:206-213
Timestamp: 2025-11-28T11:12:40.805Z
Learning: In Newton's standard solvers (XPBD, SemiImplicit, SolverMuJoCo), spatial vectors in State.body_qd use the ordering (linear, angular): wp.spatial_top(qd) returns linear velocity and wp.spatial_bottom(qd) returns angular velocity. This is the opposite of typical Modern Robotics spatial twist notation where (angular, linear) is used.
Applied to files:
newton/_src/solvers/vbd/rigid_vbd_kernels.py
📚 Learning: 2025-09-26T05:58:21.013Z
Learnt from: WenchaoHuang
Repo: newton-physics/newton PR: 835
File: newton/_src/solvers/style3d/collision/collision.py:49-53
Timestamp: 2025-09-26T05:58:21.013Z
Learning: In newton/_src/solvers/style3d/collision/collision.py, the broad_phase buffers (broad_phase_ee, broad_phase_ef, broad_phase_vf) created with wp.array() don't need zero-initialization because they follow a write-first-read-later pattern: BVH query kernels in frame_begin() populate these buffers completely (write-only operations), and collision kernels only read from them afterward in accumulate_contact_force(), ensuring no undefined reads occur.
Applied to files:
newton/_src/utils/mesh.pynewton/_src/solvers/implicit_mpm/solve_rheology.py
📚 Learning: 2025-12-12T17:45:26.847Z
Learnt from: vastsoun
Repo: newton-physics/newton PR: 1019
File: newton/_src/solvers/kamino/geometry/primitives.py:0-0
Timestamp: 2025-12-12T17:45:26.847Z
Learning: In newton/_src/solvers/kamino/geometry/primitives.py, the narrow-phase kernel `_primitive_narrowphase` does not need to handle symmetric shape-pair orderings (e.g., both SPHERE-BOX and BOX-SPHERE) because `kamino.core.builder.ModelBuilder` and `kamino.geometry.primitive.broadphase` guarantee that explicit candidate geometry pairs are always defined with GIDs in ascending order.
Applied to files:
newton/_src/utils/mesh.py
📚 Learning: 2026-01-12T10:11:39.312Z
Learnt from: nvtw
Repo: newton-physics/newton PR: 1314
File: newton/_src/sim/builder.py:6061-6091
Timestamp: 2026-01-12T10:11:39.312Z
Learning: In finalize() validation logic (e.g., newton/_src/sim/builder.py and similar files), keep the validation lightweight. Do not add union-find/connected-components validation for loop joints. The current behavior—allowing non-articulated joints when the child is in any articulation—is acceptable. Avoid overengineering here.
Applied to files:
newton/_src/sim/builder.py
📚 Learning: 2026-01-13T03:11:40.555Z
Learnt from: jumyungc
Repo: newton-physics/newton PR: 1333
File: newton/_src/sim/builder.py:0-0
Timestamp: 2026-01-13T03:11:40.555Z
Learning: In newton/_src/sim/builder.py, follow VBD conventions: treat radians as dimensionless. Prefer wording 'torque per radian' instead of writing 'N·m/rad' in any docs, strings, or generated text within this file. Ensure consistent usage in docstrings, comments, and documentation strings associated with this module.
Applied to files:
newton/_src/sim/builder.py
📚 Learning: 2025-09-09T11:03:41.928Z
Learnt from: gdaviet
Repo: newton-physics/newton PR: 750
File: newton/_src/solvers/implicit_mpm/solve_rheology.py:892-895
Timestamp: 2025-09-09T11:03:41.928Z
Learning: In newton/_src/solvers/implicit_mpm/solve_rheology.py, passing None for compliance_mat_diagonal is intentional to avoid loading zeros from global memory when compliance_mat is None, rather than creating a zero matrix and extracting its diagonal.
Applied to files:
newton/_src/solvers/implicit_mpm/solve_rheology.py
📚 Learning: 2026-01-13T07:40:13.635Z
Learnt from: CR
Repo: newton-physics/newton PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-13T07:40:13.635Z
Learning: Applies to newton/**/*.py : Any user-facing class/function/object added under `_src` must be exposed via the public Newton API through re-exports
Applied to files:
newton/utils.py
📚 Learning: 2025-08-12T17:51:37.474Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/geometry.py:16-22
Timestamp: 2025-08-12T17:51:37.474Z
Learning: In the Newton public API refactor, common geometry symbols like ParticleFlags and ShapeFlags are now exposed at the top level in newton/__init__.py rather than through newton.geometry. The newton/geometry.py module is intentionally focused only on broad-phase collision detection classes (BroadPhaseAllPairs, BroadPhaseExplicit, BroadPhaseSAP).
Applied to files:
newton/utils.py
📚 Learning: 2025-08-14T17:38:36.106Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/__init__.py:25-29
Timestamp: 2025-08-14T17:38:36.106Z
Learning: The Newton project prefers incremental __all__ building using __all__ += [...] pattern to group exports with their related imports, rather than a single consolidated __all__ at the end of the file.
Applied to files:
newton/utils.py
📚 Learning: 2025-08-12T17:58:00.815Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/_src/solvers/featherstone/kernels.py:18-20
Timestamp: 2025-08-12T17:58:00.815Z
Learning: In newton/_src/core/__init__.py, the function transform_twist is properly re-exported from the spatial module via "from .spatial import (..., transform_twist, ...)" and included in __all__, making it available for import as "from ...core import transform_twist" from other modules.
Applied to files:
newton/utils.py
📚 Learning: 2026-01-13T07:40:13.635Z
Learnt from: CR
Repo: newton-physics/newton PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-13T07:40:13.635Z
Learning: Applies to newton/_src/**/*.py : The `newton/_src/` directory is internal library implementation only and must not be imported by user code (examples, documentation, or external users)
Applied to files:
newton/utils.py
📚 Learning: 2025-11-07T01:42:36.906Z
Learnt from: daniela-hase
Repo: newton-physics/newton PR: 1044
File: newton/_src/sensors/tiled_camera_sensor.py:224-256
Timestamp: 2025-11-07T01:42:36.906Z
Learning: In newton/_src/sensors/tiled_camera_sensor.py, the `# noqa: PLC0415` directives on the local PIL imports (lines 224 and 256 in save_color_image and save_depth_image methods) should be kept because they are required by the pre-commit configuration. The local imports are intentional for optional dependency handling.
Applied to files:
newton/utils.py
🧬 Code graph analysis (7)
newton/_src/sim/style3d/builder_style3d.py (1)
newton/_src/utils/mesh.py (1)
MeshAdjacency(53-111)
newton/examples/diffsim/example_diffsim_spring_cage.py (1)
newton/_src/utils/render.py (1)
bourke_color_map(21-60)
newton/examples/diffsim/example_diffsim_ball.py (1)
newton/_src/utils/render.py (1)
bourke_color_map(21-60)
newton/_src/solvers/implicit_mpm/solver_implicit_mpm.py (2)
newton/_src/sim/contacts.py (1)
device(110-114)newton/_src/solvers/solver.py (1)
device(169-176)
newton/examples/diffsim/example_diffsim_drone.py (1)
newton/_src/utils/render.py (1)
bourke_color_map(21-60)
newton/_src/sim/builder.py (1)
newton/_src/utils/mesh.py (1)
MeshAdjacency(53-111)
newton/utils.py (1)
newton/_src/utils/mesh.py (4)
MeshAdjacency(53-111)MeshEdge(27-50)create_box_mesh(515-580)solidify_mesh(715-754)
🪛 Ruff (0.14.11)
newton/_src/solvers/style3d/linear_solver.py
230-230: Unused noqa directive (non-enabled: PLC0415)
Remove unused noqa directive
(RUF100)
newton/_src/utils/mesh.py
65-65: Unused method argument: num_tris
(ARG002)
newton/utils.py
61-61: Unused noqa directive (non-enabled: E402)
Remove unused noqa directive
(RUF100)
🔇 Additional comments (28)
newton/_src/solvers/style3d/linear_solver.py (1)
242-244: LGTM on the deprecation fix.The change from
type_lengthtotype_sizealigns with the Warp v1.11.0 API updates. The surrounding calls totype_size_in_byteson lines 242-243 remain unchanged and correctly use the publicwp.typesnamespace.newton/_src/solvers/implicit_mpm/solver_implicit_mpm.py (1)
1741-1741: LGTM! Clean simplification for CUDA graph support check.The change correctly migrates from the deprecated internal
assert_conditional_graph_supportto the publicwp.is_conditional_graph_supported()API, addressing the Warp v1.11.0 deprecation warnings. The boolean expression is clear and correctly gates CUDA graph usage on both device type and Warp's conditional graph support.newton/_src/utils/recorder.py (2)
556-557: LGTM!The migration from
wp.context.Devicetowp.Devicecorrectly addresses the Warp v1.11.0 deprecation warning by using the public API instead of the internal symbol.
760-764: LGTM!The migration from
wp.types.<dtype>towp.<dtype>correctly addresses the Warp v1.11.0 deprecation warning. Standard Warp dtypes likeuint64,float32,vec3, etc. are accessible directly from thewpnamespace as part of the public API.newton/_src/solvers/implicit_mpm/solve_rheology.py (3)
986-991: LGTM! Velocity delta computation is correct.The
array_axpycall computesprev_collider_velocity = alpha * collider_velocity + beta * prev_collider_velocity, which withalpha=1.0, beta=-1.0yieldscollider_velocity - prev_collider_velocity. This correctly computes the velocity delta as documented in the function's docstring, and the result is then aliased asdelta_velocityfor the subsequent matrix operations.
1442-1442: LGTM! Jacobi stress update is correct.The
array_axpycall withalpha=1.0, beta=1.0correctly accumulates the delta stress into the local stress:local_stress += delta_stress. This is consistent with the Jacobi iteration logic following the transposed strain matrix multiplication.
23-23: Import path update is correct.The change from
warp.fem.utilstowarp.fem.linalgforarray_axpyandsymmetric_eigenvalues_qraligns with Warp's current API and the PR's objective to address deprecation warnings in Warp v1.11.0+. Both functions are properly exported fromwarp.fem.linalg.newton/_src/utils/selection.py (1)
511-514: LGTM — correctly migrates from deprecated internal symbol.The switch from
wp.codegen.StructInstancetowp.types.is_struct()aligns with the PR objective of addressing Warp v1.11.0 deprecation warnings. The logic for handling struct attributes remains unchanged.Minor: for consistency with line 21 where
is_arrayis imported directly, you could addis_structto that import. This is optional.newton/_src/sim/builder.py (2)
59-61: Good move switching cloth adjacency off Warp helpers. This localizes the deprecation surface and keeps the builder logic unchanged.
1780-1789: Remove this concern; Newton's nightly Warp pin makes internal API access safe. The project explicitly requireswarp-lang>=1.12.0.dev20251219(nightly builds), where internal symbols likewp._src.context.runtime.core.wp_builtin_mul_transformf_transformfare part of the stable contract. Similar unguardedwp._srcaccess patterns exist throughout the codebase (sdf_mc.py,graph_coloring.py), confirming this is the intended approach.newton/_src/sim/contacts.py (1)
20-20: LGTM!The import change from the internal
warp.context.Deviceliketo the publicwarp.DeviceLikecorrectly addresses Warp deprecation warnings while maintaining theDevicelikealias for backward compatibility throughout the codebase.newton/_src/solvers/vbd/rigid_vbd_kernels.py (1)
68-71: LGTM!The
vec6class definition correctly migrates from importing internal Warp symbols (float32,vector) to using fully-qualified public API paths (wp.types.vector,wp.float32), addressing the deprecation warnings while preserving the same functionality.newton/_src/utils/mesh.py (4)
16-20: LGTM!The new imports are appropriate for the added functionality:
warningsfor non-manifold edge detection,dataclassforMeshEdge, andwarpfor the GPU kernel.
26-51: LGTM!The
MeshEdgedataclass is well-documented with clear explanations of the winding order convention and boundary edge handling.
53-111: LGTM!The
MeshAdjacencyclass correctly implements edge adjacency building with proper non-manifold edge detection. The unusednum_trisparameter is documented as kept for API compatibility with the previouswp.utils.MeshAdjacencyimplementation.
715-754: LGTM!The
solidify_meshwrapper function correctly handles different thickness input types and provides a clean interface. Note that the underlying kernel has the race condition issue flagged above.newton/_src/sim/style3d/builder_style3d.py (2)
33-33: LGTM!The import correctly references Newton's own
MeshAdjacencyimplementation fromnewton._src.utils.mesh, replacing the deprecated internal Warp utility.
602-602: LGTM!The usage change from
wp.utils.MeshAdjacencytoMeshAdjacencycorrectly migrates to Newton's implementation. The API is compatible as both take(indices, num_tris)parameters and provide the sameedgesdictionary structure.newton/examples/diffsim/example_diffsim_ball.py (1)
35-35: LGTM!The import correctly uses the public Newton API (
newton.utils) instead of the internalwarp.rendermodule, aligning with the PR objective to address Warp deprecation warnings. As per coding guidelines, examples must not import fromnewton._src.newton/examples/diffsim/example_diffsim_spring_cage.py (2)
33-33: LGTM!Import correctly updated to use the public Newton API.
268-268: LGTM!Usage updated to call
bourke_color_mapdirectly, consistent with the new import fromnewton.utils.newton/examples/diffsim/example_diffsim_drone.py (2)
40-40: LGTM!Import correctly updated to use the public Newton API.
786-786: LGTM!Usage updated to call
bourke_color_mapdirectly with the same arguments, maintaining the color inversion logic for rollout visualization.newton/utils.py (3)
33-42: LGTM!New mesh utilities (
MeshAdjacency,MeshEdge,solidify_mesh) correctly exposed via the public API. This follows the project convention of re-exporting internal implementations through the public surface.
45-56: LGTM!
__all__exports updated correctly using the incremental pattern. Based on learnings, the Newton project prefers this__all__ += [...]pattern to group exports with their related imports.
66-69: LGTM!Render utilities correctly exported via
__all__, makingbourke_color_mapandcopy_rgb_frame_uint8part of the public API.newton/_src/utils/render.py (2)
1-18: LGTM!License header and imports are correct.
63-93: LGTM!The kernel correctly implements vertical flip for OpenGL-to-standard image coordinate conversion. The pixel indexing logic and the documented launch dimensions
(width, height)are correct.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
|
|
95adf44 to
d4d50bb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
newton/_src/sim/builder.py (1)
1780-1788: Consider fallback for private Warp API dependency, or document the risk.The code hard-binds to
wp._src.context.runtime.core.wp_builtin_mul_transformf_transformffor performance optimization (avoiding repeated overload resolution). While this pattern is already used elsewhere in Newton for graph coloring without fallbacks, intentional reliance on private APIs in nightly builds carries risk if Warp refactors.Either add a defensive fallback using the public
wp.transform_multiply()API, or explicitly document why this private API binding is acceptable (e.g., the optimization necessity and acceptance of nightly-build breakage risk). If a fallback is added, note that the proposeda * boperator may not work—usewp.transform_multiply(a, b)instead.
♻️ Duplicate comments (3)
newton/_src/utils/render.py (1)
21-60: Division by zero whenlow == high.When
low == high,dv = 0and subsequent divisions bydv(e.g.,4.0 * (v - low) / dv) will raiseZeroDivisionError. Add a guard clause to return a default color whendv == 0.🐛 Proposed fix
if v > high: v = high dv = high - low + + if dv == 0.0: + return c if v < (low + 0.25 * dv):newton/_src/utils/mesh.py (1)
652-686: Race condition on shared vertex writes.Multiple triangles sharing the same vertex will have different threads writing to
out_vertices[i*2]with different normal directions (computed per-face). The final vertex position is non-deterministic.Consider either:
- Pre-computing per-vertex averaged normals in a separate pass
- Duplicating vertices per-face (changing output to
num_triangles * 6vertices)newton/utils.py (1)
61-64: Remove unused# noqa: E402directive.Ruff reports this directive is unused. The import is not actually after non-import code relative to the module structure.
🐛 Proposed fix
-from ._src.utils.render import ( # noqa: E402 +from ._src.utils.render import ( bourke_color_map, copy_rgb_frame_uint8, )
🧹 Nitpick comments (2)
newton/_src/utils/mesh.py (1)
65-79: Consider removing unusednum_trisparameter.The
num_trisparameter is documented as "kept for API compatibility" but is never used. If this is intentional for backward compatibility with existing callers, consider adding a# noqa: ARG002comment to silence the linter warning. Otherwise, removing it would simplify the API.newton/_src/sim/builder.py (1)
5481-5494: Add regression test for MeshAdjacency edge extraction to validate consistency.The edge tuple ordering
(o0, o1, v0, v1)is clearly documented in theMeshEdgedocstring and correctly extracted in builder.py. However, there are no tests validating that edge adjacency is correctly computed for known mesh configurations (e.g., simple quad mesh, non-manifold cases). Add a test that constructs a known manifold mesh and assertsedge_indicesmatches an expected frozen list—this catches silent behavioral changes if the edge iteration or canonical ordering logic shifts.
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
uv.lockis excluded by!**/*.lock
📒 Files selected for processing (13)
newton/_src/sim/builder.pynewton/_src/sim/style3d/builder_style3d.pynewton/_src/utils/mesh.pynewton/_src/utils/render.pynewton/_src/viewer/viewer.pynewton/_src/viewer/viewer_gl.pynewton/examples/diffsim/example_diffsim_ball.pynewton/examples/diffsim/example_diffsim_cloth.pynewton/examples/diffsim/example_diffsim_drone.pynewton/examples/diffsim/example_diffsim_soft_body.pynewton/examples/diffsim/example_diffsim_spring_cage.pynewton/utils.pypyproject.toml
🚧 Files skipped from review as they are similar to previous changes (5)
- newton/examples/diffsim/example_diffsim_drone.py
- pyproject.toml
- newton/_src/viewer/viewer_gl.py
- newton/examples/diffsim/example_diffsim_soft_body.py
- newton/examples/diffsim/example_diffsim_cloth.py
🧰 Additional context used
📓 Path-based instructions (5)
newton/examples/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
newton/examples/**/*.py: Examples must not import fromnewton._src, only from the public Newton API
Examples must follow the format with anExampleclass and must be registered inREADME.mdwith auv runcommand and screenshot
Examples must implement atest_final()method that verifies the simulation state is valid after the example has run
Examples may optionally implement atest_post_step()method that is evaluated after everystep()call
Files:
newton/examples/diffsim/example_diffsim_spring_cage.pynewton/examples/diffsim/example_diffsim_ball.py
newton/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
Any user-facing class/function/object added under
_srcmust be exposed via the public Newton API through re-exports
Files:
newton/examples/diffsim/example_diffsim_spring_cage.pynewton/examples/diffsim/example_diffsim_ball.pynewton/_src/utils/mesh.pynewton/_src/utils/render.pynewton/_src/sim/style3d/builder_style3d.pynewton/_src/viewer/viewer.pynewton/_src/sim/builder.pynewton/utils.py
**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
**/*.py: Use prefix-first naming for classes:ActuatorPD,ActuatorPID(notPDActuator,PIDActuator)
Use prefix-first naming for methods:add_shape_sphere()(notadd_sphere_shape())
Method names must usesnake_case
Prefer nested classes when self-contained: if a helper type or enum is only meaningful inside one parent class and doesn't need a public identity, define it as a nested class instead of a top-level class/module
Follow PEP 8 for Python code
Use Google-style docstrings with clear, concise explanations of what functions do, their parameters, and return values
Files:
newton/examples/diffsim/example_diffsim_spring_cage.pynewton/examples/diffsim/example_diffsim_ball.pynewton/_src/utils/mesh.pynewton/_src/utils/render.pynewton/_src/sim/style3d/builder_style3d.pynewton/_src/viewer/viewer.pynewton/_src/sim/builder.pynewton/utils.py
**/*
📄 CodeRabbit inference engine (AGENTS.md)
CLI arguments must use
kebab-case(e.g.,--use-cuda-graph, not--use_cuda_graph)
Files:
newton/examples/diffsim/example_diffsim_spring_cage.pynewton/examples/diffsim/example_diffsim_ball.pynewton/_src/utils/mesh.pynewton/_src/utils/render.pynewton/_src/sim/style3d/builder_style3d.pynewton/_src/viewer/viewer.pynewton/_src/sim/builder.pynewton/utils.py
newton/_src/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
The
newton/_src/directory is internal library implementation only and must not be imported by user code (examples, documentation, or external users)
Files:
newton/_src/utils/mesh.pynewton/_src/utils/render.pynewton/_src/sim/style3d/builder_style3d.pynewton/_src/viewer/viewer.pynewton/_src/sim/builder.py
🧠 Learnings (17)
📓 Common learnings
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/_src/solvers/featherstone/kernels.py:75-75
Timestamp: 2025-08-12T18:04:06.577Z
Learning: The Newton physics framework requires nightly Warp builds, which means compatibility concerns with older stable Warp versions (like missing functions such as wp.spatial_adjoint) are not relevant for this project.
Learnt from: shi-eric
Repo: newton-physics/newton PR: 521
File: newton/examples/example_cloth_hanging.py:36-36
Timestamp: 2025-08-12T05:17:34.423Z
Learning: The Newton migration guide (docs/migration.rst) is specifically for documenting how to migrate existing warp.sim functionality to Newton equivalents. New Newton-only features that didn't exist in warp.sim do not need migration documentation.
Learnt from: shi-eric
Repo: newton-physics/newton PR: 461
File: asv/benchmarks/envs/example_humanoid.py:40-41
Timestamp: 2025-07-23T14:36:42.182Z
Learning: In Warp benchmarks, explicit wp.init() calls are not needed in most circumstances since the first Warp API call that requires initialization will automatically call wp.init(). Explicit wp.init() in setup() methods is helpful when the ASV benchmark is measuring a Warp API call, as wp.init() has non-trivial overhead that should be excluded from the benchmark timing.
📚 Learning: 2025-08-12T05:17:34.423Z
Learnt from: shi-eric
Repo: newton-physics/newton PR: 521
File: newton/examples/example_cloth_hanging.py:36-36
Timestamp: 2025-08-12T05:17:34.423Z
Learning: The Newton migration guide (docs/migration.rst) is specifically for documenting how to migrate existing warp.sim functionality to Newton equivalents. New Newton-only features that didn't exist in warp.sim do not need migration documentation.
Applied to files:
newton/examples/diffsim/example_diffsim_spring_cage.pynewton/_src/sim/builder.py
📚 Learning: 2025-08-12T18:04:06.577Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/_src/solvers/featherstone/kernels.py:75-75
Timestamp: 2025-08-12T18:04:06.577Z
Learning: The Newton physics framework requires nightly Warp builds, which means compatibility concerns with older stable Warp versions (like missing functions such as wp.spatial_adjoint) are not relevant for this project.
Applied to files:
newton/examples/diffsim/example_diffsim_spring_cage.pynewton/_src/sim/builder.py
📚 Learning: 2025-09-22T21:08:31.901Z
Learnt from: dylanturpin
Repo: newton-physics/newton PR: 806
File: newton/examples/ik/example_ik_franka.py:121-123
Timestamp: 2025-09-22T21:08:31.901Z
Learning: In the newton physics framework, when creating warp arrays for IK solver joint variables using wp.array(self.model.joint_q, shape=(1, coord_count)), the resulting array acts as a reference/pointer to the original model's joint coordinates, so updates from the IK solver automatically reflect in the model's joint_q buffer used for rendering, despite the general warp documentation suggesting copies are made by default.
Applied to files:
newton/examples/diffsim/example_diffsim_spring_cage.py
📚 Learning: 2025-12-12T08:45:43.428Z
Learnt from: nvtw
Repo: newton-physics/newton PR: 1221
File: newton/examples/example_sdf.py:277-287
Timestamp: 2025-12-12T08:45:43.428Z
Learning: In Newtown (Newton) example code, specifically files under newton/examples, computing contacts once per frame and reusing them across all substeps is an intentional design choice, not a bug. Reviewers should verify that contacts are computed before the substep loop and reused for every substep within the same frame. This pattern reduces redundant work and preserves frame-consistency; do not flag as a regression unless the behavior is changed for correctness or performance reasons.
Applied to files:
newton/examples/diffsim/example_diffsim_spring_cage.pynewton/examples/diffsim/example_diffsim_ball.py
📚 Learning: 2026-01-13T03:11:40.556Z
Learnt from: jumyungc
Repo: newton-physics/newton PR: 1333
File: newton/_src/sim/builder.py:0-0
Timestamp: 2026-01-13T03:11:40.556Z
Learning: Ensure all VBD damping semantics follow Rayleigh-style damping and are unitless. This convention, demonstrated in SolverVBD, should be applied consistently across all VBD-related constraints in the codebase. In newton/_src/sim/builder.py, validate that any damping terms use the same normalization and are treated as dimensionless; add comments and unit tests to enforce consistency across VBD components.
Applied to files:
newton/examples/diffsim/example_diffsim_spring_cage.pynewton/examples/diffsim/example_diffsim_ball.pynewton/_src/utils/mesh.pynewton/_src/utils/render.pynewton/_src/sim/style3d/builder_style3d.pynewton/_src/viewer/viewer.pynewton/_src/sim/builder.pynewton/utils.py
📚 Learning: 2026-01-13T07:40:13.635Z
Learnt from: CR
Repo: newton-physics/newton PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-13T07:40:13.635Z
Learning: Applies to newton/examples/**/*.py : Examples must not import from `newton._src`, only from the public Newton API
Applied to files:
newton/examples/diffsim/example_diffsim_ball.pynewton/utils.py
📚 Learning: 2026-01-13T07:40:13.635Z
Learnt from: CR
Repo: newton-physics/newton PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-13T07:40:13.635Z
Learning: Applies to newton/**/*.py : Any user-facing class/function/object added under `_src` must be exposed via the public Newton API through re-exports
Applied to files:
newton/_src/utils/mesh.pynewton/_src/viewer/viewer.pynewton/utils.py
📚 Learning: 2025-09-26T05:58:21.013Z
Learnt from: WenchaoHuang
Repo: newton-physics/newton PR: 835
File: newton/_src/solvers/style3d/collision/collision.py:49-53
Timestamp: 2025-09-26T05:58:21.013Z
Learning: In newton/_src/solvers/style3d/collision/collision.py, the broad_phase buffers (broad_phase_ee, broad_phase_ef, broad_phase_vf) created with wp.array() don't need zero-initialization because they follow a write-first-read-later pattern: BVH query kernels in frame_begin() populate these buffers completely (write-only operations), and collision kernels only read from them afterward in accumulate_contact_force(), ensuring no undefined reads occur.
Applied to files:
newton/_src/utils/mesh.py
📚 Learning: 2025-12-12T17:45:26.847Z
Learnt from: vastsoun
Repo: newton-physics/newton PR: 1019
File: newton/_src/solvers/kamino/geometry/primitives.py:0-0
Timestamp: 2025-12-12T17:45:26.847Z
Learning: In newton/_src/solvers/kamino/geometry/primitives.py, the narrow-phase kernel `_primitive_narrowphase` does not need to handle symmetric shape-pair orderings (e.g., both SPHERE-BOX and BOX-SPHERE) because `kamino.core.builder.ModelBuilder` and `kamino.geometry.primitive.broadphase` guarantee that explicit candidate geometry pairs are always defined with GIDs in ascending order.
Applied to files:
newton/_src/utils/mesh.py
📚 Learning: 2025-09-17T21:34:05.267Z
Learnt from: gdaviet
Repo: newton-physics/newton PR: 750
File: newton/examples/mpm/example_mpm_granular.py:44-47
Timestamp: 2025-09-17T21:34:05.267Z
Learning: wp.Mesh (Warp mesh objects) expose triangle indices through the `indices` attribute, not `triangles`. The correct usage is `wp.Mesh(...).indices`, not `wp.Mesh(...).triangles`.
Applied to files:
newton/_src/utils/mesh.pynewton/_src/sim/style3d/builder_style3d.pynewton/_src/sim/builder.py
📚 Learning: 2025-08-12T17:51:37.474Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/geometry.py:16-22
Timestamp: 2025-08-12T17:51:37.474Z
Learning: In the Newton public API refactor, common geometry symbols like ParticleFlags and ShapeFlags are now exposed at the top level in newton/__init__.py rather than through newton.geometry. The newton/geometry.py module is intentionally focused only on broad-phase collision detection classes (BroadPhaseAllPairs, BroadPhaseExplicit, BroadPhaseSAP).
Applied to files:
newton/_src/viewer/viewer.pynewton/utils.py
📚 Learning: 2026-01-12T10:11:39.312Z
Learnt from: nvtw
Repo: newton-physics/newton PR: 1314
File: newton/_src/sim/builder.py:6061-6091
Timestamp: 2026-01-12T10:11:39.312Z
Learning: In finalize() validation logic (e.g., newton/_src/sim/builder.py and similar files), keep the validation lightweight. Do not add union-find/connected-components validation for loop joints. The current behavior—allowing non-articulated joints when the child is in any articulation—is acceptable. Avoid overengineering here.
Applied to files:
newton/_src/sim/builder.py
📚 Learning: 2026-01-13T03:11:40.555Z
Learnt from: jumyungc
Repo: newton-physics/newton PR: 1333
File: newton/_src/sim/builder.py:0-0
Timestamp: 2026-01-13T03:11:40.555Z
Learning: In newton/_src/sim/builder.py, follow VBD conventions: treat radians as dimensionless. Prefer wording 'torque per radian' instead of writing 'N·m/rad' in any docs, strings, or generated text within this file. Ensure consistent usage in docstrings, comments, and documentation strings associated with this module.
Applied to files:
newton/_src/sim/builder.py
📚 Learning: 2026-01-13T07:40:13.635Z
Learnt from: CR
Repo: newton-physics/newton PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-13T07:40:13.635Z
Learning: Applies to newton/_src/**/*.py : The `newton/_src/` directory is internal library implementation only and must not be imported by user code (examples, documentation, or external users)
Applied to files:
newton/utils.py
📚 Learning: 2025-08-14T17:38:36.106Z
Learnt from: nvlukasz
Repo: newton-physics/newton PR: 519
File: newton/__init__.py:25-29
Timestamp: 2025-08-14T17:38:36.106Z
Learning: The Newton project prefers incremental __all__ building using __all__ += [...] pattern to group exports with their related imports, rather than a single consolidated __all__ at the end of the file.
Applied to files:
newton/utils.py
📚 Learning: 2025-11-07T01:42:36.906Z
Learnt from: daniela-hase
Repo: newton-physics/newton PR: 1044
File: newton/_src/sensors/tiled_camera_sensor.py:224-256
Timestamp: 2025-11-07T01:42:36.906Z
Learning: In newton/_src/sensors/tiled_camera_sensor.py, the `# noqa: PLC0415` directives on the local PIL imports (lines 224 and 256 in save_color_image and save_depth_image methods) should be kept because they are required by the pre-commit configuration. The local imports are intentional for optional dependency handling.
Applied to files:
newton/utils.py
🧬 Code graph analysis (6)
newton/examples/diffsim/example_diffsim_spring_cage.py (1)
newton/_src/utils/render.py (1)
bourke_color_map(21-60)
newton/examples/diffsim/example_diffsim_ball.py (1)
newton/_src/utils/render.py (1)
bourke_color_map(21-60)
newton/_src/sim/style3d/builder_style3d.py (1)
newton/_src/utils/mesh.py (1)
MeshAdjacency(53-111)
newton/_src/viewer/viewer.py (1)
newton/_src/utils/mesh.py (1)
solidify_mesh(715-754)
newton/_src/sim/builder.py (1)
newton/_src/utils/mesh.py (1)
MeshAdjacency(53-111)
newton/utils.py (2)
newton/_src/utils/mesh.py (3)
MeshAdjacency(53-111)MeshEdge(27-50)solidify_mesh(715-754)newton/_src/utils/render.py (2)
bourke_color_map(21-60)copy_rgb_frame_uint8(64-93)
🪛 Ruff (0.14.11)
newton/_src/utils/mesh.py
65-65: Unused method argument: num_tris
(ARG002)
newton/utils.py
61-61: Unused noqa directive (non-enabled: E402)
Remove unused noqa directive
(RUF100)
🔇 Additional comments (14)
newton/_src/utils/render.py (1)
63-93: LGTM!The kernel correctly implements the vertical flip for OpenGL-to-standard image coordinate conversion. The documentation clearly explains the expected launch dimensions and purpose.
newton/_src/utils/mesh.py (2)
26-51: LGTM!Well-documented dataclass with clear field descriptions for edge adjacency information.
715-754: Wrapper logic is sound, pending kernel fix.The function correctly handles different thickness input types and properly allocates output arrays. The implementation will work correctly once the race condition in the kernel is addressed.
newton/utils.py (2)
32-56: LGTM!The new mesh utilities are properly exposed through the public API, following the incremental
__all__ += [...]pattern used throughout the codebase. Based on learnings, this pattern groups exports with their related imports.
66-69: LGTM!Render utilities correctly added to the public API exports.
newton/_src/viewer/viewer.py (2)
26-36: LGTM!Moving
solidify_meshto a module-level import is cleaner and consistent with the other mesh utilities already imported fromnewton.utils.
619-624: Usage is correct.The
solidify_meshcall correctly handles the non-solid mesh case. Note that the race condition issue insolidify_mesh_kernel(flagged innewton/_src/utils/mesh.py) would affect the output here.newton/examples/diffsim/example_diffsim_ball.py (2)
35-35: LGTM!Correctly imports
bourke_color_mapfrom the public Newton API (newton.utils) instead ofwarp.render, which aligns with the PR objective of addressing Warp deprecation warnings. As per coding guidelines, examples must not import fromnewton._src.
205-211: LGTM!The
bourke_color_mapusage is correct with a well-defined range[0.0, 7.0]that won't trigger the division-by-zero edge case.newton/_src/sim/style3d/builder_style3d.py (2)
33-33: LGTM!The import correctly references Newton's internal
MeshAdjacencyutility, which replaces the deprecatedwp.utils.MeshAdjacency. Since this is an internal_srcfile, importing from...utils.meshis appropriate.
602-607: No issues found. TheMeshEdgeclass correctly exposes all required attributes (v0,v1,o0,o1,f0,f1) with the expected names, maintaining full API compatibility with the code usage inbuilder_style3d.py.newton/examples/diffsim/example_diffsim_spring_cage.py (2)
33-33: LGTM!The import correctly uses the public Newton API (
newton.utils) instead of the deprecatedwp.rendermodule. This follows the coding guidelines requiring examples to import only from the public Newton API.
268-269: LGTM!Direct drop-in replacement of
wp.render.bourke_color_mapwith Newton's utility. The function signature and return type are identical.newton/_src/sim/builder.py (1)
59-61: Good swap: prefer NewtonMeshAdjacencyover Warp utils to avoid deprecation noise.
This keeps adjacency logic in-repo and avoids relying on Warp’s (now noisy) utility surface.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
d4d50bb to
8022873
Compare
|
pre-commit.ci run |
|
pre-commit.ci run |
1 similar comment
|
pre-commit.ci run |
8022873 to
da2038a
Compare
eric-heiden
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
55a2ceb
Following the release of Warp v1.11.0, deprecation warnings were added for symbols meant to be internal. This MR addresses most of these instances but still reference a few internal symbols through the
_srcnamespace, that would eventually need to be addressed.This depends on google-deepmind/mujoco_warp#981.
Also, for the tests to pass, #1295 also needs to be merged first.
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
Chores
✏️ Tip: You can customize this high-level summary in your review settings.