Decoupled Environment Gradient for Joint Policy and Simulator Learning
Implementation & benchmark of arXiv:2607.12590 — Environment Parameter Gradient Theorem for Policy-Environment Co-Design in Reinforcement Learning
Source paper: Environment Parameter Gradient Theorem for Policy-Environment Co-Design in Reinforcement Learning arXiv:2607.12590 ⓘ · analyzed Aug 30, 2026
AI-generated research hypothesis, automatically tested. Not peer-reviewed.
Idea description
Augment a neural policy with differentiable environment or data-generation parameters and optimize both using the environment-parameter policy-gradient theorem. The current transition is differentiated with respect to the design parameter, while the continuation value is evaluated under a frozen copy of that parameter; this isolates the local causal effect and avoids repeatedly differentiating through arbitrarily long rollouts. Suitable applications include learnable domain randomization, differentiable augmentation schedules, simulator calibration, and world-model co-design.
Formulas
Mathematical statement
Let an MDP have state s, action a, next state s', environment parameter zeta, transition kernel p_zeta(s'|s,a), cost c_zeta(s,a,s'), policy pi_theta(a|s), and discount gamma in (0,1). Define V_{theta,xi}(s)=E_{pi_theta,p_xi}[sum_{t>=0} gamma^t c_xi(s_t,a_t,s_{t+1}) | s_0=s], where xi is the parameter used in future rollouts. Define Q_{theta,xi}(s,a,zeta)=sum_{s'} p_zeta(s'|s,a)[c_zeta(s,a,s')+gamma V_{theta,xi}(s')]. The environment-gradient theorem states that the derivative of J(theta,zeta)=E_{s_0~rho_0}[V_{theta,zeta}(s_0)] is the discounted state-occupancy expectation of the local derivative of Q: gradient_zeta J = E_{s~d_{theta,zeta},a~pi_theta}[gradient_zeta Q_{theta,xi}(s,a,zeta)] with xi set equal to zeta only after differentiation. Expanding the derivative gives a transition-score term weighted by immediate cost plus continuation value, and a direct derivative of the cost. Here d_{theta,zeta}(s)=sum_{t>=0} gamma^t Pr(s_t=s) is the unnormalized discounted occupancy. The essential property is that gradient_zeta does not differentiate through V_{theta,xi}; xi is held fixed, preventing duplicated or unstable long-horizon derivatives.
Implementation notes
1. Integration point: implement a neural policy pi_theta(a|s) together with a differentiable environment generator p_zeta and cost c_zeta. Start with a small differentiable simulator or learnable augmentation environment, such as a two-dimensional navigation task whose obstacle locations, friction, or observation-noise scale are controlled by zeta. Use zeta as a constrained nn.Parameter and project it into a valid interval after every update. 2. Pseudocode: collect B transitions (s_i,a_i,s'_i,c_i) using the current theta and zeta; estimate a critic Q_hat_theta_xi with target rollouts or temporal-difference learning using a detached copy xi=zeta.detach(); compute the local cost derivative grad_zeta c_zeta and transition score grad_zeta log p_zeta(s'_i|s_i,a_i); form g_zeta as the average of grad_zeta c plus the score multiplied by Q_hat; update theta with the ordinary policy-gradient loss and update zeta with zeta <- projection(zeta-alpha_zeta*g_zeta). Every K steps copy xi <- zeta.detach(). For reparameterizable simulators, replace the score term with the pathwise derivative of the one-step transition while still stopping gradients through future rollout parameters. 3. Computed versus estimated: derivatives of p_zeta and c_zeta are obtained by autodiff when the simulator is differentiable; discounted occupancy, Q, and the expectation are estimated from replay trajectories. If p_zeta is unknown, fit a probabilistic one-step model and use its analytic log-density gradient. 4. First cheap experiment: use a tabular or two-layer MLP policy on a four-state navigation MDP, with zeta controlling slip probability and collision cost. Compare policy-only learning, naive backpropagation through full unrolled episodes, and the decoupled estimator. Sweep horizon H and finite-difference zeta perturbations to measure bias. The quantitative prediction is that the decoupled gradient agrees with finite differences within 10% at short horizons and its error remains approximately constant as H grows, whereas full-rollout differentiation error or variance grows with H. Joint optimization should reduce final cost below policy-only training when the optimum requires changing slip or collision parameters. Also test the predicted stationary condition g_zeta approximately zero and verify that the learned zeta is within 20% of a grid-search optimum in the small MDP.
Verification
Stage 1 · Toy mechanism gate: Passed ✓
Stage 2 · Mechanism transferred to benchmark: Confirmed ✓
Stage 2 · Practical benchmark result: No measurable effect
Methodology: 8 paired seeds, permutation test (p<0.05) against a learning-rate-tuned baseline. How verification works
Stage 1 — Mechanism check agent confidence 9/10
Built an exact two-state differentiable MDP verifier implementing the decoupled local environment-gradient theorem with a frozen continuation value. The mechanism manifested: matched-copy gradients agreed with finite differences to about 1e-11–2e-9, truncated-tail error decayed geometrically (fitted ratio 0.766, below the predicted gamma=0.92 bound), and stale-copy bias was approximately linear in the copy offset (R²=0.9968) while vanishing at zero offset. Environment optimization reduced cost from 8.5405 to 7.56210, matched the grid optimum z=-0.357 within 0.00030, and reached gradient 7.25e-8.
- Agent confidence
- 9/10
- Baseline
- Fixed environment z=0.55: objective cost 8.5405049337
- Finite difference check
- At gamma=0.92, theorem gradient 2.122305001708944 vs finite difference 2.1223050016949685; absolute error 1.40e-11
- Horizon scaling
- Tail-error log-fit ratio 0.7659; predicted contraction upper bound gamma=0.92 and gamma*rho(P)=0.92
- Idea
- Decoupled environment-gradient optimization: final z=-0.3567032, cost 7.5620986168, reduction 0.9784063169; grid optimum z=-0.357, cost 7.5620987236
- Stale copy scaling
- Bias linear fit R²=0.9967964788; bias exactly numerical-zero at xi=z
Limitations: The experiment uses an analytically solved two-state MDP and a fixed tabular policy, not a neural policy, sampled critic, replay trajectories, or a genuinely joint policy/environment learning loop. It does not compare variance or wall-clock performance against full-rollout autodiff, and the transition spectral radius is exactly one, so the observed tail ratio is governed by discounting rather than a strict subunit transition contraction.
How to run: python3 gradient_experiment.py
Stage 2 — Benchmark vs. tuned baseline (arXiv:2607.12590)
No significant difference vs. the tuned baseline (−-0.0%, p=1, wins 0 / 8 paired seeds).
- Benchmark
- Dynamics forecasting
- Model
- rnn_small
- Paired seeds
- 8
- Baseline mean
- 0.0008
- Idea mean
- 0.0008
- Effect (Δ)
- 0 (−-0.0%; negative = idea better)
- Wins
- 0 / 8 paired seeds
- p-value
- 1 (permutation test, 20 000 shuffles)
- Smallest detectable effect
- ±0.0%
- Mechanism
- Confirmed ✓
- Practical effect
- No effect
- Baseline tuning
- swept over 3 configs
Only the registered dynamics track was tested. The prototype used a physics auxiliary objective rather than a full sampled policy-gradient critic/replay implementation, and no wall-clock or gradient-variance comparison against long-horizon rollout differentiation was performed.
How to run: python3 bench_experiment.py
Verdict computed by deterministic test code from paired-seed statistics — not by the language model.
Stage 2 — Benchmark latest Failed ✗
Agent confidence: 10/10
The idea was evaluated on the registered dynamics track with the shared rnn_small model, 8 paired seeds, and equal-budget learning-rate sweeps. Baseline and idea both obtained mean test MSE 0.0007801908141118474, with paired delta 0.0 and permutation p-value 1.0; therefore the harness verdict is no measurable effect. The frozen-continuation mechanism signature was confirmed with mean local-to-two-step gradient ratio 0.10152785945683718, but it did not produce a task-metric win.
- Baseline
- Best cfg lr=0.006, lambda_phys=0.0; mean=0.0007801908141118474, std=0.000154764005468824, n=8.
- Comparison
- delta_mean=0.0, idea_wins=0, n_pairs=8, p_value=1.0, verdict=no measurable effect.
- Idea
- Best cfg lr=0.006, lambda_phys=0.1; mean=0.0007801908141118474, std=0.000154764005468824, n=8.
- Mechanism signature
- confirmed=true; observed_mean_local_to_two_step_grad_ratio=0.10152785945683718
Benchmark result
No significant difference vs. the tuned baseline (−-0.0%, p=1, wins 0 / 8 paired seeds).
- Benchmark
- Dynamics forecasting
- Model
- rnn_small
- Paired seeds
- 8
- Baseline mean
- 0.0008
- Idea mean
- 0.0008
- Effect (Δ)
- 0 (−-0.0%; negative = idea better)
- Wins
- 0 / 8 paired seeds
- p-value
- 1 (permutation test, 20 000 shuffles)
- Smallest detectable effect
- ±0.0%
- Mechanism
- Confirmed ✓
- Practical effect
- No effect
- Baseline tuning
- swept over 3 configs
Only the registered dynamics track was tested. The prototype used a physics auxiliary objective rather than a full sampled policy-gradient critic/replay implementation, and no wall-clock or gradient-variance comparison against long-horizon rollout differentiation was performed.
How to run: python3 bench_experiment.py
Artifacts
- bench_experiment.py 6.5 KB View Raw
- bench_report.json 6.5 KB View Raw
- gradient_experiment.py 7.1 KB View Raw
- optimization_results.json 1.8 KB View Raw
- report.md 2.0 KB View
- report_bench_2026-08-31T012832.md 6.3 KB View
- results.json 3.9 KB View Raw