Title: A DIFFERENTIABLE PHYSICS ENGINE FOR DEEP LEARNING IN ROBOTICS

Abstract: One of the most important fields in robotics is the optimization of controllers. Currently, robots are often treated as a black box in this optimization process, which is the reason why derivative-free optimization methods such as evolutionary algorithms or reinforcement learning are omnipresent. When gradient-based methods are used, models are kept small or rely on finite difference approximations for the Jacobian. This method quickly grows expensive with increasing numbers of parameters, such as found in deep learning. We propose an implementation of a modern physics engine, which can differentiate control parameters. This engine is implemented for both CPU and GPU. Firstly, this paper shows how such an engine speeds up the optimization process, even for small problems. Furthermore, it explains why this is an alternative approach to deep Q-learning, for using deep learning in robotics. Finally, we argue that this is a big step for deep learning in robotics, as it opens up new possibilities to optimize robots, both in hardware and software.

1. INTRODUCTION:

To solve tasks efficiently, robots require an optimization of their control system. This optimization process can be done in automated testbeds (Degrave et al., 2015) , but typically these controllers are optimized in simulation. Standard methods to optimize these controllers include particle swarms, reinforcement learning, genetic algorithms and evolutionary strategies. These are all derivative-free methods.

A recently popular alternative approach is to use deep Q-learning, a reinforcement learning algorithm. This method requires a lot of evaluations in order to train the many parameters (Levine et al., 2016) . However, deep learning experience has taught us that optimizing with a gradient is often faster and more efficient. This fact is especially true when there are a lot of parameters, as is common in deep learning. However, in the optimization processes for control systems, the robot is almost exclusively treated as a non-differentiable black box. The reason for this is that the robot in hardware is not differentiable, nor are current physics engines able to provide the gradient of the robot models. The resulting need for derivative-free optimization approaches limits both the optimization speed and the number of parameters in the controllers.

Recent physics engines, such as mujoco (Todorov et al., 2012) , can derive gradients through the model of a robot but rely on a finite difference method to approximate the gradient. Evaluating finite difference approximations, however, requires the same number of model evaluations as the number of states with respect to which is differentiated. Additionally, the gradient is an estimation.

In this paper, we suggest an alternative approach, by introducing a differentiable physics engine with analytical gradients. This idea is not novel. It has been done before with spring-damper models in 2D and 3D (Hermans et al., 2014) . This technique is also similar to adjoint optimization, a method widely used in various applications such as thermodynamics (Jarny et al., 1991) and fluid dynamics (Iollo et al., 2001) . However, modern engines to model robotics are not based on springdamper systems. The most commonly used ones are 3D rigid body engines, which rely on impulsebased velocity stepping methods (Erez et al., 2015) . In this paper, we test whether these engines are also differentiable and whether this gradient is computationally tractable. We will show how this method does speed up the optimization process tremendously, and give some examples where we optimize deep learned neural network controllers with millions of parameters.

2. A 3D RIGID BODY ENGINE:

The goal is to implement a modern 3D Rigid body engine, in which parameters can be differentiated with respect to the fitness a robot achieves in a simulation, such that these parameters can be optimized with methods based on gradient descent.

The most frequently used simulation tools for model-based robotics, such as PhysX, Bullet, Havok and ODE, go back to MathEngine (Erez et al., 2015) . These tools are all 3D rigid body engines, where bodies have 6 degrees of freedom, and the relations between them are defined as constraints. These bodies exert impulses on each other, but their positions are constrained, e.g. to prevent the bodies from penetrating each other. The velocities, positions and constraints of the rigid bodies define a linear complementarity problem (LCP) (Chappuis, 2013) , which is then solved using a Gauss-Seidel projection (GSP) method (Jourdan et al., 1998) . The solution of this problem are the new velocities of the bodies, which are then integrated by semi-implicit Euler integration to get the new positions (Stewart and Trinkle, 2000) . This system is not always numerically stable. Therefore the constraints are usually softened (Catto, 2009) .

The recent growth of automatic differentiation libraries, such as Theano (Al-Rfou et al., 2016) , Caffe (Jia et al., 2014) and Tensorflow (Abadi et al., 2015) , has allowed for efficient differentiation of remarkably complex functions before (Degrave et al., 2016) . Therefore, we implemented such a physics engine as a mathematical expression in Theano, a software library which does automatic evaluation and differentiation of expressions with a focus on deep learning. The resulting computational graph to evaluate this expression is then compiled for both CPU and GPU. To be able to compile for GPU however, we had to limit our implementation to a restricted set of elementary operations. The range of implementable functions is therefore severely capped. However, since the analytic gradient is determined automatically, the complexity of correctly implementing the differentiation is removed entirely.

One of these limitations with this restricted set of operations, is the limited support for conditionals. Therefore we needed to implement our physics engine without branching, as this is not yet available in Theano for GPU. Therefore some sacrifices had to be made. For instance, our system only allows for contact constraints between different spheres or between spheres and the ground plane. Collision detection algorithms for cubes typically have a lot of branching (Mirtich, 1998) . However, this sphere based approach can in principle be extended to any other shape (Hubbard, 1996) . On the other hand, we did implement a rather accurate model of servo motors, with gain, maximal torque, and maximal velocity parameters.

Another design choice was to use rotation matrices rather than the more common quaternions for representing rotations. Consequently, the states of the bodies are larger, but the operations required are matrix multiplications. This design reduced the complexity of the graph. However, cumulative operations on a rotation matrix might move the rotation matrix away from orthogonality. To correct for this, we renormalize our matrix with the update equation (Premerlani and Bizard, 2009) :

A = 3A -A • (A • A) 2 (1)

where A is the renormalized version of the rotation matrix A. '•' denotes the elementwise multiplication, and '•' the matrix multiplication.

These design decisions are the most important aspects of difference with the frequently used simulation tools. In the following section, we will evaluate our physics simulator on some different problems. We take a look at the speed of computation and the number of evaluations required before the parameters of are optimized.

2.1. THROWING A BALL:

To test our engine, we implemented the model of a giant soccer ball in the physics engine, as shown in Fig. 2a . The ball has a 1 m diameter, a friction of µ = 1.0 and restitution e = 0.5. The ball starts off at position (0, 0). After 5 s it should be at position (10, 0) with zero velocity v and zero angular velocity ω. We optimized the initial velocity v 0 and angular velocity ω 0 at time t = 0 s until the errors at t = 5 s are less than 0.01 m and 0.01 m/s respectively.

Since the quantity we optimize is only know at the end of the simulation, but we need to optimize the parameters at the beginning of the simulation, we need to backpropagate our error through time (BPTT) (Sutskever, 2013) . This approach is similar to the backpropagation through time method used for optimizing recurrent neural networks (RNN). In our case, every time step in the simulation can be seen as one pass through a neural network, which transforms the inputs from this timestep to inputs for the next time step. For finding the gradient, this RNN is unfolded completely, and the gradient can be obtained by differentiating this unfolded structure. This analytic differentiation is done automatically by the Theano library.

Optimizing the six parameters in v 0 and ω 0 took only 88 iterations with gradient descent and backpropagation through time. Optimizing this problem with CMA-ES (Hansen, 2006) , a state of the art derivative-free optimization method, took 2422 iterations. Even when taking the time to compute the gradient into account, the optimization with gradient descent takes 16.3 s, compared to 59.9 s with CMA-ES. This result shows that gradient-based optimization of kinematic systems can in some cases already outperform gradient-free optimization algorithms from as little as six parameters.

3. POLICY SEARCH:

To evaluate the relevance of our differentiable physics engine, we use a neural network as a general controller for a robot, as shown in Figure 1 . We consider a general robot model in a discrete-time dynamical system x t+1 = f ph (x t , u t ) with a task cost function of l(x t , p), where x t is the state of the system at time t and u t is the input of the system at time t. p provides some freedom in parameterizing the loss. If X t is the trajectory of the state up to time t -1, the goal is to find a policy u t = π(X t ) such that we minimize the loss L π .

EQUATION

In previous research, finding a gradient for this objective has been described as presenting challenges (Mordatch and Todorov, 2014 ). An approximation to tackle these issues has been discussed in Levine and Koltun (2013) .

We implement this equation into an automatic differentiation library, ignoring these challenges in finding the analytic gradient altogether. The automatic differentiation library, Theano in our case, analytically derives this equation and compiles code to evaluate both the equation and its gradient.

We define our controller as a deep neural network g deep with weights W. We do not pass all information X t to this neural network, but only a vector of values s t observed by the modeled sensors s(x t ). We also provide our network with (some of the) task-specific parameters p . Finally, we add a recurrent connection to the controller in the previous timestep h t . Therefore, our policy is the following:

π(X t ) = g deep (s(x t ), h t , p | W) s.t. h t = h deep (s(x t-1 ), h t-1 , p | W) and h 0 = 0 (3)

Notice the similarity between equations 2 and 3. Indeed, the equations for recurrent neural networks (RNN) in equation 3 are very similar to the ones of the loss of a physical model in equation 2. Therefore, we optimize this entire system as an RNN unfolded over time, as illustrated in Figure 4 . The weights W are optimized with stochastic gradient descent. The gradient required for that is the Jacobian dL/dW, which is found with automatic differentiation software.

We have now reduced the problem to a standard deep learning problem. We need to train our network g deep on a sufficient amount of samples x init and for a sufficient amount of sampled tasks p in order to get adequate generalization. Standard RNN regularization approaches could also improve this generalization. We reckon that generalization of g deep to more models f ph , in order to ease the transfer of the controller from the model to the real system, is also possible (Hermans et al., 2014) 

3.1. QUADRUPEDAL ROBOT -COMPUTING SPEED:

To verify the speed of our engine, we also implemented a small quadrupedal robot model, as illustrated in Fig. 2b . This model has a total of 81 sensors, e.g. encoders and an inertial measurement unit (IMU). The servo motors are controlled in a closed loop by a small neural network g deep with a number of parameters, as shown previously in Fig. 4 . The gradient is the Jacobian of L, the total traveled distance of the robot in 10 s , differentiated with respect to all the parameters of the controller W. This Jacobian is found by using BPTT and propagating all 10 s back. The time it takes to compute this traveled distance and the accompanying Jacobian is shown in Table 1 . We include both the computation time with and without the gradient, i.e. both the forward and backward pass and the forward pass alone. This way, the numbers can be compared to other physics engines, as those only calculate without gradient. Our implementation and our model can probably be made more efficient, and evaluating the gradient can probably be made faster a similar factor. When only a single controller is optimized, our engine runs more slowly on GPU than on CPU. To tackle this issue, we implemented batch gradient descent, which is commonly used in complex optimization problems. In this case, by batching our robot models, we achieve significant acceleration on GPU. Although backpropagating the gradient through physics slows down the computations by roughly a factor 10, this factor only barely increases with the number of parameters in our controller.

Combining this with our previous observation that fewer iterations are needed when using gradient descent, our approach can enable the use of gradient descent through physics for highly complex deep neural network controllers with millions of parameters. Also note that by using a batch method, a single GPU can simulate about 864 000 model seconds per day, or 86 400 000 model states. This should be plenty for deep learning. It also means that a single simulation step of a single robot, which includes collision detection, solving the LCP problem, integrating the velocities and backpropagating the gradient through it all, takes about 1 ms on average. Without the backpropagation, this process is only about seven times faster.

3.2. 4 DEGREE OF FREEDOM ROBOT ARM:

As a first test of optimizing robot controllers, we implemented a four degree of freedom robotic arm, as depicted in Fig. 2c . The bottom of the robot has a 2 degrees of freedom actuated universal joint; the elbow has a 2 degree of freedom actuated joint as well. The arm is 1 m long, and has a total mass of 32 kg. The servos have a gain of 30 s -1 , a torque of 30 Nm and a velocity of 45 • s -1 .

For this robot arm, we train controllers for a task with a gradually increasing amount of difficulty.

To be able to train our parameters, we have to use a couple of tricks often used in the training of recurrent neural networks.

• We choose an objective which is evaluated at every time step and then averaged, rather than at specific points of the simulation. This approach vastly increases the number of samples over which the gradient is averaged, which in turn makes the gradient direction more reliable (Sjöberg et al., 1995) .

• The value of the gradient is decreased by a factor α < 1 at every time step. This trick has the effect of a prior. Namely, events further in the past are less important for influencing current events, because intermediate events might diminish their influence altogether. It also improves robustness against exploding gradients (Hermans et al., 2014) .

• We initialize the controller intelligently. We do not want the controller to shake the actuators violently and explore outside the accurate domain of our simulation model. Therefore our controllers are initialized such that they only output zeros at the start of the simulation. The initial policy is the zero policy.

• We constraint the size of the gradient to an L2-norm of 1. This makes sure that gradients close to discontinuities in the fitness landscape do not push the parameter values too far away, such that everything which was learned is forgotten (Sutskever, 2013) .

3.2.1. REACHING A FIXED POINT:

A first simple task, is to have a small neural net controller learn to move the controller to a certain fixed point in space, at coordinates (0.5 m; 0.5 m; 0.5 m). The objective we minimize for this task, is the distance between the end effector and the target point, averaged over the 8 seconds we simulate our model.

We provide the controller with a single sensor input, namely the current distance between the end effector and the target point. Input is not required for this task, as there are solutions for which the motor signals are constant in time. However, this would not necessarily be the optimal approach for minimizing the average distance over time, it only solves the distance at the end of the simulation, but does not minimize the distance during the trajectory to get at the final position.

As a controller, we use a dense neural network with 1 input, 2 hidden layers of 128 units with a rectifier activation function, and 4 outputs with an identity activation function. This controller has 17 284 parameters in total. We disabled the recurrent connections h t .

We use gradient descent with a batch size of 1 robot for optimization, as the problem is not stochastic in nature. The parameters are optimized with Adam's rule (Kingma and Ba, 2014) with a learning rate of 0.001. Every update step with this method takes about 5 seconds on CPU. We find that the controller comes within 4 cm of the target in 100 model evaluations, and within 1 cm in 150 model evaluations, which is small compared to the 1 m arm of the robot. Moreover, the controller does find a more optimal trajectory which takes into account the sensor information.

Solving problems like these in fewer iteration steps than the number of parameters, is unfeasible with derivative free methods (Sjöberg et al., 1995) . Despite that, we did try to optimize the same problem with CMA-ES. After a week of computing and 60 000 model evaluations, CMA-ES did not show any sign of convergence, as it cannot handle the sheer amount of parameters.

3.2.2. REACHING A RANDOM POINT:

As a second task, we sample a random target point in the reachable space of the end effector. We give this point as input v to the controller, and the task is to again minimize the average distance between the end effector and the target point v. Our objective L is this distance averaged over all timesteps.

As a controller, we use a dense neural network comparable to the previous section, but this time with 3 inputs. We used 3 hidden layers with 1024 units each, so the controller has 2 107 396 parameters in total. This is not necessary for this task, but we do it like this to demonstrate the power of this approach. In order to train for this task, we use a batch size of 128 robots, such that every update step takes 58 s on GPU. Each simulation takes 8 s with a simulation step of 0.01 s. Therefore, the gradient on the parameters of the controllers has been averaged over 51 200 timesteps at every update step.

We update the parameters with Adam's rule, where we scale the learning rate with the average error achieved in the previous step.

We find that it takes 576 update steps before the millions of parameters are optimized, such that the end effector of the robot is on average less than 10 cm of target, 2 563 update steps before the error is less than 5 cm.

3.3. A QUADRUPEDAL ROBOT -REVISITED:

Optimizing a gait for a quadrupedal robot is a problem of a different order, something the authors have extensive experience with (Sproewitz et al., 2013; Degrave et al., 2013; 2015) . The problem is way more challenging and allows for a broad range of possible solutions. In nature, we find a wide variety of gaits, from hopping over trotting, walking and galloping. With hand tuning on the robot model shown in Figure 2b , we were able to obtain a trotting motion with an average forward speed of 0.7 m/s. We found it tricky to find a gait where the robot did not end up like an upside down turtle, as 75% of the mass of the robot is located in its torso.

As a controller for our quadrupedal robot, we use a neural network with 2 input signals s t , namely a sine and a cosine signal with a frequency of 1.5 Hz. On top of this, we added 2 hidden layers of 128 units and a rectifier activation function. As output layer, we have a dense layer with 8 units and a linear activation function, which has as input both the input layer and the top layer of the hidden layers. In total, this controller has 17 952 parameters. Since the problem is not stochastic in nature, we use a batch size of 1 robot. We initialize the output layer with zero weights, so the robot starts the optimization in a stand still position.

We optimize these parameters to maximize the average velocity of the spine over the course of 10 s of time in simulation. This way, the gradient used in the update step is effectively an average of the 1 000 time steps after unrolling the recurrent connections. This objective does not take into account energy use, or other metrics typically employed in robotic problems.

In only 500 model evaluations or about 1 hour of optimizing on CPU, the optimization with BPTT comes up with a solution with a speed of 1.17 m/s. This solution is a hopping gait, with a summersault every 3 steps1 , despite limiting the torque of the servos to 4 Nm on this 28.7 kg robot. For more life-like gaits, energy efficiency could be use as a regularization method. Evaluating these improvements are however outside the scope of this paper.

3.3.1. THE INVERTED PENDULUM WITH A CAMERA AS SENSOR:

As a fourth example, we implemented a model of the pendulum-cart system we have in our laboratorium. This pendulum-cart system is used for the classic control task of the underactuated inverted pendulum (Vaccaro, 1995) . In this example however, a camera which is set up in front of the system is the only available information for the controller. It therefore has to observe the system it controls using vision. A frame captured by this camera is shown in Figure 3 .

In order to build this model, we implemented a differentiable camera in our physics engine. This camera uses a ray-tracing approach to find where it needs to sample from the textures, and uses bilinear interpolation to sample from these textures, similar to the one used for the spatial transform layer (Jaderberg et al., 2015) . This interpolation is necessary for making the frame captured by the camera differentiable to the state of the robot with non-zero derivatives.

Figure 3 : A frame captured by the differentiable camera looking at the model of the pendulum-cart system. The resolution used is 288 by 96 pixels. All the textures are made from pictures of the actual system.

We minimize the distance from the end of the pendulum to the desired point and regularize the speed of the pendulum. The memoryless deep controller receives the current image of the camera, in addition to two images from the past such that it can estimate velocity and acceleration. We observe that a controller with 1,065,888 parameters is able to learn to swing up and keep the pendulum stable after only 2420 episodes of 3 model seconds. The complete optimization process took 15 hours. The resulting controller keeps the pendulum stable for more than one minute2 . In order to do this, the controller has learned to interpret the frames it receives from the camera and found a suitable control strategy.

4. DISCUSSION:

Our results show the first prototype of a differentiable physics engine based on similar algorithms as those that are commonly used in modern robotics simulators. When initially addressing the problem, we did not know whether finding the gradient would be computationally tractable, let alone whether evaluating it would be fast enough to be beneficial for optimization. In this paper, we have demonstrated that evaluating the gradient is tractable enough to speed up optimization on problems with as little as six parameters. The speed of this evaluation mainly depends on the complexity of the physics model and only slightly on the number of parameters to optimize. Therefore, our results suggest that this cost is dominated by the gain achieved from the combination of using batch gradient descent and GPU acceleration.

Optimizing the controller of a robot model with gradient-based optimization is equivalent to optimizing an RNN. After all, the gradient passes through each parameter at every time step. The parameter space is therefore very noisy. Consequently, training the parameters of this controller is a highly non-trivial problem, as it corresponds to training the parameters of an RNN. On top of that, exploding and vanishing signals and gradients cause far more challenging problems compared to feed forward networks.

In section 3.2, we already discussed some of the tricks used for optimizing RNNs. Earlier research shows that these methods can be extended to more complicated tasks than the ones discussed here (Hermans et al., 2014; Sutskever, 2013) . Hence, we believe that this approach towards learning controllers for robotics applies to more complex problems than the illustrative examples in this paper.

All of the results in this paper will largely depend on showing how these controllers will work on the physical counterparts of our models. Nonetheless, we would like to conjecture that to a certain extent, this gradient of a model is close to the gradient of the physical system. The gradient of the model is more susceptible to high-frequency noise introduced by modeling the system, than the imaginary gradient of the system itself. Nonetheless, it contains information which might be indicative, even if it is not perfect. We would theorize that using this noisy gradient is still better than optimizing in the blind and that the transferability to real robots can be improved by evaluating the gradients on batches of (slightly) different robots in (slightly) different situations and averaging the results. This technique has already been applied in (Hermans et al., 2014) as a regularization method to avoid bifurcations during online learning. If the previous proves to be correct, our approach can offer an addition or possibly even an alternative to deep Q-learning for deep neural network controllers in robotics.

We can see the use of this extended approach for a broad range of applications in robotics. Not only do we think there are multiple ways where recent advances in deep learning could be applied to robotics more efficiently with a differentiable physics engine, we also see various ways in which this engine could improve existing angles at which robotics are currently approached:

• In this paper, we added memory by introducing recurrent connections in the neural network controller. We reckon that advanced, recurrent connections such as ones with a memory made out of LSTM cells (Hochreiter and Schmidhuber, 1997) can allow for more powerful controllers than the controllers described in this paper.

• Using a differentiable physics engine, we reckon that knowledge of a model can be transferred more efficiently into a forward or backward model in the form of a neural network, similar to methods such as used in Johnson et al. (2016) and Dumoulin et al. (2016) . By differentiating through an exact model and defining a relevant error on this model, it should be possible to transfer knowledge from a forward or backward model in the differentiable physics engine to a forward or backward neural network model. Neural network models trained this way might be more robust than the ones learned from generated trajectories (Christiano et al., 2016) . In turn, this neural model could then be used for faster but approximate evaluation of the model.

• Although we did not address this in this paper, there is no reason why only control parameters could be differentiated. Hardware parameters of the robot have been optimized the same way before (Jarny et al., 1991; Iollo et al., 2001; Hermans et al., 2014) . The authors reckon that the reverse process is also true. A physics engine can provide a strong prior, which can be used for robots to learn (or adjust) their robot models based on their hardware measurements faster than today. You could optimize the model parameters with gradient descent through physics, to have the model better mimic the actual observations.

• Where adversarial networks are already showing their use in generating image models, we believe adversarial robotics training (ART) will create some inventive ways to design and control robots. Like in generative adversarial nets (GAN) (Goodfellow et al., 2014) , where the gradient is pulled through two competing neural networks, the gradient could be pulled through multiple competing robots as well. It would form an interesting approach for swarm robotics, similar to previous results in evolutionary robotics (Sims, 1994; Pfeifer and Bongard, 2006; Cheney et al., 2014) , but possibly faster.

5. CONCLUSION:

In this paper, we show it is possible to build a differentiable physics engine. We implemented a modern engine which can run a 3D rigid body model, using the same algorithm as other engines commonly used to simulate robots, but we can additionally differentiate control parameters with BPTT. Our implementation also runs on GPU, and we show that using GPUs to simulate the physics can speed up the process for large batches of robots. We show that even complex sensors such as cameras, can be implemented and differentiated through, allowing for computer vision to be learned together with a control policy.

We find that these gradients can be computed fast enough for use in applications. We also show that using gradient descent with BPTT speeds up optimization processes often found in robotics, even for rather small problems, due to the reduced number of model evaluations required. We show that this improvement in speed scales to problems with a lot of parameters. We also show that using this engine, finding policies for robot models can be done faster and in a more straightforward way. This method should allow for a new approach to apply deep learning techniques in robotics. The neural networks g deep and h deep with weights W receive sensor signals s t from the sensors on the robot and use these to generate motor signals u t which are used by the physics engine f ph to find the next state of the robot in the physical system. These neural networks also have a memory, implemented with recurrent connections h t . From the state x t of these robots, the loss L can be found. In order to find dL/dW, every block in this chart needs to be differentiable. The contribution of this paper, is to implement a differentiable f ph , which allows us to optimize W to minimize L more efficiently than was possible before.

6. APPENDIX:



6.2. TABLES:

Table 1 : Evaluation of the computing speed of our engine on a robot model controlled by a closed loop controller with a variable number of parameters. We evaluated both on CPU (i7 5930K) and GPU (GTX 1080), both for a single robot optimization and for batches of multiple robots in parallel.

The numbers are the time required in seconds for simulating the quadruped robot(s) for 10 s, with and without updating the controller parameters through gradient descent. The gradient calculated here is the Jacobian of the total traveled distance of the robot in 10 s, differentiated with respect to all the parameters of the controller. For comparison, the model has 102 states. It is built from 17 rigid bodies, each having 6 degrees of freedom. These states are constrained by exactly 100 constraints. 

Seconds:



:

A video is available at https://goo.gl/5ykZZe

https://twitter.com/317070/status/821062814798331905

Figures and Tables:

Figure 2: (a) Illustration of the ball model used in the first task. (b) Illustration of the quadruped robot model with 8 actuated degrees of freedom, 1 in each shoulder, 1 in each elbow. The spine of the robot can collide with the ground, through 4 spheres in the inside of the cuboid. (c) Illustration of the robot arm model with 4 actuated degrees of freedom.

Figure4: Illustration of the dynamic system with the robot and controller, after unrolling over time. The neural networks g deep and h deep with weights W receive sensor signals s t from the sensors on the robot and use these to generate motor signals u t which are used by the physics engine f ph to find the next state of the robot in the physical system. These neural networks also have a memory, implemented with recurrent connections h t . From the state x t of these robots, the loss L can be found. In order to find dL/dW, every block in this chart needs to be differentiable. The contribution of this paper, is to implement a differentiable f ph , which allows us to optimize W to minimize L more efficiently than was possible before.

, but it is outside the scope of this paper. Illustration of how a closed loop neural network controller would be used to actuate a robot. The neural network receives sensor signals from the sensors on the robot and uses these to generate motor signals which are sent to the servo motors. The neural network can also generate a signal which it can use at the next timestep to control the robot.

Table content: <table><tr><td>Next timestep</td></tr><tr><td>Motor signals</td></tr><tr><td>Neural network controller</td></tr><tr><td>Sensor signals</td></tr><tr><td>Previous timestep</td></tr><tr><td>Figure 1:</td></tr></table>

of computing time required to simulate a batch of robots for 10 seconds Milliseconds of computing time required to perform one time step of one robot.

Table content: <table><tr><td/><td colspan="2">with gradient</td><td colspan="2">without gradient</td></tr><tr><td/><td colspan="2">CPU GPU</td><td>CPU</td><td>GPU</td></tr><tr><td>1 robot</td><td>1 296 parameters 8.17 1 147 904 parameters 13.2</td><td>69.6 75.0</td><td>1.06 2.04</td><td>9.69 9.69</td></tr><tr><td>128 robots</td><td>1 296 parameters 263 1 147 904 parameters 311</td><td>128 129</td><td>47.7 50.4</td><td>17.8 18.3</td></tr><tr><td/><td colspan="2">with gradient</td><td colspan="2">without gradient</td></tr><tr><td/><td colspan="2">CPU GPU</td><td>CPU</td><td>GPU</td></tr><tr><td>1 robot</td><td>1 296 parameters 8.17 1 147 904 parameters 13.2</td><td>69.6 75.0</td><td>1.06 2.04</td><td>9.69 9.69</td></tr><tr><td>128 robots</td><td>1 296 parameters 2.05 1 147 904 parameters 2.43</td><td>1.00 1.01</td><td>0.372 0.394</td><td>0.139 0.143</td></tr></table>

Peer review (iclr2017):
A differentiable physics engine is indeed a wonderful thing to have. The key selling point of the proposed software is its speed, however there is no comparison to other physics engines. Besides describing the engine*s speed in rather creative units (e.g. *model seconds per day*), the reader has no idea if this is fast or slow. Todorov*s engine (my simulator of choice) computes a dynamics step and its derivatives wrt both states and controls (using finite-differences) in less than 1ms for a *full humanoid* model (his code is available here mujoco.org/book/programming.html#saDerivative). I think this actually faster than the engine described in this paper, but I can*t be sure. Because this engine is so limited in what it can collide (sphere/sphere and sphere/plane), it would be trivial to build the example models in several other popular engines (e.g. ODE, Bullet and MuJoCo) and simply compare the performance. Until this comparison is done I consider the paper to be incomplete.