When one policy has to serve many tasks, the tasks often pull its shared parameters in opposite directions. Improving one task then hurts another. In neural networks this is called gradient interference, and the standard remedies change the update vector: they project away the part of one task's gradient that opposes another, or pick a compromise direction. Programmatic policies are a different case. These are policies written as small programs in a domain-specific language (DSL), a restricted set of control primitives, and people want them because they can be read, edited and formally verified. A program can respond to disagreement in a way a network cannot: it can add an explicit if statement so each side of the conflict gets its own code. We propose to treat measured gradient conflict as a structural signal rather than as a nuisance to project away. If tasks disagree persistently about the constants inside one part of a program, that part should be duplicated under a guard. If they agree, the code should stay shared.
The opportunity is that two open problems answer each other. Programmatic reinforcement learning has no principled way to decide where a multi-task program should branch, and discrete search over branching structure grows exponentially with program size. Gradient-conflict methods are defined only for smooth parameter spaces, and they cost one backward pass per task. Smoothed random-perturbation estimates of each task's gradient on a program's constants fix both. They work through hard if-then-else statements, they give all K task gradients from one shared set of rollouts, and their pattern of conflict across the program's syntax tree says where to cut.
Core Claim
Our claim is that conflict localized to subtrees of a program is a good proposal distribution for structural edits. We expect a search loop that tunes constants by perturbation gradients and splits or merges subtrees according to per-task conflict to reach higher multi-task return with fewer environment episodes than three alternatives: discrete search over the summed reward, gradient surgery inside a relaxed program, and one separate program per task. We also expect it to keep more code shared, and that shared code should transfer better to held-out tasks.
Concretely, let $\theta_s$ be the numeric constants inside subtree $s$ of the program: gains, offsets and guard thresholds. Let $R_k$ be the return on task $k$. We estimate a smoothed gradient for every task from the same Gaussian perturbations $\epsilon_1,\dots,\epsilon_N$, with noise scale $\sigma$:
$$\hat g_k = \frac{1}{2\sigma N}\sum_{n=1}^{N}\big(R_k(\theta+\sigma\epsilon_n)-R_k(\theta-\sigma\epsilon_n)\big)\,\epsilon_n .$$
This estimate exists even when $R_k$ is piecewise constant in a threshold, because it is the gradient of the Gaussian-smoothed return. Restricting $\hat g_k$ to the coordinates of subtree $s$ gives $\hat g_{k,s}$. From these we define the conflict of subtree $s$ as the CAGrad-style worst-case improvement, normalized:
$$C_s = \min_{w\in\Delta^K}\Big\|\sum_k w_k \hat g_{k,s}\Big\| \Big/ \max_k \|\hat g_{k,s}\| .$$
Here $\Delta^K$ is the set of nonnegative task weights summing to one. When $C_s$ is near zero, some convex combination of task gradients cancels, so the subtree sits at a multi-task compromise point that no shared update can escape. A split is proposed when $C_s$ stays low over a window of iterations while the individual task gradients stay large. Large gradients rule out convergence, where every gradient is small anyway.
Relation to Prior Work
The file contains no paper that combines programmatic policies with multi-task gradient interference. The nearest work falls into three groups.
The first group supplies the program-search machinery and motivates the gap. Programmatic Reinforcement Learning without Oracles (π-PRL) relaxes grammar choices into softmax weights and if statements into sigmoids, then trains with TRPO on single tasks. Differentiable Synthesis of Program Architectures (dPads) does the same for sequence classification and reports a bias toward paths that are quick to optimize. Both leave a known gap: the relaxed program can collapse when it is converted back to a discrete one. Our method never relaxes structure. Structure changes only through discrete splits and merges, so this gap does not apply.
Reclaiming the Source of Programmatic Policies shows that plain hill climbing over syntax-tree mutations beats learned latent spaces on every Karel task (0.84 vs. 0.5 on DoorKey). This constrains our design: we search directly over source code, not over a latent space. Language Models Speed Up Local Search for Finding Programmatic Policies shows that unguided local search wastes many episodes, which motivates guiding the mutations.
The second group consists of teacher-guided methods. Programmatically Interpretable Reinforcement Learning and Imitation-Projected Programmatic Reinforcement Learning (PROPEL) distill a neural policy, or a neural correction term added to the program, back into a program. In multi-task settings the neural teacher itself suffers from interference. We use these methods as baselines, not as components.
The third group supplies the conflict measure. Gradient Surgery for Multi-Task Learning (PCGrad) and Conflict-Averse Gradient Descent for Multi-task learning (CAGrad) change update directions inside a fixed neural architecture. Conflict-Averse Gradient Aggregation for Constrained Multi-Objective Reinforcement Learning (CoMOGA) does the same with a quadratic program per step. That paper notes that such conservative updates can truncate the reachable Pareto front, the set of best achievable trade-offs between tasks. Splitting addresses that truncation in a different way: instead of a compromise direction, each side of the conflict gets its own parameters. We reuse CAGrad's dual problem over task weights only as a diagnostic, never as the update rule.
Research Program
The system alternates two phases.
In the inner phase, the program's constants are tuned by the shared-perturbation estimator above. The update is the plain average of the task gradients. Throughout this phase we record $C_s$ for every subtree. The per-task estimates cost nothing extra, since every perturbed program is already being rolled out on every task. This removes the K-fold backward-pass overhead that PCGrad and CAGrad carry.
In the outer phase, the subtree whose low conflict has persisted longest is cloned. The two copies are placed under a guard chosen from the DSL's predicates. We cluster tasks by the sign pattern of their gradients on that subtree, then search for the cheapest predicate over observations that separates the clusters. Predicates over observations are preferred to a raw task-ID test, so that tasks never seen in training can still be routed by what the agent observes. The guard falls back to a task-ID predicate only when no observation predicate separates the clusters. Merging is the reverse move: two branches whose constants have drifted to within a tolerance of each other are collapsed back into one. A split is accepted only if it improves the summed return over a held-out set of seeds. A complexity penalty on the number of branches keeps programs readable and small enough to verify.
The analysis has three parts. First, we test whether $C_s$ predicts which edits succeed, by comparing it with an oracle that tries every possible split. Second, we test whether the estimator's noise floor makes conflict detection unreliable as K grows. The estimator's variance scales with the number of parameters divided by N, so we measure how many perturbations are needed for the sign of $C_s$ to be stable. Third, we check whether programs that keep more code shared generalize better to held-out tasks.
Baselines
The naive reference is a single program found by stochastic hill climbing over the summed task return, with the same DSL, the same budget of environment episodes and the same mutation operators as Reclaiming the Source. Its single-task strength is documented, and it isolates whether conflict information adds anything to plain search. Beating it means higher mean multi-task return at an equal episode count, averaged over at least ten seeds with confidence intervals.
The strongest structural competitor is one independently searched program per task. It never suffers interference, so it is the real threat on training-task return. It runs under the same total episode budget, split evenly across tasks. Beating it means matching its training return within noise while using fewer total episodes, and scoring higher on held-out tasks, where per-task programs have no principled way to route.
The strongest gradient-based competitor is multi-task π-PRL with CAGrad applied to both the grammar weights and the constants, following Programmatic Reinforcement Learning without Oracles and Conflict-Averse Gradient Descent for Multi-task learning. This is the obvious combination of the two directions, and a reviewer would expect it to be the answer. It gets the same episode budget, and we tune its conflict-aversion constant $c$ over the same grid size used for our split threshold. Beating it means higher return after the final conversion to a discrete program.
The teacher-guided competitor is PROPEL whose neural correction term is trained with CAGrad, so that the neural part is as strong as the file allows. Beating it means higher program return at equal episodes.
The ablation that isolates our key ingredient keeps the whole loop unchanged but chooses split locations uniformly at random, or by the largest gradient magnitude instead of by conflict. If conflict-chosen splits do not beat both, the central claim fails.
Why not just…?
Why not just apply CAGrad to a relaxed program, as in π-PRL? This is a real competitor and is run as one, but there are concrete reasons to expect it to fall short. dPads reports that relaxed program structures are biased toward paths that are quick to optimize. The file also lists collapse on conversion to a discrete program as an open problem. Conflict-averse updates aim for a compromise on a shared structure, while a program can instead give each side of the conflict its own branch. The comparison of returns measured after discretization settles which works better.
Why not just write one program per task? This avoids interference entirely, and on training tasks it may well tie with our method. Two pieces of evidence argue against it. On MT50, PCGrad-augmented multi-task SAC beat independent single-task agents, according to Gradient Surgery for Multi-Task Learning. The state-machine results in Synthesizing Programmatic Policies that Inductively Generalize suggest that shared structure is what transfers. If held-out performance and episode efficiency do not favor our method, this alternative wins, and we will report that.
Why not just hill-climb with "add a branch" as one of the mutations? Random branch insertion has to search over both the location and the guard, which is exactly the combinatorial blow-up the file identifies. The random-location ablation is this alternative under controlled conditions. We report the number of episodes to the first useful split as the decisive quantity.
Proposed Experiments
The first testbed is a multi-task Karel suite. A single program must solve Maze, Harvester, DoorKey and the Crashable variant, with the task observable only through the grid layout. The best single-task reference point in the file is hill climbing's 0.84 on DoorKey from Reclaiming the Source.
The second testbed is continuous navigation. A multi-goal set combines Ant Cross Maze, Ant Random Goal and HalfCheetah Hurdle with π-PRL's DSL. The file reports a single-task normalized distance to goal of 0.10 for π-PRL on Ant Cross Maze, and 94% zero-shot success under altered arenas. We use the altered arenas as held-out tasks.
The third testbed is TORCS across several tracks, with crash ratio as the metric. PROPEL reports crash ratios of often below 16%, against up to 92% for DDPG. Here we also check that the split programs still pass Z3 verification of smoothness properties; PROPEL reports verification in under half a second for its policies.
Last comes Meta-World MT10, to test how the method scales. No programmatic result on Meta-World was found on Lacuna. The neural ceiling for reference is multi-headed SAC at 85% success on MT10 (Meta-World).
The decisive checks are four. Conflict-chosen splits must beat random and magnitude-chosen splits. Our method must beat CAGrad-relaxed π-PRL on return measured after discretization. On held-out tasks it must match or beat one-program-per-task at an equal episode budget. Finally, the rank correlation between $C_s$ and the return gain from oracle splits must be clearly positive. If that correlation is near zero, the conflict signal carries no structural information and the proposal fails.
References
- Programmatic Reinforcement Learning without Oracles
- Differentiable Synthesis of Program Architectures
- Reclaiming the Source of Programmatic Policies: Programmatic versus Latent Spaces
- Language Models Speed Up Local Search for Finding Programmatic Policies
- Programmatically Interpretable Reinforcement Learning
- Imitation-Projected Programmatic Reinforcement Learning
- Gradient Surgery for Multi-Task Learning
- Conflict-Averse Gradient Descent for Multi-task learning
- Conflict-Averse Gradient Aggregation for Constrained Multi-Objective Reinforcement Learning
- Synthesizing Programmatic Policies that Inductively Generalize
- Meta-World: A Benchmark and Evaluation for Multi-Task and Meta Reinforcement Learning