Manuscript Offprint

arXiv:2610.28998

FlashNext-RL: A System Optimization Study for Long-Horizon Agentic RL of Qwen3.8-Flash-Next

Zhewei Yao, Yuxiong He

Abstract

Long-horizon agentic reinforcement learning (RL) requires both efficient rollout generation and training on long sequences. However, the memory requirements and model-specific operators of Qwen3.8-Flash-Next make this difficult with existing open-source implementations. To resolve these limitations, we introduce FlashNext-RL, a model-specific RL training optimization framework based on prime-rl, with vLLM for software engineering (SWE) rollout generation. Our main focus is BF16 training of the full 48-layer model on a single 8×B200 node, with the first two layers, the n-gram table, the sparse-attention indexer and the multi-token prediction head frozen. We optimize host offload, gradient accumulation and the kernels for mixture-of-experts, sparse attention and the gated residual stream. In the full-model development study, non-padding training throughput increases from approximately 395 tokens/s/GPU in the initial 32K-token configuration to 4,438 tokens/s/GPU in the optimized 131K-token configuration, with hardware matmul throughput (aka without considering the cost of attention components) increasing from approximately 20 to 213 TFLOPs/GPU. A controlled cumulative study on an 8-layer model further quantifies the contributions of individual optimizations. Together with three inference nodes, the system supports a live SWE RL run with a target batch of 1,024 trainable rollouts and a 131,072-token context limit. Over steps 5–15, an iteration takes 22.4 minutes on average, with bounded entropy and trainer–sampler mismatch KL. These results highlight the importance of tailoring RL training to the model's architecture, memory layout and kernel requirements, rather than relying only on general-purpose RL infrastructure.

1 Introduction

Reinforcement learning (RL) is widely used in large language model (LLM) post-training to improve reasoning capabilities [35, 9, 47]. More recently, it has been applied to agentic tasks that require interaction with an environment over multiple turns [19, 29]. Software engineering (SWE) is a representative example: an agent reads a repository, executes commands and tests, and edits code to resolve an issue [17]. SWE-Gym, R2E-Gym and SWE-smith provide environments or training data for developing such agents [27, 16, 43], while SWE-rebench addresses task collection and decontaminated evaluation [2]. In our setting, a rollout may contain many interaction turns, but its total context is capped at 131,072 tokens; a training batch contains approximately one thousand trainable rollouts. Open-source RL systems, including DeepSpeed-Chat, OpenRLHF, HybridFlow and AReaL, address different aspects of training and generation [46, 14, 37, 12]. In this work, we build on prime-rl for training and orchestration [28], and verifiers for environments [3].

Qwen3.8-Flash-Next introduces architectural changes within the Qwen model family [42, 31]. The model configuration used in this study has the following components, consistent with the released configuration [32]:

• Hybrid attention. 36 of the 48 layers use Gated DeltaNet (GDN) linear attention [44]. The other 12 use Qwen Sparse Attention (QSA), where a lightweight indexer selects up to 512 blocks of 4 keys per query. Related sparse-attention designs include NSA and DeepSeek Sparse Attention [48, 11].

• Gated residual. A 4-branch residual stream (4×2560)(4 \times 2560) is mixed by learned read and write gates. Related multi-stream residual designs include hyper-connections and mHC [52, 41].

• N-gram embedding. A frozen 51B-parameter n-gram table supplies per-layer embeddings (PLE). Engram provides a related conditional-memory design [6].

• Fine-grained MoE. Each layer has 512 routed experts with top-10 routing and an intermediate size of 640, plus a shared expert. This follows the broader use of sparse mixture-of-experts (MoE) layers [36, 10].

• Multi-token prediction (MTP). An additional 4B-parameter head supports multi-token prediction, a technique studied in prior work [13, 10]. We use this head for speculative decoding [21, 4], rather than training it during RL.

In total, the model has 125B parameters (6B activated per token), plus the 51B n-gram table and the 4B MTP head.

However, the open-source implementations we evaluated did not meet our target of efficient training at a 131K-token context on one B200 node. vLLM provides the serving backend [20], and training frameworks such as NeMo AutoModel and ms-swift provide useful infrastructure [26, 51]. Our target additionally requires model-specific backward kernels and memory planning across the RL loop. In particular, we encountered three limitations:

  1. GPU memory. Without context parallelism, retaining one residual-stream input per layer for activation checkpointing [5] requires 48×131,072×10,24048 \times 131,072 \times 10,240 BF16 values, or about 129 GB (120 GiB) per GPU, before accounting for weights, gradients and layer-local intermediates.

  2. Host memory. With CPU offload [33, 50], storing an fp32 master parameter, an fp32 gradient and two fp32 AdamW moments requires 16 bytes per parameter. Our planning budget is about 1.9 TiB before the n-gram table and the remaining RL system state, exceeding the node's host-memory capacity once these are included.

  3. Kernels. We found few efficient implementations of the backward pass of QSA's sparse grouped-query attention, of MoE kernels for an intermediate size of 640 at expert parallelism 8, or of fused kernels for the gated residual and the per-layer embeddings.

To resolve those limitations, we introduce FlashNext-RL, which focuses on model-specific RL training optimization for Qwen3.8-Flash-Next in prime-rl, with SWE as the example. The RL setup uses four 8×B2008 \times B200 nodes: one for training and three for inference. We train the full 48-layer model, but freeze the first two layers, the n-gram table, the QSA indexer and the MTP head; this is not an update of every model parameter. The contributions of FlashNext-RL are summarized as below.

  1. Inference (Section 2). A vLLM serving configuration for long agentic rollouts (per node, 2 engines of tensor parallelism 4 with expert parallelism; MTP speculative decoding; BF16 weights and KV cache).

  2. Training (Section 3). A single-node BF16 trainer with CPU offload, streaming Muon [18, 22], expert and context parallelism, and model-specific kernels. The optimized full-model development configuration reaches 4,438 non-padding tokens/s/GPU and 213 hardware matmul TFLOPs/GPU (Table 12). Isolated comparisons and an 8-layer cumulative study quantify the contributions of individual optimizations.

  3. End-to-end RL (Section 4). The memory, weight-transfer and checkpoint optimizations that let one training node run within a 2TB host-memory budget along with three inference nodes

  4. A real SWE RL run (Section 5). An end-to-end demonstration reporting iteration time, throughput, sequence lengths and short-run numerical behavior.

Note that our goal is not to reach the best model accuracy or the most efficient RL recipe, but to identify the model-specific RL training optimizations that make long-horizon agentic RL of Qwen3.8-Flash-Next practical.

References (43)