Full text not available for this paper
Summary (Overview)
- HyScale is a long-context training system for learned sparse attention, addressing the training bottleneck of the selection step (scoring all previous tokens per query and selecting top-).
- Core insight: The output of selection is a discrete set of indices, not a continuous activation. This enables two key techniques: HyTopK (on-the-fly top- selection without materializing a full score table) and selection replay (reusing forward-pass selection during recomputation instead of repeating it).
- Results: HyScale accelerates end-to-end GLM-5.1 training on 1M-token sequences by 2.07× over Megatron-LM on 512 H20 GPUs, with speedups growing with context length.
- Generality: HyScale generalizes to block-level sparse attention architectures, speeding up CSA layers of DeepSeek-V4-Flash by 2.01× and QSA layers of Qwen3.8-Flash-Next by 1.57× at 1M tokens on 32 H800 GPUs.
- HyScale is deployed in production, powering large-scale LLM training at million-token contexts.
Introduction and Theoretical Foundation
Background
Long context has become a core capability of large language models, driving training sequence lengths from 128K to 1M tokens. At these lengths, full attention dominates training cost due to quadratic computation growth.
Learned Sparse Attention
Learned sparse attention reduces this cost by splitting attention into two steps:
- Selection: A lightweight indexer scores every previous token for each query and keeps the top-.
- Sparse attention: Each query attends only to the selected tokens.
The selection process is formalized as:
where is the indexer's query, is the indexer's key of entry , is the score vector, and is the index set of size .
Sparse attention then attends only to selected entries:
The Selection Bottleneck
The paper identifies two key inefficiencies in existing systems:
-
Materialized scores: Current systems write an score table to GPU memory before selecting, even though top- keeps only entries per query. At 1M tokens (K, ), the table takes 32 GiB per GPU, whereas selected indices take only 64 MiB.
-
Repeated selection: Under full activation recomputation, selection runs twice per training step—once in forward, once in recomputation.
Key Insight
The output of selection is not a continuous activation, but rather a discrete set of indices.
Two properties support this view:
- The score table serves only to find these indices; nothing reads the scores of non-selected keys.
- Top- is non-differentiable, so no gradient flows through selection; the backward pass needs only the selected indices and their scores.
Methodology
HyTopK: On-the-Fly Top- Selection
HyTopK uses optimistic thresholding—the threshold need not be a guaranteed lower bound, as long as failures are rare and cheap to recover from.
Three key components:
-
Optimistic strided sampling (C1): Samples evenly spaced keys from each query's own context, setting the threshold at the -th best sample.
-
Lightweight host-free recovery (C2): A check kernel marks failed queries (candidates overflowed or fewer than ), then recovery kernels rescore up to 64 failed queries over their whole context.
-
Deterministic selection (C3): Uses radix select for tied keys at the -th position and radix sort to order selected entries by score, breaking ties by position.
Selection Replay
Selection replay is a fine-grained recomputation policy that records forward-pass selection results and replays only the selected entries during recomputation.
Two variants:
- Index replay: Keeps only indices per query, rescores only those entries (default).
- Score replay: Also keeps the scores, rescores nothing.
Cost comparison (per layer, one GPU at M, K, ):
| Policy | Extra memory | Recomputation |
|---|---|---|
| No recomputation | all activations | 0 |
| Full recomputation | 0 | |
| Keep scores | ||
| Keep top- indices | ||
| Keep indexer inputs | ||
| Index replay | ||
| Score replay | 0 |
Holistic System Optimizations
-
Decoupled CP Overlap: Transfers indexer keys and KV states separately, overlapping each with computation that doesn't consume it.
-
Locality-aware sparse kernels: Process two adjacent queries in one thread block over the union of their selections (adjacent queries share ~71% of top- keys), reducing L2 traffic and atomic operations.
-
Implementation details: CP layout cache, sequence boundaries cache, kernel fusion, and permutation-free KV gather.
Empirical Validation / Results
End-to-End Training (GLM-5.1 on 512 H20 GPUs)
| Metric | 256K | 512K | 1M |
|---|---|---|---|
| Step time speedup | 1.23× | 1.44× | 2.07× |
| MFU (HyScale) | 20.9% | — | 27.8% |
| MFU (Megatron-LM) | 17.1% | — | 13.5% |
At 1M context, HyTopK cuts forward selection from 35.9s to 20.8s, and selection replay cuts recomputed selection from 37.0s to 1.0s.
Ablation Study (1M context, 128 GPUs)
- HyScale saves 66% of Megatron-LM's layer time
- HyTopK saves 37% (largest single contribution)
- Selection replay saves another 18%
- Implementation optimizations save the remaining 11%
Generality (Block-level architectures, 1M tokens, 32 H800 GPUs)
| Architecture | Speedup |
|---|---|
| CSA (DeepSeek-V4-Flash) | 2.01× |
| QSA (Qwen3.8-Flash-Next) | 1.57× |
HyTopK Efficiency
- Peak memory: 1.5–1.9 GiB per layer (vs. 3.1–48 GiB for Megatron-LM)
- Deterministic sort adds only 0.8% overhead
- Host-free recovery: 1.8% overhead for 1 failed query, 4.3% for 64
- Optimistic strided sampling fails on 5,000× fewer queries than LiteTopK/DoSA at 16K buffer slots
Theoretical and Practical Implications
Theoretical Implications
- Rethinking activation semantics: The paper challenges the assumption that all intermediate computation outputs must be treated as continuous activations. Discrete index sets require fundamentally different treatment in training systems.
- Recomputation policies: Operator-level recomputation granularity is insufficient for non-differentiable operations; entry-level policies can achieve orders-of-magnitude improvements.
- Threshold-based selection: Guaranteed lower bounds are unnecessary; optimistic thresholds with cheap recovery are more efficient in practice.
Practical Implications
- Production deployment: HyScale is deployed in production, demonstrating practical viability at scale.
- Architecture generality: Works across token-level (DSA) and block-level (CSA, QSA) sparse attention designs.
- Memory efficiency: Eliminates the memory–time trade-off of score table materialization, enabling longer contexts on existing hardware.
- Scaling behavior: HyScale's advantage grows with context length, making it increasingly valuable as models move toward million-token contexts.
Conclusion
HyScale addresses the training bottleneck of learned sparse attention through the key insight that selection outputs indices, not activations. Its two core techniques—HyTopK (on-the-fly top- selection via optimistic thresholding) and selection replay (fine-grained recomputation policy)—eliminate the score table materialization and repeated selection costs, respectively.
The system achieves 2.07× end-to-end speedup for GLM-5.1 training at 1M tokens on 512 H20 GPUs, with speedups growing as context lengths increase. HyScale generalizes across diverse learned sparse attention architectures and is deployed in production.
Future directions implied by this work include:
- Extending these techniques to other non-differentiable operations in training
- Further optimization of sparse kernels for even longer contexts
- Adaptation to emerging sparse attention architectures as they evolve
Related papers
- AgenticEvolve: Evolutionary Program Search with Persistent Language Model Agents that Design and Run Experiments
AgenticEvolve, where persistent LLM agents run self-designed experiments between evaluations, consistently outperforms baselines in heuristic design and symbolic regression while keeping costs under a few dollars per run.
- What Does a Harness Repair? A Preregistered Study of Visibility, Baseline Adequacy and Evaluation Defects
Preregistered harness-search studies show most accuracy gains are visibility artifacts, and searched harnesses failed to beat trivial constant-label baselines despite large nominal improvements.
- Adaptive-Depth Is a Finishing Stage
Fixed-first training cuts adaptive-depth transformer training compute by 30-45% with negligible quality loss by reserving full-depth updates for a brief final phase.