Create and explore imaginative 3D worlds with our new product Dreamfield (opens in a new tab)
Papers
Topics
Authors
Recent
Search
2000 character limit reached

HyScale Distributed Training | HyperScale Training | Graph Neural Networks

Updated 29 October 2026
  • HyScale is a distributed training system designed for learned sparse attention, accelerating training while preserving selected sparse-attention computations on long sequences, such as million-token lengths.
  • HyScale employs HyTopK, an algorithm that selects top-k candidates without materializing the full score table, making it efficient with reduced memory traffic and improved computation performance, seen in speed improvements up to 2.07 times on 512-H20 GPUs, compared to conventional methods.
  • The system utilizes selection replay, allowing efficient recomputation of selected candidates and reducing the computational cost significantly, optimizing memory usage and communication for improved distributed training scenarios

HyScale is a distributed training system for learned sparse attention at million-token sequence lengths. Its central design principle is to treat attention selection as production of a discrete index set rather than as production of a dense activation. HyScale implements HyTopK, an on-the-fly exact top-kk selection algorithm that avoids materializing the full score table, and selection replay, which reuses forward-pass selections during activation recomputation. Combined with context-parallel communication overlap, locality-aware sparse kernels, and other system optimizations, HyScale accelerates long-context training while preserving the selected sparse-attention computation. On one-million-token sequences, it reports a 2.07×2.07\times speedup for GLM-5.1 on 512 H20 GPUs, 2.01×2.01\times for the CSA layers of DeepSeek-V4-Flash on 32 H800 GPUs, and 1.57×1.57\times for the QSA layers of Qwen3.8-Flash-Next on the same 32-H800 configuration (Deng et al., 23 Oct 2026).

1. Scope and problem formulation

HyScale targets learned sparse attention, in which an indexer scores a large set of candidate tokens or blocks and selects only kk entries for the subsequent attention computation. For query position tt, the candidate set is denoted by UtU_t, and the indexer produces scores

It=(Score⁡(qtI,kuI))u∈Ut.I_t=\left(\operatorname{Score}(q_t^I,k_u^I)\right)_{u\in U_t}.

The selected set is

Tt=TopK⁡(It),∣Tt∣=k,T_t=\operatorname{TopK}(I_t), \qquad |T_t|=k,

after which sparse attention operates only on the selected entries:

ot=Attn⁡(qt,{cu}u∈Tt).o_t=\operatorname{Attn}\left(q_t,\{c_u\}_{u\in T_t}\right).

Selection therefore has computational cost proportional to ∣Ut∣|U_t|, potentially O(L)O(L) for a context of length LL, whereas sparse attention reads only kk entries. At million-token sequence lengths, the supposedly sparse layer can consequently become dominated by the dense selection stage.

For a DSA-style indexer, the score function is

Score⁡(qtI,kuI)=∑h=1HIwt,hReLU⁡((qt,hI)⊤kuI).\operatorname{Score}(q_t^I,k_u^I) = \sum_{h=1}^{H_I} w_{t,h}\operatorname{ReLU}\left((q_{t,h}^I)^\top k_u^I\right).

The indexer loss uses the selected scores:

LI=λ∑tKL⁡(pt  ∥  Softmax⁡(It,Tt)),\mathcal{L}_I = \lambda\sum_t \operatorname{KL} \left( p_t\;\middle\|\; \operatorname{Softmax}(I_{t,T_t}) \right),

with detached indexer inputs and target distributions. Gradients from this loss flow only through selected scores.

Two implementation costs motivate HyScale:

  • Dense score-table materialization: conventional execution writes an n×Ln\times L score table and subsequently reads it for top-kk selection. This requires O(nL)O(nL) storage and substantial memory traffic.
  • Repeated selection during recomputation: activation recomputation conventionally reruns indexer projections, scoring, and top-kk selection, despite the backward pass requiring only selected indices and selected scores.

In the GLM-5.1 configuration with n=8,192n=8{,}192, L=1,048,576L=1{,}048{,}576, and k=2,048k=2{,}048, a single-layer score table occupies approximately 32 GiB, whereas the selected indices occupy approximately 64 MiB. Only about 0.2%0.2\% of scores survive top-kk. At one million tokens, selection accounts for 47% of the training step and is 6.6 times slower than sparse attention (Deng et al., 23 Oct 2026).

2. System architecture and execution workflow

HyScale is implemented on top of Megatron-LM and preserves the broader long-context training stack. Its attention-layer workflow is divided into forward execution, recomputation, and backward propagation.

During the forward pass, HyScale projects queries and indexer queries, obtains globally available indexer keys through context-parallel communication, runs HyTopK, recovers failed queries when necessary, stores the exact selected index set, and executes sparse attention over the selected entries. Saved indices may be asynchronously offloaded to pinned host memory.

During recomputation, HyScale restores the saved indices, gathers and scores only the selected entries, and reruns sparse attention over the same selection. It does not rescore all candidate keys or reconstruct the full score table.

During backward propagation, sparse attention is differentiated only over selected entries, while the indexer loss is differentiated only through selected scores. Context-parallel reduce-scatter operations handle the relevant gradients.

The system includes several complementary mechanisms:

  • HyTopK: fused, on-the-fly candidate scoring and exact top-kk selection without score-table materialization.
  • Selection replay: reuse of forward-pass indices during recomputation.
  • Decoupled context-parallel communication: separate scheduling and overlap of indexer-key and KV-state transfers.
  • Locality-aware sparse kernels: joint processing of adjacent queries with overlapping selections.
  • Cached layouts and boundaries: reuse of context-parallel layouts and sequence boundaries.
  • Fused elementwise kernels: fusion of operations including KL-loss computation, normalization, and RoPE.
  • Permutation-free KV gathering: direct indexing into gathered layouts without explicit permutation.
  • Recovery and determinism mechanisms: GPU-resident exact recovery and deterministic tie handling.

The paper reports an implementation comprising approximately 3.4K lines of Python and 14.7K lines of CUDA, Triton, and CuTe GPU code (Deng et al., 23 Oct 2026).

3. HyTopK on-the-fly exact selection

HyTopK computes exact top-kk results while scanning candidates, retaining only candidates likely to belong to the final result. Its principal objective is to eliminate the score-table write/read path rather than to eliminate the underlying candidate-scoring computation.

For query tt, let LtL_t denote the number of candidate entries. HyTopK samples its own context using

M=min⁡(max⁡(4096,Lt128),8192).M= \min\left( \max\left(4096,\frac{L_t}{128}\right), 8192 \right).

The samples are evenly strided through the query’s context. Several consecutive queries may share samples and score them jointly through matrix multiplication. HyTopK estimates a threshold from approximately three times as many candidates as ultimately required. The threshold is the

⌈3kMLt⌉\left\lceil \frac{3kM}{L_t}\right\rceil

-th best sampled score.

This threshold is intentionally optimistic: it is not guaranteed to be a lower bound on the true kk-th score. During the full scan, scores above the threshold are retained in a bounded per-query candidate buffer, while other scores are discarded immediately. Exact top-kk is then applied to the retained candidates.

The operational sequence is:

  1. Sample evenly spaced keys from the query’s context.
  2. Compute sample scores.
  3. Estimate an optimistic threshold.
  4. Scan all candidate keys in tiles.
  5. Compute scores for each tile.
  6. Retain only scores exceeding the threshold.
  7. Discard nonpassing scores.
  8. Apply exact top-kk to the candidate buffer.
  9. Recover queries whose buffers overflow or contain fewer than kk candidates.
  10. Resolve ties deterministically and return the selected indices.

The dense score table has storage complexity O(nL)O(nL). HyTopK replaces it with bounded candidate storage, approximately O(nB)O(nB) for candidate-buffer capacity BB, together with O(nk)O(nk) output storage. The arithmetic required to score every candidate remains asymptotically O(nLHIdI)O(nLH_Id_I) for a dense indexer. Thus, HyTopK’s principal savings arise from eliminating dense score-table traffic, avoiding a separate full-table top-kk pass, and reducing memory-driven query chunking.

Exact recovery

A query is marked as failed when too many candidates pass the threshold and the bounded buffer overflows, or when fewer than kk candidates survive. A GPU-side check kernel records failed queries. Recovery launches GPU kernels that rescore each failed query over its entire context and perform exact top-kk.

The optimized recovery path processes up to 64 failed queries without host synchronization. If more than 64 queries fail, HyScale falls back to rescoring all queries. The paper reports that no training run encountered more than 64 failed queries. Consequently, the normal path uses approximate threshold filtering only as an intermediate mechanism; the final top-kk result is exact because failures are recomputed densely.

Deterministic selection

Atomic candidate writes can produce nondeterministic candidate ordering. HyScale restores deterministic behavior by retaining the smallest positions when multiple entries tie at the kk-th score and by radix-sorting the final selected entries using position as a tie-breaker. The selected set and sparse-attention accumulation order are thereby made deterministic under the stated implementation assumptions.

Deterministic sorting adds 0.8% to base HyTopK selection time. On one H20 GPU, HyTopK requires approximately 1.5–1.9 GiB per layer, nearly independent of context length. Megatron-LM with a 1-GiB score-table limit requires approximately 3.1 GiB and is 1.22–1.71 times slower, while full score-table execution can use 12–48 GiB and be 3–10% slower than HyTopK. Recovery overhead is 1.8% for one failed query and 4.3% for 64 failed queries (Deng et al., 23 Oct 2026).

4. Selection replay and recomputation

Selection replay exploits the fact that top-kk selection is nondifferentiable and that the indexer loss has nonzero score gradients only at selected entries. If gt,sg_{t,s} denotes the gradient with respect to score It,sI_{t,s}, then

gt,s={λ(p^t,s−pt,s),s∈Tt,0,s∉Tt.g_{t,s} = \begin{cases} \lambda(\hat p_{t,s}-p_{t,s}), & s\in T_t,\\ 0, & s\notin T_t. \end{cases}

For DSA, with

zt,h,s=(qt,hI)⊤ksI,z_{t,h,s}=(q_{t,h}^I)^\top k_s^I,

and

δt,h,s=gt,swt,h1[zt,h,s>0],\delta_{t,h,s} = g_{t,s}w_{t,h}\mathbf{1}[z_{t,h,s}>0],

the gradients with respect to indexer parameters and inputs involve sums only over s∈Tts\in T_t. Sparse-attention gradients are similarly restricted to selected entries.

Index replay

The default replay policy stores the selected indices but not the selected scores.

During forward execution:

  1. HyTopK computes TtT_t.
  2. HyScale stores the kk selected indices for every query.
  3. Sparse attention executes over TtT_t.
  4. The indices may be copied to pinned host memory asynchronously.

During recomputation:

  1. HyScale restores TtT_t.
  2. It gathers only the selected indexer keys.
  3. It recomputes the kk selected scores.
  4. It reruns sparse attention over the same TtT_t.
  5. Backward propagation proceeds over the selected entries.

Selection recomputation is reduced from approximately

O(nLHIdI+nL)O(nLH_Id_I+nL)

to

O(nkHIdI),O(nkH_Id_I),

apart from gather and indexing overhead.

The paper also describes score replay, which stores both selected indices and selected scores. Score replay eliminates selected-entry rescoring during recomputation but requires more memory. Index replay is the default because its recomputation cost is at most 1.6% of a training step in the GLM-5.1 setting and saves approximately 5 GiB per GPU relative to score replay.

For one layer, the reported memory and recomputation trade-offs are:

Policy Extra memory Recomputed work
Full recomputation $0$ 2nLHIdI+nL2nLH_Id_I+nL
Keep scores $4nL$ nLnL
Keep top-kk indices $4nk$ 2nLHIdI+nL2nLH_Id_I+nL
Keep indexer inputs 2LdI+2nHIdI2Ld_I+2nH_Id_I 2nLHIdI+nL2nLH_Id_I+nL
Index replay $4nk$ 2nkHIdI2nkH_Id_I
Score replay $8nk$ $0$

Replay indices can be transferred to pinned host memory after selection and transferred back during recomputation. The transfers are overlapped with sparse attention and query projections, respectively. The paper reports nearly zero observed overhead for this offloading.

Selection replay is exact provided that the layer input is unchanged between forward execution and recomputation, selection is deterministic, top-kk is nondifferentiable, and gradients are required only for selected entries. The method would require reconsideration for differentiable selection relaxations, stochastic selection whose randomness is not replayed, losses depending directly on unselected scores, or deliberately numerically different recomputation inputs (Deng et al., 23 Oct 2026).

5. Distributed communication and sparse-kernel optimizations

HyTopK and selection replay expose communication and sparse-kernel costs that would otherwise limit end-to-end gains. HyScale therefore optimizes context-parallel execution and sparse attention itself.

Context-parallel overlap

Under context parallelism, each GPU owns approximately n=L/Pn=L/P queries but requires all indexer keys for selection and all KV states for sparse attention. HyScale transfers these dependencies separately.

During forward and recomputation, indexer-key all-gather overlaps query projections, while KV-state all-gather overlaps query projections and selection. Each transfer is waited on only immediately before its first consumer. During backward, KV-gradient reduce-scatter overlaps indexer backward, and indexer-key-gradient reduce-scatter overlaps query-projection backward.

The paper reports that exposed context-parallel transfer in Megatron-LM increases by 4.8 times from 256K to one million tokens in the GLM-5.1 profile. Ring Attention is not directly suitable because sparse attention performs too little computation per transferred block to hide communication. Ulysses-style head partitioning also provides insufficient benefit for DSA because all heads share the same KV latent and indexer key.

Locality-aware sparse kernels

Adjacent queries often select overlapping entries. In a subset of GLM-5.1 layers, adjacent-query top-2048 selections exhibit 71% average overlap, with their union only approximately 1.29 times the size of one selection.

Instead of assigning one thread block to one query, HyScale processes two adjacent queries jointly:

  1. Construct the union of their selected keys.
  2. Load each union entry once.
  3. Mask accesses so each query consumes only its own selected entries.
  4. Combine gradients for shared keys during backward.
  5. Issue one atomic update for shared destinations.

The union is organized into entries selected only by the first query, entries shared by both, and entries selected only by the second query. This reduces memory traffic and atomic operations at the cost of masked computation.

In the baseline at 512K tokens on H800, L2 utilization is reported as 53–65%, memory stalls consume 40–44% of warp cycles, and tensor-core utilization is 21–32%. These measurements motivate reducing repeated key/value loads and sparse-gradient atomics.

Additional optimizations

HyScale caches context-parallel layouts once per microbatch rather than rebuilding them for every layer and pass. It also caches sequence boundaries used by RoPE, fuses elementwise operations including KL-loss calculations and normalization, and avoids permutation of gathered KV states by modifying indices to address the gathered layout directly.

Accelerating attention also reduces pipeline idle time. In the one-million-token GLM-5.1 profile, HyScale reduces pipeline wait from 106.6 seconds to 51.7 seconds (Deng et al., 23 Oct 2026).

6. Supported learned sparse-attention layers and evaluation

HyScale operates at the interface between candidate scoring, top-kk selection, and sparse attention. It therefore supports token-level and block-level learned sparse-attention mechanisms.

GLM-5.1 and DSA use token-level learned selection. Each candidate is an earlier token, the indexer uses DSA-style scores, sparse attention uses MLA-like latent KV states, and HyScale stores token indices.

DeepSeek-V4-Flash and CSA select compressed blocks, with each entry representing four tokens. HyScale applies HyTopK to block-level scores and replays selected block indices and scores.

Qwen3.8-Flash-Next and QSA select mean-pooled blocks of four tokens. The same on-the-fly selection and replay interface applies. Because block-level mechanisms score fewer entries per query than token-level DSA, selection constitutes a smaller fraction of total work and the corresponding speedups are lower.

The primary experimental systems are:

  • an H20 cluster with eight 96-GB H20 GPUs per node, two 96-core AMD EPYC 9K84 CPUs, 2.2 TiB DRAM, and eight 400 Gb/s RoCE NICs;
  • an H800 cluster with eight 80-GB H800 GPUs per node, two 48-core Intel Xeon Platinum 8476C CPUs, 2 TiB DRAM, and eight 400 Gb/s RoCE NICs.

The baseline is Megatron-LM using Megatron Core 0.19.2 and the cuDNN DSA backend. Both systems use BF16, zigzag all-gather context parallelism, and full activation recomputation unless otherwise stated.

GLM-5.1 training

The GLM-5.1 experiment uses released model weights, a global batch of 4M tokens, 8K tokens per GPU, one sequence per sample, balanced MoE routing, momentum-free SGD, and the Megatron-LM distributed optimizer. The reported speedups over Megatron-LM are:

Context length Speedup
256K 1.23×1.23\times
512K 1.44×1.44\times
1M 2.07×2.07\times

From 256K to one million tokens, HyScale’s step time increases by only 1.27 times, compared with 2.13 times for Megatron-LM. HyScale MFU rises from 20.9% to 27.8%, while Megatron-LM MFU falls from 17.1% to 13.5%. Peak memory is approximately the same; without replay-index offloading, HyScale would use at most 11% more memory.

At one million tokens, HyTopK reduces forward selection time from 35.9 seconds to 20.8 seconds, and selection replay reduces recomputed selection time from 37.0 seconds to 1.0 second. Pipeline wait falls from 106.6 seconds to 51.7 seconds.

Ablation at one million tokens and 128 GPUs attributes 37% of Megatron-LM layer-time savings to HyTopK, 18% to selection replay, and 11% to other implementation optimizations. The combined savings equal 66% of Megatron-LM layer time, with HyTopK and selection replay accounting for 84% of the total savings.

Context-parallel scaling

A single GLM-5.1 attention layer was benchmarked on 8–512 H20 GPUs. Up to 256 GPUs, doubling the GPU count reduces HyScale layer time by 1.65–1.96 times. Beyond 256 GPUs, the reduction falls to 1.18–1.54 times because too few queries remain on each GPU to hide communication.

At 256K context, HyScale’s advantage over Megatron-LM grows from 1.44×1.44\times to 11.7×11.7\times; at 512K, it grows from 1.79×1.79\times to 8.1×8.1\times. In a weak-scaling setting with 8M context and 16K queries per GPU, HyScale’s layer time grows only 11 times from 128K, compared with 190 times for Megatron-LM, producing a 22.3×22.3\times speedup at 8M context. At 4M context with 8K queries per GPU, the speedup is 11.2×11.2\times. These extreme scaling results concern a single attention layer rather than full-model training.

CSA and QSA

On 32 H800 GPUs at one million tokens, HyScale reports:

  • a 2.01×2.01\times speedup for DeepSeek-V4-Flash CSA layers;
  • a 1.57×1.57\times speedup for Qwen3.8-Flash-Next QSA layers.

The lower gains relative to token-level DSA are attributed primarily to the smaller number of scored blocks.

7. Limitations, scope, and terminology

HyScale does not eliminate the fundamental candidate-scoring cost. HyTopK still scores all candidates in the normal path; its principal asymptotic benefit is the removal of dense score-table materialization, redundant top-kk processing, and selection recomputation. Its effectiveness also depends on optimistic threshold quality. Poor thresholds can enlarge candidate buffers or trigger exact recovery, although the evaluated workloads exhibit favorable failure rates.

The recovery path is optimized for up to 64 failed queries; larger failure counts trigger dense fallback. Selection locality is workload-dependent, so the two-query sparse-kernel optimization may provide smaller gains when neighboring queries share few selected entries. Context-parallel scaling also degrades when each GPU owns too few queries to hide communication.

Selection replay assumes deterministic top-kk selection and unchanged recomputation inputs. The reported numerical behavior depends on deterministic tie handling, sorting, sparse-attention accumulation order, and implementation-specific kernels. The evaluation is hardware- and model-specific, using H20 and H800 clusters, BF16, Megatron-LM, and the evaluated learned sparse-attention architectures. The supplied results establish exact selection and backward-computation behavior together with the reported training speedups, but do not provide extensive independent validation-loss, perplexity, or downstream-accuracy tables.

The name HyScale is not unique across research literature. “HyScale-GNN” denotes a different single-node heterogeneous CPU–GPU/FPGA GNN training system that uses CPU-memory-resident graphs, two-stage feature prefetching, and dynamic resource management (Lin et al., 2023). “H-Scale” denotes a different Hessian-guided NVFP4 per-group scale-refinement method for LLM post-training quantization (Yu et al., 28 Aug 2026). An ASE-based hybrid atomistic simulation framework described as MultiASE is technically related only by functionality and is not named HyScale (Leukkunen et al., 2012). Similarly, “EasyScale” is an elastic distributed-training system for accuracy-consistent DDP execution, not HyScale (Li et al., 2022). These systems should not be conflated with the learned sparse-attention training system described here.

HyScale’s central contribution is the separation of discrete selection from dense activation computation. HyTopK exploits this separation during forward execution by filtering candidates without writing a full score table, while selection replay exploits it during recomputation by retaining and reusing indices. Communication overlap, locality-aware sparse kernels, deterministic recovery, and memory offloading extend those savings to distributed long-context training. Within the evaluated million-token workloads, this design converts selection from a dominant memory- and recomputation-intensive operation into a bounded-index production pipeline while retaining exact top-kk semantics.

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to HyScale.