Abstract
Continual learning has become a promising solution to refine large language models incrementally by leveraging user feedback. In particular, online continual learning - iteratively training the model with small batches of user feedback - has demonstrated notable performance improvements. However, the existing practice of separating training and serving processes forces the online trainer to recompute the intermediate results already done during serving. Such redundant computations can account for 30%-42% of total training time. In this paper, we propose Alchemist, to the best of our knowledge, the first online continual learning system that efficiently reuses serving activations to increase training throughput. Alchemist introduces two key techniques: (1) recording and storing activations and KV cache only during the prefill phase to minimize latency and memory overhead; and (2) smart activation offloading and hedging. Evaluations with inputs of varied token length sampled from ShareGPT dataset show that compared with a separate training cluster, Alchemist significantly increases training throughput by up to 1.72x, reduces up to 47% memory usage during training, and supports up to 2x more training tokens - all while maintaining negligible impact on serving latency.
Introduction
In the rapidly evolving landscape of Large Language Models (LLMs), maintaining model relevance requires constant updates. Online Continual Learning (OCL)—the iterative refinement of models using real-time user feedback—has emerged as the gold standard for accuracy and personalization. However, current deployments typically treat serving (inference) and training as isolated processes. This decoupling creates a massive hidden cost: the "computational waste" of redundant forward passes.
The Redundancy Problem
When a system learns from user interaction (e.g., via Direct Preference Optimization), the trainer must perform a forward pass to calculate gradients. In traditional setups, this pass is identical to the one already performed by the serving engine to generate the response.
As shown in Figure 3, these redundant computations account for 30% to 42% of total training time. Simply co-locating these tasks on the same hardware is insufficient, as recording activations during serving can introduce up to 35% latency overhead and lead to GPU memory exhaustion.
Alchemist System Architecture
Alchemist is designed to bridge this gap by reusing serving activations to supercharge training. It integrates directly with the serving engine to capture intermediate results without disrupting the user experience.
The system consists of several key components:
- Hooks: Injected into the LLM serving engine to capture activations and manage training preemption.
- AlchemistCacheBase: A specialized buffer for storing activations, labels, and KV caches.
- Trainer: Executes the backward pass using cached activations.
- Offloader: Manages memory by moving data to CPU memory when GPU resources are tight.
Key Innovations
Selective Activation Recording
Alchemist exploits a "prefill loophole." While recording activations for every generated token (decoding) is prohibitively slow, recording them during the initial prompt processing (prefill) is relatively inexpensive. By focusing on the prefill phase, Alchemist maintains a smooth user experience with negligible latency impact.
KV Cache and Activation Reuse
For preference-based training like DPO, which compares multiple responses to the same prompt, Alchemist reuses the prompt's Key-Value (KV) cache. This avoids recomputing the prompt's representation multiple times, significantly reducing memory and compute requirements.
Smart Offloading and Hedging
To prevent Out-of-Memory (OOM) errors, Alchemist profiles GPU memory and offloads activations to CPU memory. It employs a "hedging" strategy: if the time to transfer an activation back from the CPU exceeds the time to recompute it, the system chooses recomputation. This acknowledges the PCIe bottleneck in modern hardware.
Results and Impact
Evaluations using the ShareGPT dataset and models like Llama-3.1-8B demonstrate Alchemist's efficiency:
- Throughput: Training throughput increases by 1.26x to 1.72x compared to decoupled baselines.
- Memory Efficiency: Peak memory usage is reduced by 32% to 47%, allowing the system to support sequences up to 2x longer (e.g., 7,000 tokens).
- Serving Latency: The impact on Time Per Token (TPT) is kept under 3%, ensuring that the background training remains invisible to the end user.
Conclusion
Alchemist demonstrates that the "waste" of serving computation can be effectively harvested to enable efficient, real-time model refinement. By co-locating serving and training and implementing intelligent activation management, Alchemist paves the way for more responsive and resource-efficient AI systems.
Summary updated