KTPO: K-Step Test-Time Policy Optimization for Long- Horizon Discovery

Dacheng Li, Fangzhou Zhao, Shiyi Cao, Hao Zhang, Joseph E. Gonzalez, Ion StoicaCOLM 2026

TL;DR

KTPO (K-Step Test-Time Policy Optimization) is a new reinforcement learning framework that allows relatively small Large Language Models (4B–9B parameters) to solve complex "long-horizon" discovery problems in mathematics and systems engineering. By training on short, $k$-step refinement trajectories starting from a curated pool of previously discovered solutions, KTPO enables models to surpass human records and state-of-the-art AI systems on tasks like circle packing and cloud cost optimization.

What Problem Does This Paper Address?

Discovery problems—such as finding the most efficient way to pack circles in a square or minimizing data transfer costs across clouds—are notoriously difficult for AI. These tasks are "long-horizon," meaning they typically require hundreds of iterative refinement steps to reach a high-quality solution.

Current approaches generally fall into two camps:

  1. Training-free search: Using frozen LLMs as "mutation operators" in evolutionary algorithms. While effective, the model never actually learns from the search process.
  2. Reinforcement Learning (RL): Training the model to improve. However, applying RL to a full 500-step refinement trajectory is computationally unstable and difficult to scale.

Prior attempts to bridge this gap used single-step RL updates, but these fail to teach the model complex, multi-step exploration strategies. The authors of KTPO sought a way to give models the benefits of long-term search while keeping the training process efficient and focused.

Methods

KTPO introduces a three-phase iterative loop that optimizes the model during the "test-time" search itself:

  1. Refine: Instead of starting from scratch, the model samples a "parent" program from a pool of previously discovered solutions. It then performs $k$ sequential refinement steps (where $k$ is small, e.g., 4 or 8), using evaluator feedback like error messages or constraint violations to guide its edits.
  2. Train: The model is updated using Group Relative Policy Optimization (GRPO). It receives a reward of +1 if a "child" program improves upon its parent, 0 if it's valid but not better, and -0.5 if the code is invalid (e.g., crashes).
  3. Update Pool: This is the core innovation. The system tracks the improvement rate—how often the model successfully improves a specific program. If the model improves a program very easily, that program is considered "mastered" and is used to set an eviction threshold. Programs with scores below this threshold are pruned, ensuring the pool always represents the model’s "learning frontier."
Figure 1: KTPO optimizes the LLM using short k-step refinements from a pool of pre- viously discovered programs, and updates this pool using program improvement rates. Each iteration consists of three phases. (1) Refine (Section 3.1): sample parent programs from the pool and generate improved child programs through k-step sequential refinements with evaluator feedback. (2) Train (Section 3.2): assign a reward of +1 if the child improves over its parent, 0 if it is valid but non-improving, and −0.5 if it is invalid, then update πθ via GRPO. (3) Update pool (Section 3.3): record the fraction of child programs that outperform their parent program (improvement rate), estimate an eviction threshold, and evict weak parent programs from the pool.

Datasets

The authors evaluated KTPO across seven open-ended optimization tasks:

  • Mathematical Discovery: Circle Packing ($n=26$) and the Erdős Minimum Overlap problem.
  • Systems Optimization (ADRS Benchmark): Five real-world engineering tasks, including optimizing SQL query schemas, minimizing multi-cloud data transfer costs, and balancing expert-parallel loads across GPUs (EPLB).

These benchmarks are particularly challenging because they have objective, deterministic evaluators (like a compiler or a math formula) that provide clear "ground truth" scores.

Key Insights and Ideas

  • The Power of the Frontier: The authors found that keeping every discovered program in the pool actually hurts performance. Without eviction, the pool grows to tens of thousands of programs, diluting the training data with "easy" tasks. By evicting mastered programs, KTPO forces the model to stay focused on the edge of its current capabilities.
  • Multi-step is Critical: Ablation studies showed that training on $k=4$ or $k=8$ steps is significantly more effective than $k=1$. Multi-step trajectories allow the model to learn how to recover from intermediate mistakes—a vital skill for complex discovery.
  • Small Models, Big Results: One of the most surprising findings is that 4B and 9B parameter models (like Qwen3) using KTPO can outperform much larger proprietary models like GPT-5 or Gemini-3-Pro that are used in training-free search setups.

Key Results

KTPO achieved several new records across both math and systems tasks:

  • Circle Packing: KTPO matched the best-known AI score (2.63598) and surpassed the human record (2.634).
  • Systems Engineering: It set new AI records for minimizing multi-cloud data transfer costs and balancing GPU loads. It also outperformed the human record for maximizing SQL query prefix hit rates.
  • Efficiency: When compared against evolutionary baselines (like AlphaEvolve) using the same model and compute budget, KTPO consistently found better solutions, proving that the gains come from the RL method rather than just raw compute.
Figure 1: KTPO optimizes the LLM using short k-step refinements from a pool of pre- viously discovered programs, and updates this pool using program improvement rates. Each iteration consists of three phases. (1) Refine (Section 3.1): sample parent programs from the pool and generate improved child programs through k-step sequential refinements with evaluator feedback. (2) Train (Section 3.2): assign a reward of +1 if the child improves over its parent, 0 if it is valid but non-improving, and −0.5 if it is invalid, then update πθ via GRPO. (3) Update pool (Section 3.3): record the fraction of child programs that outperform their parent program (improvement rate), estimate an eviction threshold, and evict weak parent programs from the pool.

Limitations and Future Work

  • Wall-clock Overhead: Training while searching isn't free. KTPO takes about 1.86x longer than an inference-only search due to the time required for gradient updates and the fact that the model generates longer, more complex code as it improves.
  • Diminishing Returns on $k$: While $k=4$ was a huge jump over $k=1$, the benefits of increasing $k$ to 8 were smaller, suggesting there is a "sweet spot" for trajectory length.
  • Generalization: The current work focuses on code-based discovery. Future research could explore whether this "learning frontier" approach works for non-coding tasks, such as symbolic logic or creative writing.

Summary updated

BibTeX
@inproceedings{li2026ktpo,
  author = {Dacheng Li and Fangzhou Zhao and Shiyi Cao and Hao Zhang and Joseph E. Gonzalez and Ion Stoica},
  title = {{KTPO: K-Step Test-Time Policy Optimization for Long- Horizon Discovery}},
  booktitle = {COLM},
  year = {2026},
  url = {https://openreview.net/forum?id=t2MIMXJq3W},
}
Figure