Add Nesterov momentum with O'Donoghue-Candès restarts to PGS solver (~2x speedup)

Benchmark on `2humanoid100.xml` (nefc=1785, nv=654):

```
Convergence at fixed iteration count (mean relative error vs Newton):
  20 iters: 2.98e-03 vs 1.54e-02 (5.2x better)
  40 iters: 8.14e-05 vs 2.60e-03 (32x better)
  80 iters: 1.17e-07 vs 1.77e-04 (1500x better)

Pipeline throughput (tolerance=1e-8, islands disabled):
  Nesterov: 243 steps/s, 46 iters/step
  Baseline: 151 steps/s, 95 iters/step
  Solver speedup: 1.8x, overall step speedup: 1.6x

Pipeline throughput (tolerance=1e-8, islands enabled):
  Nesterov: 306 steps/s, 442 iters/step
  Baseline: 175 steps/s, 966 iters/step
  Solver speedup: 2.1x, overall step speedup: 1.7x
```

PiperOrigin-RevId: 936610759
Change-Id: I2978e8bd545971d9151005623967e5cf0ad125cc
This commit is contained in:
Yuval Tassa
2026-06-23 05:51:42 -07:00
committed by Copybara-Service
parent 5cef2472d5
commit c499f7f2b0
8 changed files with 798 additions and 15 deletions
+12 -2
View File
@@ -2129,8 +2129,13 @@ void mju_n2d(double* res, const mjtNum* vec, int n) {
}
// gather
// gather: res[i] = vec[ind[i]], or copy if ind is NULL
void mju_gather(mjtNum* restrict res, const mjtNum* restrict vec, const int* restrict ind, int n) {
if (!ind) {
mju_copy(res, vec, n);
return;
}
for (int i=0; i < n; i++) {
res[i] = vec[ind[i]];
}
@@ -2146,8 +2151,13 @@ void mju_gatherMasked(mjtNum* restrict res, const mjtNum* restrict vec,
}
// scatter
// scatter: res[ind[i]] = vec[i], or copy if ind is NULL
void mju_scatter(mjtNum* restrict res, const mjtNum* restrict vec, const int* restrict ind, int n) {
if (!ind) {
mju_copy(res, vec, n);
return;
}
for (int i=0; i < n; i++) {
res[ind[i]] = vec[i];
}