arXiv:2610.05559cs.LGOct 2026

Manuscript Offprint

arXiv:2610.05559

Cut Binary Cross Entropy: Efficient Large-Vocabulary Loss and Gradient Kernels for Sequential Recommendation

Yaoyiran Li, Haowen Ning, Mohamed Hammad

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Yaoyiran Li

Google Cloud

London, United Kingdom

yaoyiran@google.com

Haowen Ning

Google Cloud

Mountain View, USA

hning@google.com

Mohamed Hammad

Google Cloud

Mountain View, USA

mibra@google.com

Abstract—Industrial sequential recommender systems operate over massive item catalogs (e.g., 105−10710^{5}-10^{7} items). Multi-label recommendation models are trained with Binary Cross-Entropy (BCE) loss over the full vocabulary, but standard BCE materializes a dense [B,N,V][B, N, V] logits tensor in High Bandwidth Memory (HBM), incurring prohibitive O(BNV)O(BNV) memory and fatal Out-Of-Memory (OOM) errors. While chunked loss optimizations exist for Softmax Cross-Entropy in LLMs, large-scale multi-label BCE optimization remains unexplored across deep learning ecosystems.

We propose CutBCE, an exact, hardware-accelerated BCE loss and gradient operator implemented in JAX and Pallas for large-vocabulary workloads. CutBCE introduces (1) an exact fused reformulation evaluating dense background loss and sparse target corrections; (2) a custom Vector-Jacobian Product (VJP) with a dedicated Pallas TPU backward kernel computing logit tiles on-chip in both passes so logits and their gradients never reside in HBM; (3) dynamic VMEM budgeting and sharding-aware collective hoisting for distributed meshes; and (4) count-based zero-overhead training metrics. On single-chip TPU v5e/v6e mini-benchmarks, CutBCE eliminates OOM errors with up to 91.9% speedup. On 8-chip TPU slice training for multi-label SASRec with 876k items (Yambda-50M), CutBCE reduces peak HBM by 65.7% (> 14 GiB saved per chip) and increases training speed by 225.9% with comparable accuracy. CutBCE is open-sourced at https://github.com/AI-Hypercomputer/RecML/blob/main/recml/core/ops/binary_cross_entropy_ops.py.

Index Terms—Binary Cross Entropy, Efficient Deep Learning, Sequential Recommendation, TPU Kernels, Pallas, JAX

I. INTRODUCTION AND MOTIVATION

Sequential recommender systems are foundational to modern digital services, including e-commerce marketplaces, video streaming platforms, and app stores. These systems model user interaction trajectories to predict future user actions over massive item catalogs containing hundreds of thousands to tens of millions of item IDs [1], [3], [4]. Although text-based generative Large Language Models (LLMs) have demonstrated strong semantic reasoning capabilities for recommendation [2], ID-based sequential models (such as SASRec [3] and BERT4Rec [4]) remain the industry mainstream due to submillisecond serving latency via Approximate Nearest Neighbor (ANN) search and lightweight model architectures.

In industrial sequential recommendation, users frequently interact with multiple related items in a single session. Because single-step next-item prediction is myopic and overfits to noisy clicks and arbitrary local order, models are increasingly trained to predict the next L items (e.g., L = 8) simultaneously [11], [12]. This multi-label objective provides richer supervision and captures multi-intent sessions. The standard training loss for multi-label classification is Binary Cross-Entropy (BCE) evaluated over the entire item vocabulary (V is the vocab size).