Verifiable Environments Are LEGO Bricks: Recursive Composition for Reasoning Generalization

Hao Xiang, Qiaoyu Tang, Le Yu, Yaojie Lu, Xianpei Han, Ben He, Le Sun, Bowen Yu, Peng Wang, Hongyu Lin, Dayiheng Liu

TL;DR

RACES (Recursive Automated Composition for Environment Scaling) is a novel framework that scales reinforcement learning training data for LLMs by snapping together verifiable environments like LEGO bricks. By matching the output type of one task to the input type of another, RACES generates an unbounded space of complex, multi-step reasoning problems from a small base pool, significantly boosting downstream generalization on unseen benchmarks.

What Problem Does This Paper Address?

Reinforcement Learning with Verifiable Rewards (RLVR)—popularized by models like DeepSeek-R1—relies on environments that can programmatically and deterministically verify answers (e.g., code execution, math problems, logic puzzles). While scaling up the number and diversity of these environments directly translates to better LLM reasoning, creating them is a bottleneck.

Currently, environments are engineered manually or synthesized individually by LLMs. This results in a linear scaling limit: doubling your environment pool doubles your construction cost. Consequently, models risk overfitting to a narrow, structurally simplistic set of training tasks, hindering their ability to generalize to truly novel reasoning problems.

Methods

RACES bypasses linear scaling by leveraging the compositional closure property of verifiable environments. If Environment A outputs an integer, and Environment B takes an integer as input, RACES automatically fuses them into a new, more complex environment ($B \circ A$).

Figure 1: Overview of the RACES framework. 1) RACES standardizes the format of a verifiable environment, which consists of four components. 2) Following the standard interface, RACES constructs a pool of verifiable environments. 3) RACES can snap environments together like Lego bricks if the codomain of one matches the domain of another. 4) RACES implements four composition operators, resulting in diverse composite patterns and reasoning requests.

The framework operationalizes this via a three-stage pipeline:

  1. Composition Path Discovery: A randomized breadth-first search explores a tree of type-compatible environment sequences.
  2. Quality Assurance: An online executable filtering step discards paths that trigger runtime exceptions, timeouts, or degenerate states (e.g., loops or empty outputs).
  3. Operator Instantiation: To turn these composite paths into diverse training prompts, RACES applies four distinct composition operators:
  4. SEQUENTIAL: Chains tasks together; the model must track and output all intermediate and final states.
  5. PARALLEL: Packs independent tasks into a single context, forcing the model to manage multiple computational threads.
  6. SORT: Presents a shuffled set of tasks and a target output; the model must deduce the correct execution order.
  7. SELECT: Introduces "distractor" tasks; the model must identify the correct subset and arrange them in order.

Datasets

The authors seeded RACES with an initial pool of 300 base environments sourced from algorithmic datasets, manual curation, and LLM-assisted synthesis.

Crucially, to test true reasoning generalization, the models were evaluated on six challenging benchmarks completely unseen during training:

  • LiveCodeBench (LCBench): Code generation.
  • AIME 2024/2025: High-school competition mathematics.
  • Enigmata: Synthetic logical puzzles.
  • IFEval: Verifiable instruction following.
  • LongBench-v2 (LBench-V2): Long-context understanding.

Key Insights and Ideas

  • The Training Reward Paradox: During training, models trained on individual, uncompounded environments achieve much higher rewards much faster than RACES models. However, this rapid optimization represents overfitting. RACES models face a harder optimization challenge (slower reward growth) but acquire transferable reasoning behaviors that excel on downstream tasks.
  • Massive Data Efficiency: RACES turns a small environment pool into a combinatorial goldmine. Training on just 50 base environments composed via RACES achieved downstream performance comparable to or better than training on 300 individual, uncompounded environments.
  • The Difficulty Sweet Spot: Task difficulty can be precisely modulated by changing the composition size (the number of blocks chained together). However, more isn't always better: performance improves steadily from size 2 to 5, but drops at size 6 because the optimization landscape becomes too difficult, leaving a less informative learning signal for RL.

Key Results

RACES was evaluated using two 14B parameter backbones: DeepSeek-R1-Distill-Qwen-14B and Qwen3-14B.

Table 1: Main results. LCBench and LBench-V2 denote LiveCodeBench and LongBench-V2; AIME is the average score on AIME 2024 and AIME 2025. Both RL settings use the same number of training instances and steps.
  • DeepSeek-R1-Distill-Qwen-14B: RACES improved the average score across all benchmarks by 3.1 points (from 48.2 to 51.3), significantly outperforming the individual-environment baseline, which only crawled up to 48.8. Notable jumps occurred on IFEval (+4.0) and LongBench-v2 (+3.5).
  • Qwen3-14B: RACES boosted the base model's average performance from 58.8 to 61.1.
  • Qualitative Shift: Qualitative analysis showed that RACES-trained models naturally develop superior strategies, such as defining reusable functional abstractions, maintaining explicit index-value tracking, and executing self-consistency checks, rather than relying on error-prone, ad-hoc enumeration.

Limitations and Future Work

While powerful, the authors note a few constraints of the current framework:

  • Design Space Coverage: The four chosen operators represent a subset of programming logic. Complex control flows like conditional branching (IF-ELSE) and bounded loops (FOR/WHILE) remain unexplored.
  • Cold-Start Problem: RACES relies on the base model having a baseline level of reasoning competence. If a model is too weak, it will consistently fail composite tasks, leading to sparse rewards that stall RL training.
  • Context Window Demands: Multi-step composite reasoning generates long thought traces, requiring large context windows (32K tokens in these experiments), which increases computational overhead.

Summary updated

BibTeX
@inproceedings{xiang2026verifiable,
  author = {Hao Xiang and Qiaoyu Tang and Le Yu and Yaojie Lu and Xianpei Han and Ben He and Le Sun and Bowen Yu and Peng Wang and Hongyu Lin and Dayiheng Liu},
  title = {{Verifiable Environments Are LEGO Bricks: Recursive Composition for Reasoning Generalization}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=PUqSH8cFqy},
}
Figure