AMD's HyLo Turns Llama and Qwen Models Into Long-Context Hybrids
AMD researchers convert pretrained Llama and Qwen models into hybrids of attention and linear layers, cutting KV-cache memory by more than 90 percent and serving up to 2 million tokens.
TL;DR
- AMD's HyLo converts pretrained Llama and Qwen models into hybrids that keep few attention layers and cut KV-cache memory by over 90 percent [^1].
- The converted models stay usable at long range: on a 64K-token benchmark, HyLo reached 52.0, against 17.4 for the best earlier conversion tested [^1].
Background
In a Transformer, every attention layer stores keys and values for all earlier tokens, the KV cache, so memory grows with input length [^2]. Hybrid models such as Jamba replace many attention layers with Mamba layers and need far less cache: 4GB at 256K tokens, against 32GB for Mixtral [^2]. Mamba-style layers keep a fixed-size state instead of a growing cache [^1]. Most hybrids, though, are trained from scratch, which repeats the cost of building a Transformer [^1].
What happened
Researchers at AMD posted HyLo, short for "HYbrid LOng-context", on arXiv on April 27 [^1]. It is an upcycling recipe: it takes a pretrained Transformer and replaces its attention blocks with cheaper ones. A few become Multi-Head Latent Attention (MLA), which compresses the KV cache; the rest become linear blocks, either Mamba2 or Gated DeltaNet, which add no KV cache at all [^1]. The new blocks are initialized from the original weights. Training then runs in two stages. First, all-MLA and all-linear versions of the model learn to match the original layer by layer, on 20 percent of the data at a 2K context. Then the assembled hybrid is fine-tuned at 8K or 64K tokens while an 8B teacher model guides its outputs [^1].
Training at 64K was itself a memory problem. At that length, each logit tensor for the Llama-3 vocabulary takes about 16 GB, so naive distillation doesn't fit even on 80 GB GPUs [^1]. Fused kernels and activation checkpointing brought training with the 8B teacher down to 54.2 GiB, on 8 GPUs [^1]. The team also extended the vLLM inference engine to serve the mixed layer types [^1].
The recipe was applied to Llama-3.2-1B, Llama-3.2-3B and Qwen3-1.7B [^1]. On RULER, a long-context test suite, the converted models held up where earlier conversions collapsed. At 64K tokens, the best 3B HyLo variant scored 52.0, against 4.2 for Zebra-Llama, the recipe HyLo builds on, and 17.4 for M1 [^1]. A 1B variant that keeps 3.9 percent of the original KV cache scored 37.9, where the comparable Zebra-Llama model scored 0.1 [^1]. On 8 AMD MI300X GPUs, HyLo served contexts up to 2 million tokens, while Llama-3.2-3B ran out of memory beyond 64K [^1]. The authors also report that HyLo-Qwen, trained on only 10B tokens, beat Jet-Nemotron-2B, a hybrid trained from scratch, on GSM8K, common-sense reasoning and RULER at 64K, where one variant scored 33.1 against 14.1 [^1].
Why it matters
The paper's argument is that cheaper long-context models don't have to start from zero. Earlier upcycling work, the authors say, focused on short-context scores and left open whether converted hybrids inherit long-context ability; HyLo makes that a core goal [^1]. The results suggest it has to be trained for explicitly. A 1B model trained at 8K scored 0.5 on RULER at 64K; stretching its context with the YaRN method raised that to 31.3, and training directly at 64K did better still [^1]. The teacher mattered more for long inputs than for short ones: with the 8B teacher, the 1B model gained 6 percent on short-context reasoning but 22 percent on RULER at 64K [^1].
There are trade-offs. Long-context training costs some short-context quality, which the authors call expected and small [^1]. Math can suffer more: for one 1B Llama variant, GSM8K fell from 49.2 after 8K training to 33.0 after 64K training [^1]. The models tested are small, 1B to 3B. And speed is mixed: the original Llama 3B decodes each token faster at 8K to 32K tokens. HyLo's advantage is that its per-token time stays flat up to 64K, while Llama's grows until it runs out of memory at 128K [^1].
Practical example
Say Tomasz runs the ML platform at a legal-tech startup that serves Llama-3.2-3B for contract review on a node with eight AMD MI300X GPUs. Customers want to upload whole case files, well over 64K tokens. That is where the stock model fails: in AMD's tests, Llama-3.2-3B ran out of memory beyond 64K, because each of its 28 attention layers keeps a full KV cache [^1].
Training a hybrid from scratch is out of budget. With a recipe like HyLo, Tomasz's team keeps the existing weights and converts most attention layers into Mamba2 layers, leaving a handful as MLA. In AMD's 3B configuration with 6 MLA and 22 Mamba2 layers, the model keeps 2.0 percent of the original KV cache [^1]. The team runs both training stages and ends at 64K tokens with a larger teacher model, since that gave the best long-context results [^1].
The payoff: AMD's version of that configuration ran prefill and decoding up to 2 million tokens on the same kind of node [^1]. The catch is short inputs. Before switching, Tomasz reruns the team's own short-document and math tests, because 64K training cost the converted models some short-context accuracy, in some cases a lot of GSM8K accuracy, and the original model decoded faster at 8K to 32K tokens [^1].
Related gear
We recommend this book because it builds a Transformer language model step by step, including the attention layers whose memory cost HyLo is designed to cut.