arXiv(opens in a new tab)cs.LGAug 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2608.28158

HARTS: Efficient Agentic Reinforcement Learning for Hybrid-Attention Models over Arbitrary Rollout Trees

Boyuan Meng, Peihua Bao, Hong Liu, Xiaowei Zhu, Chao Wang, Gen Li, Zhenxuan Pan

Boyuan Meng

Ant Group

China

Xiaowei Zhu

Ant Group

China

Peihua Bao

Ant Group

China

Chao Wang

Ant Group

China

Hong Liu

Ant Group

China

Gen Li

Ant Group

China

Zhenxuan Pan

Ant Group

China

Abstract

Agentic reinforcement learning (RL) often produces irregular rollout trees whose trajectories share long interaction histories. Training each root-to-leaf trajectory independently recomputes these shared prefixes. Existing tree-structured training systems primarily target full-attention models and do not provide dense, differentiable hybrid-attention execution compatible with activation recomputation. We present HARTS (Hybrid-Attention RL over Tree Structures). HARTS jointly constructs microbatches, data-parallel (DP) replica assignments, and microbatch-slot schedules using the number of unique, non-replay compact token rows after prefix compression as its work metric. For chunkwise linear attention, a linear-time algorithm coordinates chunk-boundary state recovery and replay and produces the minimum possible number of sequential linear-attention calls under our packed chunkwise execution model. The resulting execution preserves the chunkwise state partitioning of conventional trajectory-wise training: it does not repeat projections, MLP/MoE computation, or final outputs, and performs only the bounded linear-attention state replay required for numerical alignment. At runtime, HARTS batches all branches in an execution round into one packed call, propagates gradients through differentiable state handoffs, supports activation recomputation, and restores per-token log-probabilities from compact outputs. For deterministic, no-token-drop top-k MoE routing, semantic multiplicities also restore the token weights and load statistics used by the MoE objectives. Existing RL objectives retain their interface. To our knowledge, HARTS is the first system to demonstrate arbitrary-rollout-tree prefix-sharing speedups on a real hybrid-attention model. On an Agentic RL workload generated from SWE-bench tasks, HARTS achieves 4.81–4.87× forward/backward/gradient speedup with activation recomputation across multiple parallel configurations. Its numerical differences are comparable to baseline self-rerun variation, and its reward trend is similar to the baseline over the first 120 steps of τ3\tau^{3}-Bench training.

Keywords: agentic reinforcement learning, hybrid attention, rollout trees, prefix sharing, distributed training

1 Introduction

Agentic reinforcement learning (Agentic RL) trains an agent through multi-turn interactions, tool calls, parallel exploration, and retries after failed attempts. Sampling therefore need not produce independent linear sequences. It can instead produce a rollout tree with irregular depth, fan-out, and fork positions: each root-to-leaf path is a training trajectory, and multiple trajectories share the task description, environment state, and early interaction history (Figure 1(a)). Conventional trajectory-wise training expands and executes every trajectory independently, repeating the forward and backward computation of shared prefixes within the same training step. In our Agentic RL workload, generated by a Claude Code scaffold solving SWE-bench tasks [7], trajectory-wise expansion contains approximately 5.63×5.63\times as many non-replay token rows as compact execution. Shared-prefix redundancy is therefore a major training cost for this workload.

On a hybrid-attention model, a tree mask addresses only ancestor visibility in full attention; it does not satisfy the state-recovery and execution constraints of chunkwise linear attention (Figure 1(b)). In a full-attention layer, the tree primarily determines which ancestor keys and values each query can see. High-performance training algorithms for linear-attention variants such as RetNet, GLA, DeltaNet, Gated DeltaNet, and Kimi Delta Attention (KDA), however, use a chunkwise parallel/recurrent formulation. They compute within fixed-size chunks in parallel while propagating recurrent state across chunks [8, 15, 18–20]. An arbitrary fork rarely coincides with a fixed chunk boundary at which the operator can export a recurrent state for another branch. To preserve the state partitioning and floating-point path of

Contact: mengboyuan.mby@antgroup.com.

(a) One rollout tree and its trajectories

Compact rollout tree

Root-to-leaf trajectories

Figure

T1

A

B

D

T2

A

B

E

T3

A

C

T1 and T2 share A and B, then use different next-token labels D and E.

Each box denotes one or more contiguous tokens.

(b) Tree dependencies in full and linear attention

Full attention

Ancestor KV + current QKV → output

ancestor KV

[A, B]

QKV_D

Full Attn D

Y_D

QKV_E

Full Attn E

Y_E

Linear attention

Recurrent state + current QKV

→ output + next state

shared state

S_B

Linear Attn D

Y_DIS_D

Linear Attn E

Y_EIS_E

QKV_E

(c) HARTS training pipeline for arbitrary rollout trees

Placement is measured in physical compact tokens; execution follows the verified plan for the highlighted microbatch.

1 Balance DP-replica work:

per-slot and current-step totals

Bar length is schematic; microbatch 0* contains tree

(a).

Slot 1

Slot 2

DP

replica 0

microbatch 0*

microbatch 2

DP

replica 1

microbatch 1

microbatch 3

Balanced within

each slot

Balanced within

each slot

Balanced current-step totals

replica 0

replica 1

2 Plan linear-attention execution

Verified minimum: 2 sequential calls

Call 1

A

B

D

state dependency—state dependency

Call 2: one variable-length batch

C

E

3 Execute hybrid layers

on the linear-attention-aware ordering

Planner-produced call layout

Call 1: [A, B, D]

Call 2: [C] [E]

Full attention

ancestor view

Linear

attention

planned calls

MoE

routing +

experts

4 Restore RL/MoE semantics

One compact row, multiple semantic uses

RL log-probabilities

compact logit row

zBz_{B}

computed once

T1: label D

logsoftmax( zBz_{B}) | D

T2: label E

logsoftmax( zBz_{B}) | E

MoE router training

router result rBr_{B}

computed once

semantic multiplicity

qB=2q_{B} = 2

weights z-/aux losses

and expert-bias counts

Figure 1. HARTS carries one rollout tree through distributed hybrid-attention training. (a) The three rows are exactly the root-to-leaf trajectories represented by the tree; each box denotes one or more contiguous tokens. T1 and T2 share A and B but use different next-token labels D and E, while T3 shares only A before following C. (b) Both branch paths consume their current QKV. Full attention additionally reads the explicit ancestor KV of [A, B], whereas linear attention consumes the shared recurrent state SBS_B and produces a branch-specific next state. (c) HARTS balances compact-token work across DP replicas at two levels: within each microbatch slot and in their current-step totals; bar lengths are schematic and do not report measured values. For the highlighted microbatch, the verified minimum plan executes [A, B, D] in Call 1 and batches [C] and [E] as two independent sequences in Call 2. The resulting compact ordering is shared across layer types: full-attention layers recover ancestor visibility, chunkwise linear-attention layers execute the planned variable-length calls, and MoE layers perform compact routing and expert computation. One compact logit row zBz_B yields the target-indexed log-probabilities for T1 and T2; the semantic multiplicity qB=2q_B = 2 weights the router losses and the expert-load counts used by expert-bias update, without repeating routing or expert computation.

trajectory-wise training, a side branch must resume from the nearest preceding chunk-boundary state and replay less than one chunk of ancestor state updates inside the linear-attention core. Under the packed chunkwise operator interface that we target, a boundary state produced within a call cannot initialize a separate input sequence until that call returns, and gradients from all consuming branches must propagate through the shared state. Executing one rollout-tree node at a time, as in Tree Training’s linear-attention/GDN path [16], can traverse an arbitrary tree but fragments the work into many small sequential calls. When a fork falls inside a chunk, node boundaries also change the numerical path of conventional chunkwise training. Prefix sharing on hybrid-attention models is thus simultaneously a state-recovery, call-planning, differentiability, and computation-density problem.

Existing tree-structured training systems do not solve this combination of problems. Tree Training [16] uses tree-node state routing in its linear-attention/GDN path. Its paper reports no real hybrid-attention training experiment that establishes the path’s efficiency or scalability. Its reported training performance, memory usage, and learning results use full-attention Qwen3-30B/32B models [17], and the system lacks effective support for parallel training [21]. Its strict zero-redundancy partitioning also requires retaining and reusing parent computation graphs and boundary states across partitions or microbatches. This lifetime conflicts with standard activation recomputation, which discards forward activations and rematerializes them during backward. Retaining the parent graph forfeits the corresponding memory savings; discarding it requires recomputing shared ancestors and is no longer strictly zero-redundancy. AReaL-DTA [21], in turn, targets standard full-attention Transformers, dynamically executes at tree-node granularity, and supports only data parallelism. It does not provide dense execution for models that interleave full- and linear-attention layers. Existing approaches therefore do not jointly support efficient execution on real hybrid-attention models, multidimensional parallelism, activation recomputation, and arbitrary rollout trees.

We present HARTS (Hybrid-Attention RL over Tree Structures), a training system for Agentic RL over arbitrary rollout trees on hybrid-attention models (Figure 1(c)). HARTS carries prefix sharing through batch construction, full- and linear-attention execution, and dense or mixture-of-experts (MoE) feed-forward computation while reconstructing the original RL objective interface and the applicable MoE objective weights. It organizes and assigns training examples by the computation that remains after shared prefixes are removed. It then reconciles the distinct dependencies of full and chunkwise linear attention and coalesces irregular tree computation into a small number of packed calls. The same compact layout drives MoE routing and expert computation, so prefix sharing spans the entire hybrid model. This execution remains differentiable, supports activation recomputation, and composes with multiple forms of parallelism. At the objective interface, HARTS recovers a log-probability for every semantic token occurrence. Under deterministic, no-token-drop top-k routing, semantic multiplicity restores the token weights of MoE router losses and the expert-load counts used by expert-bias updates. Existing RL objectives remain unchanged. To our knowledge, HARTS is the first system to demonstrate arbitrary-rollout-tree prefix-sharing speedups on a real hybrid-attention model.

We evaluate HARTS on Ling-3.0-tiny, a hybrid-attention MoE model with Multi-head Latent Attention (MLA) and KDA layers. The Agentic RL rollout-tree workload is generated by a Claude Code scaffold solving SWE-bench tasks. All performance experiments enable activation recomputation. Across multiple parallel configurations, 5.62–5.63× non-replay compact-row compression yields 4.81–4.87× forward/backward/gradient (F/B/Grad) speedup and 4.39–4.63× training-core speedup. F/B/Grad covers the complete measured training path after planning except for the optimizer update, whereas Core additionally includes HARTS planner latency. In separate numerical-fidelity experiments, with and without activation recomputation, the mean token-wise cosine similarity between HARTS and baseline full-vocabulary logits exceeds 0.9997 and is close to baseline self-rerun variation. Over the first 120 steps of online τ3\tau^{3}-Bench training [1], HARTS and the baseline also exhibit similar reward trends. This paper makes three contributions:

  • Prefix-aware microbatch planning and schedule construction for arbitrary rollout trees. Subject to capacity constraints, HARTS generates candidate microbatch partitions together with their DP-replica assignments and microbatch-slot schedules. It measures cost by non-replay compact-token work and selects a balanced plan using total work, critical-path work in each slot, and cumulative work on each DP replica.

• Minimum-call execution. When a fork falls inside a linear-attention chunk, each side branch resumes from the nearest preceding chunk-boundary state and replays less than one chunk of ancestor updates, preserving the chunkwise state partitioning of trajectory-wise training. A linear-time algorithm selects one direct continuation at each fork and schedules every side branch in the earliest call where its initial state is available. Under the stated packed chunkwise execution model, the plan uses the minimum possible number of sequential linear-attention calls. It never repeats projections, MLP/MoE computation, or final outputs, and performs only the bounded state replay required for numerical alignment. At runtime, HARTS batches the branch sequences in each round into one packed call, selectively returns chunk-boundary states, and supports backward and full-layer activation recomputation through differentiable state handoffs. The resulting training path supports multiple parallel configurations.

• RL and MoE semantics in compact coordinates, without expansion. Compact-to-semantic log-probability computation obtains current log-probabilities in the original token order directly from compact logits and accumulates gradients from reused compact logit rows back into compact coordinates. Existing policy objectives consume these log-probabilities and their original metadata unchanged. For deterministic, no-token-drop top-k routing, semantic multiplicity restores the token weights of router z-loss and the routing mass and assignment counts used by auxiliary losses and expert-bias updates. Routing, dispatch, and expert computation remain compact.

References (10)