HSTU: The First Exploration of the Scaling Law
π Before You Continue: Make sure you first have the discriminative ranking background from 3.1 Wide & Deep. This chapter repeatedly contrasts "traditional DLRM scoring each candidate independently" with "generative sequence modeling" β understanding the bottlenecks of the former is what makes HSTU's motivation click. We also recommend reading 6.1 Generative Recommendation Paradigm first for background on semantic IDs and generative retrieval.
Over the past decade, deep learning has scaled relentlessly in CV and NLP: ResNet pushed network depth beyond a thousand layers, Transformer parameter counts exceeded a trillion, and astonishing intelligent behavior emerged. Behind them all lies a common pattern β as long as the architecture is right, model performance keeps improving as compute, data, and parameters grow, following a predictable power law. This is the famous Scaling Law.
Recommendation systems, however, have long been the counterexample. Industry invested heavily in carefully designing thousands of features, building sophisticated DLRM architectures, and processing billions of users' data every day β yet performance hit a ceiling quickly. More parameters and bigger data often bought marginal or even zero gains. Where does the problem come from? This chapter walks you from the three bottlenecks of traditional DLRMs to the full story of Meta validating, with HSTU, that "recommendation can scale too".
After reading this chapter, you will be able to:
- Name the three fundamental limitations that keep traditional DLRMs (Deep Learning Recommendation Models) from scaling
- Explain how Generative Recommenders (GR) model behavior history as a "language" and achieve
user-levelsequence training - Describe HSTU's three architectural innovations for recommendation (Pointwise Aggregation, relative time bias, gated feed-forward)
- Explain how Stochastic Length and M-FALCON solve the engineering challenges of ultra-long-sequence training and multi-candidate inference respectively
- Recount the experimental conclusion of the recommendation Scaling Law, , and understand its implications for recommendation foundation models
- Work through 4 tiered practice problems that consolidate the full chain from paradigm to engineering
7.1.0 Three Fundamental Limitations of Traditional DLRMs
To understand why HSTU is a breakthrough, you first need to see clearly what it broke through. Traditional DLRMs are extremely mature in recommendation performance, yet they carry three structural flaws that defeat scaling:
First, the feature bottleneck. DLRMs rely on hand-crafted numerical features (CTR, average watch time, and other statistical features) to compress historical information. As model capacity grows, these pre-aggregated features become an information bottleneck β model capability rises, but the richness of the input information does not.
Second, architectural fragmentation. A DLRM is assembled from heterogeneous modules such as FM, DCN, DIN, and MMoE, each optimized for a specific kind of interaction. Scaling up one module's capacity usually yields only local improvement, not systemic gains.
Finally, the training paradigm limitation. Traditional DLRMs use item-level modeling: they compute an independent score for each candidate, and each training sample corresponds to a single triple. This means each training pass extracts only one supervision signal per interaction, compute cost grows linearly with the number of candidates, and the independent scoring mechanism cannot capture dependencies between candidates.
π‘ Key Insight: These three limitations compound to flatten the traditional DLRM's "compute growth curve". Breaking through requires not engineering patches but a paradigm shift.
7.1.1 The Paradigm Shift: From Item Sequences to Behavior Sequences
The Meta team arrived at a key insight: what happens if we treat a user's behavior history as a special kind of "language"?
In NLP, the success of language models such as GPT rests on a clean and powerful paradigm: given the preceding tokens , autoregressively predict the next word . The unified sequence representation encodes all information into a token sequence; autoregressive training yields multiple supervision signals per sample; and the Transformer provides strong sequence modeling capability and parameter efficiency.
But recommendation is not a copy-paste of language modeling. GRU4Rec and SASRec had long modeled user interaction history as sequences, yet they focused only on the item sequence , predicting the next item , while ignoring the single most crucial piece of information in recommender systems β the user's behavioral feedback.
The Generative Recommender (GR) paradigm proposed by Meta treats recommendation as two intertwined stochastic processes: the system presents content , and the user produces a behavioral feedback (click, like, watch time, and so on). The full data flow is an alternating contentβaction sequence:
This deceptively small change has far-reaching effects. What gets modeled is no longer but the full joint distribution . Applying the chain rule of probability immediately reveals two core tasks:
- The ranking task corresponds to β given the user's history and the current candidate , predict what behavior the user will produce. Note this is target-aware: the model sees the candidate first, then predicts the behavior.
- The retrieval task corresponds to β given historical interactions, predict the next item to recommend, which is closer to traditional sequential recommendation.
π§ Mental Model: Recommendation as a "Diary"
A traditional DLRM scores each event independently: "Xiaoming rates video A 0.8, video B 0.6". GR instead writes recommendation as a diary: "watched tech blogger A (liked) β watched food blogger B (saved) β ...". By reading the whole diary, the model can predict "what you will do next, what you want to watch" β and every sentence it reads delivers another supervision signal.
7.1.2 Unifying the Heterogeneous Feature Space
Traditional DLRM features are highly heterogeneous and fragmented: categorical (sparse) features such as user ID, item ID, and creator ID can have cardinalities in the billions; numerical (dense) features such as CTR and average watch time are carefully engineered aggregate statistics. They pass through different modules β embedding lookups, feature crossing, MLPs β and are then concatenated.
GR needs clever design to unify these heterogeneous features into a sequence. For categorical features, the core idea is timeline alignment with compressed merging:
- Identify the "main timeline" that changes most frequently (usually the user's interaction history).
- For slowly changing features (following list, city, etc.), apply segment compression: keep only the first occurrence of each run of identical values. For example, compress
[Zhang,Zhang,Zhang,Li,Li,Wang,...]to[Zhang,Li,Wang]. - Merge the compressed sequences onto the main timeline by timestamp to obtain a unified categorical feature sequence.
For numerical features, the insight goes deeper: they are usually aggregate statistics over categorical features ("CTR on tech topics" is essentially a statistic over "click behaviors on tech items in the history"), and the underlying signals already live in the categorical sequence. This means if the sequence model is strong enough and the sequence long enough, it can in principle learn these aggregated features from the raw sequence automatically β trading model capacity for feature engineering.
Formally, the traditional DLRM feature space is , while GR unifies it as . As sequence length : .
Left: DLRM routes sparse/dense features into different modules, and information stays isolated before concatenation; right: GR encodes all information into a single unified sequence, learned end-to-end by one Transformer.
β οΈ Warning: Fully giving up numerical features is not free. The paper's ablation shows that when the DLRM baseline is also configured as "categorical-only", performance drops significantly. This means in low-compute settings, carefully engineered numerical features still carry value. GR's advantage is learning these signals automatically with larger capacity and longer sequences β a trade of compute for feature engineering.
7.1.3 The Leap in Training Efficiency
The unified sequence representation brings not only modeling advantages β it fundamentally changes the computational complexity of training.
Traditional DLRM: each sample corresponds to one interaction and requires one forward pass. With interactions, you need forward passes, for a total compute cost of .
Under GR, a user sequence has total length . In autoregressive training it provides supervision signals (predict after position 0, predict after position 2, ...). The key point: these predictions are completed in parallel within a single forward pass.
The Transformer's causal mask (lower-triangular mask) ensures position can only see positions through ; one forward pass implicitly encodes all prefixes, and the position after each content token is used to predict the corresponding behavior, all sharing the intermediate results of that same forward pass.
Total compute drops from to β a training efficiency gain of roughly times. With an average of 500 historical interactions per user, that is a 500x speedup. This means with the same compute budget, you can train models one to two orders of magnitude more complex.
π‘ Key Insight: This is the first key factor behind GR breaking the scaling bottleneck β it provides enough computational headroom to try deeper networks and larger capacities. But it is not enough on its own; you also need an efficient architecture purpose-built for recommendation.
7.1.4 The HSTU Architecture: A Sequence Model Optimized for Recommendation
Can we just use a standard Transformer? It is proven in NLP, but recommendation has its own peculiarities. Meta's HSTU (Hierarchical Sequential Transduction Unit) introduces three key architectural innovations.
Innovation 1: Pointwise Aggregation Replaces Softmax Attention
Standard Transformer: . Softmax normalization forces attention weights to sum to 1, so what is learned is the relative importance of historical tokens.
But in recommendation we need to know not only "which history matters" but also "how much it matters". For example: user A clicks 10 tech items and 1 entertainment item; user B clicks 100 tech items and 10 entertainment items. Under softmax, both distributions may come out 90%/10% β erasing the information that user B's absolute intensity of interest in tech is higher.
HSTU replaces softmax with pointwise aggregation:
where is the SiLU activation (Swish), is a relative attention bias, and is element-wise multiplication. The full output: , where is a gated projection. The key point is that SiLU maps similarity to a continuous value range but performs no global normalization: each position's weight is independent, and the summed weights can exceed 1 β so the model can learn the absolute intensity of "this user's interest in this type of content is very strong".
Innovation 2: Redesigning Relative Position Encoding
The temporal characteristics of recommendation sequences differ fundamentally from language sequences: language positions are discrete and uniform (words 3 and 5 are always distance 2 apart); recommendation time is continuous and uneven (two interactions may be seconds or months apart).
HSTU introduces an enhanced relative position bias that considers not only the position difference but also the actual time difference , and distinguishes token types (content / action ):
This lets the model learn: recent behaviors matter more, certain behaviors decay faster (browsing vs liking), and the relationship between content tokens and action tokens differs from that between content tokens.
Innovation 3: Simplified Feed-Forward Network and Gating
The standard Transformer appends a two-layer FFN after attention (with the intermediate dimension 4x the hidden size), which consumes most of the parameters and compute. HSTU, inspired by GLU variants, replaces the explicit FFN with element-wise gating:
The gate function is a lightweight transformation. The benefits: (1) it avoids the 4x-hidden FFN, reducing parameters and compute; (2) it cuts activation memory. The latter matters enormously in industry β with very large batch sizes (tens of thousands to hundreds of thousands), activation memory is often the bottleneck. HSTU reduces per-layer activation memory from 33x the hidden dimension in a standard Transformer to 14x, enabling deeper networks under the same memory budget.
π Note: The "Hierarchical" in HSTU's name refers to representing ultra-high-cardinality categorical features with hierarchical tokens (e.g., splitting an item ID into multiple sub-tokens). Follow-up research found that a flat representation suffices in most scenarios; the real value lies in the three architectural innovations above.
One HSTU Block: after Query/Key/Value projections, element-wise SiLU aggregation (not softmax normalization) with relative time bias is applied, and a gated projection performs the residual fusion.
Analysis: All three HSTU innovations revolve around "the peculiarities of recommendation" β absolute interest intensity (pointwise), non-uniform time (rab), and large-batch memory (gated FFN). Compared with directly applying a standard Transformer, it improves both efficiency and effectiveness, and it is the engineering foundation that makes deploying trillion-parameter models possible.
The interactive demo below lets you see intuitively how HSTU transforms "behavior history" step by step into "behavior prediction": interleaved sequence organization β causal mask β pointwise aggregation β target-aware prediction at candidate positions β multiple supervision signals from one forward pass.
Click "Next" or "Autoplay" and observe how the sequence changes at each step, and why this delivers the leap in training efficiency.
7.1.5 Engineering Optimizations for Training and Inference
With an efficient architecture in hand, ultra-long-sequence training and multi-candidate inference remain hard. HSTU cracks each with an engineering innovation.
Stochastic Length: Exploiting Multi-Scale Redundancy in Behavior
Self-attention complexity is , which becomes unbearable when sequences run to thousands or tens of thousands. But user behavior has repeating patterns at different time scales: long-term stable preferences, mid-term interest evolution, and short-term contextual needs. Based on this observation, HSTU proposes Stochastic Length: for a sequence of length , do not always use the full sequence; instead, with a certain probability randomly truncate to a shorter subsequence.
Concretely, if exceeds a threshold , sample a subsequence of length with probability ; otherwise use the full sequence. controls truncation aggressiveness: smaller (e.g., 1.6β1.7) truncates more aggressively and trains faster; degenerates to no truncation. Subsequence sampling is feature-weighted to ensure coverage across time scales.
This brings a double benefit: (1) self-attention complexity drops from to , sequence sparsity can reach 80%+, and training speeds up several-fold; (2) the random subsequences act as regularization, similar to dropout, forcing the model to learn more robust representations β and generalization actually improves. Experiments show almost no negative impact on quality across a wide range of .
M-FALCON: An Inference Algorithm with Global Cost Amortization
Inference latency is equally critical. Ranking must score hundreds or thousands of candidates one by one; the naive approach needs forward passes with total compute , and the accumulated latency is unacceptable. HSTU's M-FALCON (Microbatched-Fast Attention Leveraging Cacheable OperatioNs) solves it with three escalating optimizations:
Layer 1: Batched Inference β concatenate candidates together and modify the attention mask so candidates cannot see each other (candidate can only attend to the user's history). Now the scores for candidates are computed in parallel in a single forward pass. Setting (full batch), complexity drops to , eliminating the linear dependence on .
Layer 2: Microbatching β when is very large, makes too big. Split the candidates into microbatches (e.g., with on the same order as ) to find the sweet spot between "fully parallel" and "fully serial".
Layer 3: KV Caching β microbatching unlocks KV caching across microbatches: the user-history portion of is identical across all microbatches, so the first microbatch computes the full and subsequent ones only compute the of the new candidates. Later microbatches' complexity drops to , a x speedup. The KV cache can also be reused across requests (the same user refreshing several times within a short window).
Combined: batched inference brings a tens-of-times speedup, microbatching + KV caching another x β up to hundreds of times overall, letting you use models hundreds of times more complex under the same latency budget.
Analysis: M-FALCON is the engineering cornerstone that lets HSTU deploy trillion-parameter models. It decouples "history representation computation" from the candidate count β the user side is computed only once per request β and this is precisely the origin of the Cross-Request KV Caching idea in OneTrans later in 7.5.
7.1.6 The Scaling Law for Recommender Systems
With all the technical building blocks in place, we return to the original question: can recommendation models keep scaling like language models?
Meta ran systematic scaling experiments: sequence length from 512 to 8192, hidden dimension from 256 to 1024, depth from a few layers to 24. Because recommendation trains in a streaming fashion, training compute was normalized to 365 days to allow fair comparison with GPT-3 and LLaMA-2. Metrics were Hit Rate@100/@500 for retrieval and Normalized Entropy for ranking (lower is better).
Plotted on log axes, all metrics show a clean power-law relationship:
where is the performance metric, is total training compute (PetaFLOPs/day), and are fitted parameters. The fitted results:
- Retrieval:
- Ranking:
That is, for every 10x increase in compute (one order of magnitude), HR@100 improves by about 4.5 percentage points and NE drops by about 1.2 percentage points. More striking still, this relationship holds stably across three orders of magnitude of compute.
Left: the ranking NE metric keeps decreasing with compute; right: retrieval HR@100 keeps increasing with compute. Both curves are stable across three orders of magnitude, isomorphic to the LLM Scaling Law.
The implications run deep: (1) this is the first proof of a Scaling Law for recommendation models β recommendation is no longer deep learning's exception; (2) small-scale experiments can predict large-scale performance, providing direction for R&D while reducing blind effort and carbon emissions; (3) it opens the door to recommendation Foundation Models β pretrain a large model, then fine-tune across scenarios. The largest configuration (8192 sequence, 1024 dimensions, 24 layers) reached 1.5 trillion parameters and was successfully deployed across multiple Meta surfaces serving billions of users, with online A/B ranking metric gains in the double-digit percentage range.
The interactive curves below let you verify the Scaling Law yourself: drag the slider to adjust training compute and watch Hit Rate@100 and Normalized Entropy move along the power-law curve; you can also click "Next" to walk through several key milestones from small scale to trillion-parameter deployment.
Each 10x increase in compute moves HR@100 up about +4.5pp and NE down about β1.2pp β this predictability is the fundamental guarantee that recommendation models can scale like LLMs.
7.1.7 Why Could HSTU Break Through?
Looking back at the whole technical system, four levels of innovation support one another:
- The paradigm shift is the foundation β moving from item-level to user-level, from independent scoring to sequence generation, unbinding compute cost from candidate count's linear coupling.
- Architectural innovation is the key β attention, position encoding, and the feed-forward network were each purposefully designed, yielding significant gains over directly applying a standard Transformer.
- Engineering optimization is the guarantee β Stochastic Length makes ultra-long-sequence training feasible, M-FALCON makes complex-model inference efficient, and activation memory optimization makes large batches a non-issue.
- The unified feature space is the base β heterogeneous features enter a unified sequence, simplifying feature engineering and, more importantly, letting the model learn complex interactions end-to-end with higher parameter efficiency.
All four are indispensable. HSTU's success proved recommendation models can scale β and left new questions behind: which factors are truly essential? Is fully generative training necessary? How do we generalize to multi-task, multi-surface settings? Later research answers these β starting with GenRank in 7.2, which asks "is the autoregressive mechanism really the essence?"
β οΈ Common Mistakes in 7.1
| # | Mistake | Example | Why It's Wrong | Fix |
|---|---|---|---|---|
| 1 | Assuming recommendation inherently cannot scale | "Adding parameters to a DLRM is useless; recommendation is just the exception" | It is not that recommendation cannot scale; the item-level paradigm + fragmented architecture tie its hands computationally | Understand how HSTU's user-level sequences unbind it |
| 2 | Treating GR as ordinary sequential recommendation | "GR is just SASRec with longer sequences" | GR models contentβaction interleaved sequences and predicts behaviors in a target-aware way | Distinguish item sequences from behavior sequences |
| 3 | Assuming softmax attention is good enough | "Just use a standard Transformer as HSTU" | Softmax normalization erases the absolute intensity of interest | Remember the key difference of pointwise aggregation |
| 4 | Overlooking where the training efficiency comes from | "Sequence modeling just performs better" | One forward pass yields supervision signals, speeding training up times | Understand the compute dividend of user-level aggregation |
| 5 | Assuming the Scaling Law only holds for huge models | "Scaling only matters at a trillion parameters" | The power law holds across three orders of magnitude; small-scale experiments extrapolate | Use small experiments to predict large-scale performance |
Chapter Summary
π Key Takeaways
| Concept | Key Points | Why It Matters |
|---|---|---|
| Three DLRM limitations | Feature bottleneck / architectural fragmentation / item-level training | Explains why recommendation long failed to scale |
| GR paradigm | interleaved sequence, user-level autoregression | Unified sequence + multiple supervision signals, x training speedup |
| Three HSTU innovations | Pointwise Agg / relative time bias / gated FFN | A sequence architecture tailored to recommendation |
| Stochastic Length | Random truncation of ultra-long sequences | Several-fold training speedup + regularization |
| M-FALCON | BatchedβMicrobatchβKV Cache | Hundreds-of-times inference speedup, trillion parameters deployable |
| Scaling Law | , stable across three orders of magnitude | First proof recommendation can scale; opens the door to foundation models |
β FAQ
Q1: Why is Pointwise Aggregation better suited to recommendation than Softmax?
A: Softmax forces weights to sum to 1 and learns only "relative importance"; recommendation also needs "absolute intensity" (user B likes tech more than user A does). SiLU element-wise aggregation does no global normalization, weights can accumulate beyond 1, and absolute interest intensity is preserved β which is crucial for predicting post-click deep behaviors.
Q2: Why is GR training so much faster than DLRM?
A: A DLRM does one forward pass per interaction β samples means forward passes. GR predicts behaviors for a user sequence in one forward pass (sharing computation under the causal mask), so total forward passes drop to , roughly an x speedup.
Q3: Why are recommendation foundation models now plausible?
A: The Scaling Law proves performance improves predictably with compute, which means you can pretrain a large general recommendation model and fine-tune it across scenarios β the most exciting direction after HSTU's 1.5-trillion-parameter deployment.
π Connections to Later Chapters
- 7.2 (Generative Ranking / GenRank) asks whether autoregression is the essence and speeds things up further with Action-Oriented design β directly continuing this chapter's question of "which factors are essential".
- 7.3 (MTGR) retains cross features under a hybrid paradigm, answering "is fully generative training necessary?"
- 6.1β6.4 (generative fundamentals) provide the prerequisites of semantic IDs and RQ-VAE for understanding how items become tokens.
- 3.1β3.5 (discriminative ranking) are the "old paradigm" this chapter keeps contrasting against β see the bottlenecks clearly, and the breakthrough lands.
Practice Problems
Work through all problems in order β they get progressively harder. Each has a complete solution you can reveal after trying it yourself.
Problem 7.1.1 β Identifying the DLRM Bottleneck π’ Easy
A team doubles the DLRM's embedding dimension and deepens the MLP, yet online CTR-prediction AUC barely moves. Based on the three limitations in 7.1.0, identify the most likely cause (pick one and justify it).
π‘ Solution (click to reveal)
Approach: Judge from the angle of "more capacity β more information".
The most likely culprit is the feature bottleneck: the DLRM compresses history into pre-aggregated numerical features (CTR, average watch time), so model capacity grew but the richness of input information did not. Second is item-level training β each sample carries only one supervision signal, so added capacity does not increase the per-sample information. Architectural fragmentation is also possible (scaling one module only improves things locally).
Key points:
- A stalled compute growth curve usually means information or the paradigm is constrained, not that parameters are insufficient.
- This is precisely what leads to HSTU's user-level sequence solution.
Problem 7.1.2 β GR Sequence Organization π’ Easy
Traditional sequential recommendation models the item sequence , while HSTU's GR models . Answer:
- How many times the number of interactions is the GR sequence length (in tokens)?
- Is the ranking task target-aware or target-agnostic?
π‘ Solution (click to reveal)
Approach: Map directly to the definitions in the text.
- The GR sequence has total length (content and action alternating), which is 2 times .
- In the model sees candidate before predicting behavior , so it is target-aware.
Key points:
- The interleaved sequence trades length for behavioral feedback signals.
- Target-awareness is the foundation for later generative ranking to predict deep behaviors.
Problem 7.1.3 β Training Efficiency Multiple π‘ Medium
Suppose users average historical interactions and the training set has interaction records. Compare the order of magnitude of "forward passes" required by the DLRM (one per record) versus GR (organized into user sequences of length ). About how many times faster is GR?
π‘ Solution (click to reveal)
Approach: DLRM forward passes = . GR organizes the interactions into sequences, one forward pass each.
forward passes. The speedup is x.
Key points:
- The speedup ratio β average sequence length , because one forward pass yields supervision signals.
- This explains "with the same compute you can train models hundreds of times more complex".
Problem 7.1.4 β Extrapolating the Scaling Law π΄ Hard
Given retrieval HR@100 ( in PetaFLOPs/day). If compute grows from to (one order of magnitude), by how many percentage points does HR@100 improve? And why is this more controllable than "blindly stacking parameters"?
π‘ Solution (click to reveal)
Approach: Use the difference of logarithms.
. That is about 4.5 percentage points, consistent with the main text.
Key points:
- The Scaling Law gives a predictable power law, so small experiments can extrapolate to large-model performance.
- Compared with blindly stacking parameters (which may plateau), it turns R&D into a controlled engineering exercise of "planning performance against the compute budget".
π Challenge: Arguing a Design Trade-off
Suppose you lead a mid-sized company's recommendation team with only 1% of Meta's compute. Write an argument within 150 words: should you copy HSTU's trillion-parameter setup directly, or first do a lightweight landing based on its "paradigm shift + engineering optimization" ideas? Identify the two HSTU techniques most useful to you.
π‘ Hint
With limited compute, a trillion parameters is infeasible; but "user-level sequence training's x speedup" and "M-FALCON's KV caching/batching" are architecture dividends independent of compute scale, and the most worth borrowing. Stochastic Length's truncation also directly cuts training cost. The point is to carry over the paradigm dividend, not the parameter scale.