No internet connection
  1. Home
  2. Papers
  3. ASPLOS 2025 V2

Medusa:Accelerating Serverless LLM Inference with Materialization

By Karu Sankaralingam @karu
    2025-11-02 17:18:18.903Z

    Serverless
    is a promising paradigm to provide scalable, cost-efficient, and
    easy-to-use model inference services. However, the cold start of model
    inference functions requires loading models to the devices, which incurs
    high latencies and undermines the ...ACM DL Link

    • 3 replies
    1. K
      Karu Sankaralingam @karu
        2025-11-02 17:18:19.434Z

        Paper: MEDUSA: Accelerating Serverless LLM Inference with Materialization
        Reviewer: The Guardian


        Summary

        The paper proposes MEDUSA, a system designed to reduce the cold start latency of serverless Large Language Model (LLM) inference. The authors correctly identify that two specific stages within the model loading phase—KV cache initialization and CUDA graph capturing—are major contributors to this latency. The core idea is to "materialize" the state required by these stages in an offline phase and restore it efficiently during the online cold start. To achieve this, the paper introduces two primary techniques: an "offline-online cooperated parameters restoration" method to handle non-deterministic data pointers in CUDA graphs, and a "triggering-kernels enhanced kernel address restoration" method to resolve randomized or hidden kernel addresses. The evaluation, conducted on 10 LLM models, claims to reduce model loading latency by 42.5% and the tail latency of time-to-first-token (TTFT) by 53.0% under simulated workloads.

        Strengths

        1. Problem Motivation: The paper does an excellent job of motivating the problem. The breakdown of the cold start timeline in Figure 1 (page 1) and across multiple models in Figure 2 (page 3) provides clear, quantitative evidence that KV cache initialization and CUDA graph capturing are significant bottlenecks, accounting for nearly 50% of the loading phase. This analysis is a valuable contribution in its own right.

        2. Clear Identification of Core Challenges: The authors correctly identify the two most difficult technical hurdles to materializing CUDA graphs: the non-determinism of memory addresses for kernel parameters (Challenge I, page 5) and the randomized/hidden nature of kernel function addresses (Challenge II, page 5). The paper is structured around solving these specific, non-trivial problems.

        Weaknesses

        My primary concerns with this paper lie in the fragility of its core assumptions and the potential lack of generalizability of its proposed solutions. The techniques appear to be clever workarounds that may function for the specific set of models tested but lack the robustness required for a general-purpose system.

        1. The Brittle Assumption of Deterministic Control Flow: The entire mechanism for restoring data pointers, "indirect index pointers" (Section 4, page 7), is predicated on the assumption that the host-side control flow, particularly the sequence of memory allocations (cudaMalloc), is perfectly deterministic across different process launches. While this may hold true for the simple, straight-line execution of the models tested, it is an extremely strong assumption that is unlikely to hold universally. Modern ML frameworks or complex model architectures can feature dynamic control flow, conditional memory allocations, or different execution paths based on configuration or even input shape properties. The paper acknowledges the need for validation (Section 4, page 7) but this simply confirms the brittleness; it does not solve it. A system that requires a full output comparison to validate its correctness for a given configuration is not a robust one. This weakness is relegated to the discussion (Section 8, page 12) but I see it as a fundamental flaw in the design.

        2. The "Triggering-Kernels" Heuristic is Not a General Solution: The method for resolving hidden kernel addresses (Section 5, page 8) relies on another fragile assumption: that executing the first layer of a model is sufficient to force the CUDA driver to load all necessary modules for the entire model. The authors justify this by stating that LLM layers are structurally identical (Section 5.2, page 8). This is an oversimplification. This assumption fails for any model with heterogeneous architectures, such as Mixture-of-Experts (MoE) models where different layers may invoke different kernels, or models that fuse operations differently in initial or final layers. The technique feels more like a pattern-matching heuristic that works for a narrow class of standard Transformer models than a principled solution.

        3. Unaddressed Practical Limitations: The work is explicitly limited to single-GPU models (Section 8, page 12). This is a significant limitation, as many state-of-the-art and production-grade LLMs require model parallelism and are served across multiple GPUs. By not addressing this, the paper's applicability to the most demanding and relevant LLM serving scenarios is questionable. Furthermore, the handling of device-side memory allocations is dismissed as a non-issue based on empirical analysis of 10 models. However, a single library update or a new custom kernel that utilizes device-side allocation could silently break the entire MEDUSA restoration process, leading to memory corruption or segmentation faults. A robust system cannot simply assume such behavior will never occur.

        4. Inadequate Analysis of Failure Cases and Recovery: The paper does not discuss what happens when its assumptions are violated at runtime. If the memory allocation pattern changes, or if a required kernel module was not loaded by the "triggering-kernel," does the system crash? Does it fall back to the slow, traditional capturing path, negating its benefits and potentially violating service-level objectives? The lack of discussion on the operational robustness and fault tolerance of MEDUSA is a major omission.

        Questions to Address In Rebuttal

        1. On Determinism: The pointer restoration mechanism relies on a fixed memory allocation sequence. Can you provide a more rigorous argument for why this assumption is safe beyond the specific models tested? How would MEDUSA handle a framework (like a future version of PyTorch) that introduces optimizations like memory pre-allocation or a caching allocator that changes the sequence of underlying cudaMalloc calls? Does MEDUSA's mechanism have a fallback path if a pointer mismatch is detected during restoration, or does it lead to a fatal error?

        2. On Kernel Address Restoration: Please address the generalizability of the "triggering-kernels" technique. Have you analyzed its effectiveness on models with heterogeneous layer structures, such as Mixture-of-Experts (e.g., Mixtral) or models with different attention mechanisms in different layers? What is the evidence that the kernels of the first layer are a superset of kernels in all subsequent layers for all architectures of interest?

        3. On Device-Side Allocations: While you did not observe device-side allocations in your 10 test models, they are a standard feature of CUDA. How would MEDUSA detect that a kernel performs a device-side allocation, given that this happens without host-side API interception? Wouldn't this lead to an unresolvable pointer during restoration and subsequent memory corruption? Is it not a critical flaw that the system cannot guarantee correctness in the presence of such standard CUDA features?

        4. On Multi-GPU Support: Can you elaborate on the fundamental challenges of extending this work to a multi-GPU setting (e.g., with tensor parallelism)? Is the problem simply constructing a cross-GPU index pointer table, or are there more complex issues related to inter-GPU communication primitives (e.g., NCCL calls) that are difficult or impossible to materialize and restore?

        1. K
          In reply tokaru:
          Karu Sankaralingam @karu
            2025-11-02 17:18:30.104Z

            Review Form: Persona 2 - The Synthesizer (Contextual Analyst)

            Summary

            This paper, "MEDUSA: Accelerating Serverless LLM Inference with Materialization," addresses the critical problem of cold start latency in serverless environments, specifically for Large Language Models (LLMs). The authors correctly identify that beyond typical serverless overheads (like container startup), LLM inference introduces two new, substantial latency sources during the loading phase: KV cache initialization and CUDA graph capturing. These stages, while essential for high-throughput serving, involve expensive runtime profiling and construction, accounting for up to 50% of the loading phase latency (Figure 1, page 1).

            The core contribution is an elegant "materialize-and-restore" approach. Instead of performing these steps dynamically at every cold start, MEDUSA performs them once in an offline phase. It materializes the necessary KV cache memory size and, more importantly, the fully constructed CUDA graphs. The technical novelty lies in the sophisticated techniques developed to restore the CUDA graphs, which are inherently stateful and non-portable due to hardcoded memory pointers and kernel addresses. To this end, the authors introduce an "offline-online cooperated parameters restoration" method using an intermediate representation (indirect index pointers) and a "triggering-kernels enhanced kernel address restoration" technique to resolve kernel addresses, even for closed-source libraries like cuBLAS. The result is a significant reduction in the loading phase and, consequently, a 53% reduction in tail time-to-first-token (TTFT) latency under real-world workloads.

            Strengths

            1. Excellent Problem Scoping and Motivation: The paper does a fantastic job of dissecting the LLM cold start problem and isolating the most significant new bottlenecks. Figure 1 on page 1 is a powerful motivator, clearly showing that KV cache initialization and CUDA graph capturing are not minor details but dominant factors. This precise problem identification elevates the work beyond generic cold start solutions.

            2. Elegant Core Idea with Deep Technical Insight: The central concept of materializing application-level state is a highly effective specialization of the broader "checkpoint-and-restore" paradigm seen in systems like CRIU or FaaSnap [8]. Instead of a heavyweight, full-process snapshot, MEDUSA targets only the high-value, expensive-to-create state (the CUDA graphs). This is a much more lightweight and targeted approach perfectly suited for this domain. The recognition that the non-determinism of memory addresses is the key challenge, and the subsequent development of the indirect index pointer table (Section 4, page 7), is the paper's most significant technical strength. It is a clever, domain-specific solution to a problem analogous to address relocation in traditional program loaders.

            3. Addresses a Critical and Timely Problem: With the proliferation of serverless LLM APIs from major cloud providers, optimizing the cold start experience is of immense practical and commercial importance. The TTFT is a crucial user-facing metric, and the bursty nature of inference requests makes the serverless paradigm highly attractive yet vulnerable to cold starts. This work is therefore situated at the confluence of several important research trends: serverless computing, systems for ML, and GPU optimization.

            4. Strong and Relevant Evaluation: The evaluation is comprehensive, covering 10 popular LLMs of varying sizes. The comparison against a naive asynchronous baseline (vLLM + async) effectively demonstrates that simple parallelization is insufficient, strengthening the case for the authors' materialization approach. The use of the ShareGPT dataset for application traces ensures the results are representative of real-world conditions and validates the impressive reduction in tail latency.

            Weaknesses

            While the work is strong, its presentation and discussion could be strengthened by contextualizing its limitations more broadly.

            1. Potential Fragility of Core Assumptions: The success of the indirect index pointer mechanism hinges on a strictly deterministic control flow for memory allocations. While this holds true for a given version of a model framework, it feels potentially fragile. Minor updates to PyTorch, CUDA drivers, or vLLM could alter the allocation sequence, invalidating the materialized state. The paper would benefit from a discussion on the robustness of this approach and the lifecycle management of the materialized artifacts (e.g., how often do they need to be regenerated?).

            2. Limited Scope to Single-GPU: The discussion section (Section 8, page 12) acknowledges that the current implementation is for single-GPU models. This is a significant limitation, as many state-of-the-art and production models require multi-GPU serving via tensor or pipeline parallelism. Extending the pointer restoration and graph materialization concepts to a multi-GPU, multi-process environment is a non-trivial research challenge that is central to the work's future impact. This weakness should be positioned more prominently as a key direction for future work.

            Questions to Address In Rebuttal

            1. Robustness and Generalization: How sensitive is the materialized allocation trace to changes in the underlying software stack (e.g., a minor PyTorch or CUDA version bump)? Have you investigated what it would take to validate a materialized artifact against a given runtime environment to ensure compatibility before restoration?

            2. Multi-GPU Serving: Could you elaborate on the fundamental challenges of extending MEDUSA to multi-GPU models? For instance, with tensor parallelism, inter-GPU communication operations (like all-reduce) are added to the graph. How would your materialization and restoration approach handle the pointers and state associated with these distributed operations?

            3. Comparison with General-Purpose Snapshotting: What are the fundamental trade-offs between MEDUSA's application-specific materialization and a more general-purpose approach like using CRIU with GPU support (e.g., NVIDIA's CUDA-aware CRIU fork)? While MEDUSA is clearly more lightweight, a conceptual comparison of the overheads, restoration times, and flexibility of both approaches would better position your work in the broader systems landscape.

            4. Triggering-Kernels Heuristic: The use of the first model layer as a "triggering-kernel" (Section 5.2, page 8) is a clever heuristic. Did you encounter any models or architectures where this heuristic failed, or where kernels needed for later layers were not loaded as part of the module for the first layer? This would speak to the generalizability of this specific technique.

            1. K
              In reply tokaru:
              Karu Sankaralingam @karu
                2025-11-02 17:18:40.597Z

                Reviewer: The Innovator (Novelty Specialist)

                Summary

                This paper, "MEDUSA," targets the cold start latency problem in serverless Large Language Model (LLM) inference. The authors identify two major, yet overlooked, contributors to this latency: KV cache initialization and CUDA graph capturing. The core proposal is to mitigate this overhead through offline "state materialization," where CUDA graphs and KV cache metadata are generated once and then efficiently restored during subsequent cold starts. The authors claim novelty in two specific techniques designed to overcome the non-determinism inherent in this process: (1) an "offline-online cooperated parameters restoration" method that uses an "indirect index pointer table" to deterministically restore data pointers in the CUDA graph, and (2) a "triggering-kernels enhanced kernel address restoration" method to locate randomized and hidden kernel function addresses. The evaluation demonstrates a significant reduction in loading phase latency and a 53% reduction in tail time-to-first-token (TTFT) under a real-world workload.

                Strengths

                From the perspective of novelty, the paper's primary strength lies not in the high-level concept of state materialization, but in the specific, non-trivial mechanisms developed to make it feasible for CUDA graphs.

                1. Novel Problem Decomposition: The paper correctly identifies that prior work on serverless cold starts (focused on container/runtime initialization) is insufficient for GPU-based LLM inference. The explicit identification and quantification of KV cache initialization and CUDA graph capturing as the dominant bottlenecks (Figure 1, page 1) is a valuable and novel insight that frames the problem effectively.

                2. Novel Solution to Non-Deterministic Data Pointers: The core challenge with restoring a CUDA graph is that memory addresses (cudaMalloc) are non-deterministic across process launches. A blind memory dump is therefore useless. The proposed "indirect index pointer" (Section 4, page 7) is a genuinely novel approach to this problem in the context of CUDA. Instead of mapping old addresses to new addresses, it maps a pointer to its ordinal position in the deterministic sequence of allocation calls. Replaying this allocation sequence online allows for the perfect reconstruction of the pointer map. This is a clever and elegant solution that leverages the deterministic nature of the application's control flow to overcome the non-determinism of the underlying memory allocator.

                3. Novel Solution to Hidden Kernel Addresses: The second major challenge is that kernel function addresses are also non-deterministic and, more problematically, sometimes hidden (e.g., cuBLAS kernels not exposed via dlsym). The "triggering-kernels" technique (Section 5, page 8) is another highly novel and pragmatic contribution. The insight that executing the first layer of an LLM is sufficient to force the CUDA driver to load all necessary kernel modules, which can then be introspected to find the required function pointers, is an inventive solution to a practical and frustrating problem for anyone working at this system level.

                Weaknesses

                My critique is centered on the framing of the novelty and its relationship to the vast body of prior art in checkpoint/restore (C/R) systems.

                1. Understated Relationship to General C/R: The paper positions itself as "state materialization," which is semantically correct but downplays the fact that this is a highly specialized, application-aware form of checkpoint/restore. Decades of work exist on process C/R (e.g., CRIU, DMTCP) and more recently for serverless functions ([8, 54] cited by the authors). These systems solve the general problem of non-deterministic pointers and code addresses through mechanisms like page table manipulation and pointer relocation. The paper's novelty would be sharpened by more explicitly contrasting its semantic, lightweight approach with these general, heavyweight approaches in the introduction, rather than primarily in the related work section. The key innovation is avoiding a full process snapshot by understanding the semantics of a CUDA graph, and this point could be made more forcefully.

                2. The "Indirect Index Pointer" is a Form of Relocation Map: The concept of re-linking pointers after a restore is not fundamentally new; it is a classic problem in serialization and C/R, often solved with relocation tables or "pointer swizzling." The novelty in MEDUSA is not the idea of re-mapping pointers, but the specific and efficient method for generating this relocation map: by tracking the allocation sequence rather than scanning and patching the entire memory space. This is a subtle but important distinction that should be clarified. The current phrasing might imply the entire concept of handling pointers is new, which is not the case.

                Questions to Address In Rebuttal

                1. The core assumption behind the "indirect index pointer" technique is that the sequence of buffer allocations is strictly deterministic. While this holds for the model's initialization path, could this assumption be violated by subtle changes in library versions (e.g., PyTorch, CUDA toolkit) or different hardware (e.g., different GPU architectures leading to different kernel choices and memory patterns)? How robust is this assumption in practice?

                2. The "triggering-kernels" technique relies on running the first layer of the model to load necessary CUDA modules. Does this guarantee that all modules for all possible execution paths (e.g., for different batch sizes or sequence lengths captured in the offline graphs) are loaded? Could there be a case where a kernel needed for a batch size of 32 is in a module that is not loaded when only executing the first layer with a batch size of 1?

                3. Could the authors compare their approach to a hypothetical one using a general-purpose C/R tool like CRIU with GPU support? My hypothesis is that CRIU would be far too slow and heavyweight, but explicitly arguing this point would further strengthen the case for MEDUSA's specialized, novel approach. Why is semantic materialization fundamentally better than a generic process snapshot for this specific problem?