Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Google deepmind Mujoco MJWarp Derivative

From Leeroopedia
Knowledge Sources
Domains Physics_Simulation, GPU_Computing, NVIDIA_Warp
Last Updated 2026-02-15 04:00 GMT

Overview

MJWarp Derivative computes analytical derivatives of smooth dynamics with respect to velocities for implicit integration on the GPU.

Description

This module computes the derivative of smooth forces (actuator and passive) with respect to generalized velocities, producing the qDeriv matrix used by the implicit integrator. It evaluates velocity-dependent gains and biases from actuator parameters (affine gain/bias types) and accumulates their contributions into a derivative matrix that modifies the effective mass matrix. The module supports both sparse and dense mass matrix representations and uses tiled operations for the dense case.

Usage

Called by the implicit integrator in forward.py and by the inverse dynamics in inverse.py to compute the velocity-dependent correction to the mass matrix. The deriv_smooth_vel function is the primary entry point.

Code Reference

Source Location

Key Functions

# Primary entry point
def deriv_smooth_vel(m: Model, d: Data, qDeriv: wp.array)

# Internal kernels
@wp.kernel
def _qderiv_actuator_passive_vel(
    actuator_dyntype, actuator_gaintype, actuator_biastype,
    actuator_actadr, actuator_actnum, actuator_gainprm, actuator_biasprm,
    act_in, ctrl_in, vel_out)

# Dense tiled derivative accumulation (via @cache_kernel)
def _qderiv_actuator_dense(nv, ...)

Import

from mujoco.mjx.third_party.mujoco_warp._src.derivative import deriv_smooth_vel

I/O Contract

Inputs

Name Type Required Description
m Model Yes Warp model with actuator gain/bias parameters and dynamics types
d Data Yes Warp simulation data with activations, controls, and actuator moments

Outputs

Name Type Description
qDeriv wp.array Derivative of smooth forces w.r.t. velocities (sparse or dense format)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment