Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Spotify Engineering 7 min read Case study hardMaster

Advancing Generative Recommendation Inference: our collaboration with NVIDIA on TensorRT LLM

Spotify consolidated its LLM-based generative recommendation inference onto TensorRT LLM, working with NVIDIA to add the features it had been splitting across engines. vLLM handled beam search for semantic-ID candidate generation, but its beam search runs outside the core GPU engine and recomputes partially filled KV blocks. SGLang supplied multi-item candidate scoring, and personalization came from soft tokens that project existing user embeddings into the LLM's embedding space. The upstream additions were multi-sequence beam search, out-of-tree models for a custom Qwen3 soft-token plugin, embedding injection and multi-item scoring, which cut costs on Qwen3 1.7B by up to 54% for beam search and 7% for scoring.

Assumes: LLM inference enginesbeam search decodingKV cacheembedding-based recommenders

Related posts

  • Shopify’s generative discovery model

    Shopify Engineering hardMaster

    Shopify trained a single generative model, adapted from an open-weight LLM, that emits semantic-ID tokens to generate product candidates for both personalized search and recommendation across a catalog of billions. Products are tokenized with RQ-KMeans into three-token semantic IDs (three 8,192-entry codebooks). Training combines joint continued pretraining, upsampling of first-purchase discovery events, RL with an LLM relevance judge (+1.5 OneDCG@10) and multi-teacher distillation from task experts. For serving, LFM2-2.6B was chosen for its 25.5 ms p95, GPU trie-constrained decoding via STATIC cut constraint overhead from 50 ms to about 1 ms, and multi-token prediction replaces autoregressive decoding. In production the model lifted home-feed orders by 7.95% and search OneDCG@10 by 2.1 points.

  • Welcome Beam: a 501B open model you can own, customize, and scale

    Hugging Face hardMaster

    Beam is a 501B-parameter mixture-of-experts model from Reflection with 23B active parameters per token, a 1M-token context window, and an Apache 2.0 license, aimed at coding and agentic workloads. It interleaves 43 sliding-window RoPE layers with 9 global layers that use no positional encoding and scalable-softmax query scaling, which cuts KV-cache growth to 36 KiB per token (about 36 GiB at 1M context versus 208 GiB if every layer were global). Its 256-expert router follows DeepSeek-V3's group-limited scheme without a shared expert, and its residual stream uses depth-dependent weights that keep the stream at a constant scale. Practical guidance covers BF16, FP8 and NVFP4 checkpoints, hardware sizing (NVFP4 at ~280 GB on four B200s is recommended), transformers expert-parallel loading, and vLLM/SGLang serving with DFlash2 speculative decoding.

  • From Scoring to Spelling: Rebuilding Ads Retrieval at Instacart

    Instacart Tech hardMaster

    Instacart replaced its BERT-based ads retrieval model, which scored every atomic product ID in a fixed vocabulary, with a generative model that autoregressively decodes Semantic IDs (RQ-VAE codeword sequences) via beam search. The goal was to fix vocabulary bottlenecks, cold-start bias toward popular items, and incoherent candidate sets. Prompts combine a retailer-type token, user history SIDs and cart SIDs. SIDs shrink embedding parameters 125x and give new products coverage from day one, while beam width and temperature act as dials between precision and diversity. Serving moved from Python on CPU to a Go service on TensorRT-LLM and Triton. Mean latency dropped 10–17% despite roughly twice the candidates, and A/B tests showed +5% CTR and +34% add-to-carts.

  • Bypassing inference bottlenecks: Accelerating complex AI search with Retrieve-for-Train

    Google Research hardMaster

    Retrieve-for-Train replaces expensive inference-time LLM reasoning for query fan-out with a one-time offline RL stage. A 4B fan-out language model (Gemma3-4B or Qwen3-4B) is trained with Soft-GRPO on a composite set-level reward that combines groundedness to the database manifold, Vendi Score diversity and query alignment. The trained model then synthesizes query-to-target-set pairs, which are distilled into a 53.9M-parameter diffusion retriever that produces a whole slate of target embeddings in one non-autoregressive pass. On fashion (CLIP) and music playlist (MuLan) retrieval it beats zero-shot expansion and Best-of-N, with a 12–20x speedup, staying at sub-second to a few seconds where autoregressive fan-out reaches nearly 50 seconds. Ablations show that without the diversity term the policy reward-hacks into degenerate strings.

  • Assisted Generation: a new direction toward low-latency text generation

    Hugging Face mediumAdept

    Assisted generation cuts autoregressive LLM latency by letting a much smaller assistant model with the same tokenizer greedily draft candidate tokens, then verifying them all in a single forward pass of the large model. The large model keeps matching tokens plus the first divergent one. The draft length adapts: it grows by 2 when every candidate matches and shrinks by 1 otherwise. The approach exploits the fact that forward passes are memory-bandwidth bound. In 🤗 Transformers it is exposed through an `assistant_model` argument to `generate` (batch size 1 only) and yields up to 2x speedups, 3x with INT8, and up to 10x when the model relies on memory offloading. It works best on input-grounded tasks like ASR and summarization, and with sampling only at low temperatures.

The quest for software engineering knowledge.

Look:
Layout: