# * : On-the-Fly Self-Speculative Decoding for LLM Inference Acceleration
> Corresponding Author
## Abstract
Speculative decoding (SD) has emerged as a widely used paradigm to accelerate LLM inference without compromising quality. It works by first employing a compact model to draft multiple tokens efficiently and then using the target LLM to verify them in parallel. While this technique has achieved notable speedups, most existing approaches necessitate either additional parameters or extensive training to construct effective draft models, thereby restricting their applicability across different LLMs and tasks. To address this limitation, we explore a novel plug-and-play SD solution with layer-skipping, which skips intermediate layers of the target LLM as the compact draft model. Our analysis reveals that LLMs exhibit great potential for self-acceleration through layer sparsity and the task-specific nature of this sparsity. Building on these insights, we introduce , an on-the-fly self-speculative decoding algorithm that adaptively selects intermediate layers of LLMs to skip during inference. does not require auxiliary models or additional training, making it a plug-and-play solution for accelerating LLM inference across diverse input data streams. Our extensive experiments across a wide range of models and downstream tasks demonstrate that can achieve over a $1.3\times$ $\sim$ $1.6\times$ speedup while preserving the original distribution of the generated text. We release our code in https://github.com/hemingkx/SWIFT.
## 1 Introduction
Large Language Models (LLMs) have exhibited outstanding capabilities in handling various downstream tasks (OpenAI, 2023; Touvron et al., 2023a; b; Dubey et al., 2024). However, their token-by-token generation necessitated by autoregressive decoding poses efficiency challenges, particularly as model sizes increase. To address this, speculative decoding (SD) has been proposed as a promising solution for lossless LLM inference acceleration (Xia et al., 2023; Leviathan et al., 2023; Chen et al., 2023). At each decoding step, SD first employs a compact draft model to efficiently predict multiple tokens as speculations for future decoding steps of the target LLM. These tokens are then validated by the target LLM in parallel, ensuring that the original output distribution remains unchanged.
Recent advancements in SD have pushed the boundaries of the latency-accuracy trade-off by exploring various strategies (Xia et al., 2024), including incorporating lightweight draft modules into LLMs (Cai et al., 2024; Ankner et al., 2024; Li et al., 2024a; b), employing fine-tuning strategies to facilitate efficient LLM drafting (Kou et al., 2024; Yi et al., 2024; Elhoushi et al., 2024), and aligning draft models with the target LLM (Liu et al., 2023a; Zhou et al., 2024; Miao et al., 2024). Despite their promising efficacy, these approaches require additional modules or extensive training, which limits their broad applicability across different model types and causes significant inconvenience in practice. To tackle this issue, another line of research has proposed the Jacobi-based drafting (Santilli et al., 2023; Fu et al., 2024) to facilitate plug-and-play SD. As illustrated in Figure 1 (a), these methods append pseudo tokens to the input prompt, enabling the target LLM to generate multiple tokens as drafts in a single decoding step. However, the Jacobi-decoding paradigm misaligns with the autoregressive pretraining objective of LLMs, resulting in suboptimal acceleration effects.
<details>
<summary>x1.png Details</summary>

### Visual Description
## Diagram: Two Drafting Methods for Large Language Models
### Overview
The image displays two side-by-side technical diagrams illustrating different architectural approaches for "drafting" in the context of Large Language Models (LLMs). The diagrams are labeled (a) and (b) and contrast a "Jacobi-based" method using a full-parameter model with a "Sparsity-based" method using a sparse model.
### Components/Axes
The image contains two distinct diagrams with the following labeled components:
**Diagram (a): Jacobi-based Drafting**
* **Central Component:** A large, light-blue rounded rectangle labeled **"Full-parameter LLM"**.
* **Input/Output Blocks:** Four smaller, green-outlined rectangular blocks are positioned below the central LLM, with arrows pointing upward into it. Four similar green-outlined blocks are positioned above the central LLM, with arrows pointing upward out of it.
* **Refinement Loop:** A gray, rounded rectangular container encloses the top four output blocks. This container is labeled **"Refine x N"** at its top center. A gray arrow originates from the right side of this container and loops back down to point at the rightmost input block at the bottom.
* **Flow Indicators:** Black arrows show the direction of data flow: from the bottom input blocks into the LLM, and from the LLM out to the top output blocks.
**Diagram (b): Sparsity-based Drafting**
* **Central Component:** A large, light-blue rounded rectangle containing the label **"Sparse LLM"**. Inside this rectangle, there are two solid light-blue horizontal bars (one top, one bottom) and a central, dashed-outline yellow bar.
* **Input/Output Blocks:** A single green-outlined rectangular block is positioned below the central component. A single green-outlined rectangular block is positioned above it.
* **Flow Indicators:** Dashed gray arrows connect the bottom input block to the central component and the central component to the top output block. A solid gray arrow points from the central dashed yellow bar upward to the top solid blue bar.
### Detailed Analysis
The diagrams visually encode the following technical processes:
**For (a) Jacobi-based Drafting:**
1. **Process:** The system takes multiple input drafts (represented by the four bottom blocks) and processes them simultaneously through a single, full-parameter LLM.
2. **Iteration:** The outputs (top blocks) are collected and subjected to a refinement process that is repeated N times ("Refine x N").
3. **Feedback:** The refined outputs are fed back into the system as new inputs for the next iteration, creating a closed-loop, iterative refinement cycle.
**For (b) Sparsity-based Drafting:**
1. **Process:** The system uses a "Sparse LLM," which is visually represented as having both active (solid blue bars) and inactive or pruned (dashed yellow bar) components.
2. **Flow:** A single input draft is processed. The dashed arrows suggest a potentially conditional or selective data path through the sparse model.
3. **Internal Routing:** The solid gray arrow inside the Sparse LLM indicates a specific internal data pathway from the sparse (yellow) component to an active (blue) component, highlighting the model's sparse activation pattern.
### Key Observations
* **Structural Contrast:** Diagram (a) emphasizes parallel processing and iterative refinement with a monolithic model. Diagram (b) emphasizes internal model sparsity and a more streamlined, single-pass data flow.
* **Visual Metaphors:** The use of solid vs. dashed lines is a key visual metaphor. In (a), solid lines represent active data flow. In (b), dashed lines represent the sparse or conditional nature of the model's internal pathways and connections.
* **Complexity:** The Jacobi-based method appears more complex, involving multiple data streams and a feedback loop. The Sparsity-based method appears more streamlined at the system level but implies complexity within the model's architecture.
### Interpretation
These diagrams illustrate two distinct paradigms for improving LLM inference or training efficiency, likely in the context of speculative decoding or iterative refinement.
* **Jacobi-based Drafting** suggests a method where multiple candidate drafts are generated and refined in parallel through the full model, leveraging iterative correction (akin to a Jacobi iterative method in numerical analysis). The "Refine x N" loop is central to its operation, indicating that quality is improved through repeated passes.
* **Sparsity-based Drafting** suggests a method that relies on the inherent sparse architecture of a model (e.g., a Mixture-of-Experts model or a pruned model) to process drafts more efficiently. The single input/output path and internal sparse routing imply a focus on reducing computational cost per draft by activating only relevant parts of the network.
The core contrast is between **improving output through iterative, full-model refinement** (a) and **improving efficiency through architectural sparsity** (b). The choice between them would involve a trade-off between the quality gains from multiple refinement steps and the computational savings from sparse activation.
</details>
Figure 1: Illustration of prior solution and ours for plug-and-play SD. (a) Jacobi-based drafting appends multiple pseudo tokens to the input prompt, enabling the target LLM to generate multiple tokens as drafts in a single step. (b) adopts sparsity-based drafting, which exploits the inherent sparsity in LLMs to facilitate efficient drafting. This work is the first exploration of plug-and-play SD using sparsity-based drafting.
In this work, we introduce a novel research direction for plug-and-play SD: sparsity-based drafting, which leverages the inherent sparsity in LLMs to enable efficient drafting (see Figure 1 (b)). Specifically, we exploit a straightforward yet practical form of LLM sparsity – layer sparsity – to accelerate inference. Our approach is based on two key observations: 1) LLMs possess great potential for self-acceleration through layer sparsity. Contrary to the conventional belief that layer selection must be carefully optimized (Zhang et al., 2024), we surprisingly found that uniformly skipping layers to draft can still achieve a notable $1.2\times$ speedup, providing a strong foundation for plug-and-play SD. 2) Layer sparsity is task-specific. We observed that each task requires its own optimal set of skipped layers, and applying the same layer configuration across different tasks would cause substantial performance degradation. For example, the speedup drops from $1.47\times$ to $1.01\times$ when transferring the configuration optimized for a storytelling task to a reasoning task.
Building on these observations, we introduce , the first on-the-fly self-speculative decoding algorithm that adaptively optimizes the set of skipped layers in the target LLM during inference, facilitating the lossless acceleration of LLMs across diverse input data streams. integrates two key innovations: (1) a context-based layer set optimization mechanism that leverages LLM-generated context to efficiently identify the optimal set of skipped layers corresponding to the current input stream, and (2) a confidence-aware inference acceleration strategy that maximizes the use of draft tokens, improving both speculation accuracy and verification efficiency. These innovations allow to strike an expected balance between the latency-accuracy trade-off in SD, providing a new plug-and-play solution for lossless LLM inference acceleration without the need for auxiliary models or additional training, as demonstrated in Table 1.
We conduct experiments using LLaMA-2 and CodeLLaMA models across multiple tasks, including summarization, code generation, mathematical reasoning, etc. achieves a $1.3\times$ $\sim$ $1.6\times$ wall-clock time speedup compared to conventional autoregressive decoding. Notably, in the greedy setting, consistently maintains a $98\$ $\sim$ $100\$ token acceptance rate across the LLaMA2 series, indicating the high alignment potential of this paradigm. Further analysis validated the effectiveness of across diverse data streams and its compatibility with various LLM backbones.
Our key contributions are:
1. We performed an empirical analysis of LLM acceleration on layer sparsity, revealing both the potential for LLM self-acceleration via layer sparsity and its task-specific nature, underscoring the necessity for adaptive self-speculative decoding during inference.
1. Building on these insights, we introduce , the first plug-and-play self-speculative decoding algorithm that optimizes the set of skipped layers in the target LLM on the fly, enabling lossless acceleration of LLM inference across diverse input data streams.
1. We conducted extensive experiments across various models and tasks, demonstrating that consistently achieves a $1.3\times$ $\sim$ $1.6\times$ speedup without any auxiliary model or training, while theoretically guaranteeing the preservation of the generated text’s distribution.
## 2 Related Work
Speculative Decoding (SD)
Due to the sequential nature of autoregressive decoding, LLM inference is constrained by memory-bound computations (Patterson, 2004; Shazeer, 2019), with the primary latency bottleneck arising not from arithmetic computations but from memory reads/writes of LLM parameters (Pope et al., 2023). To mitigate this issue, speculative decoding (SD) introduces utilizing a compact draft model to predict multiple decoding steps, with the target LLM then validating them in parallel (Xia et al., 2023; Leviathan et al., 2023; Chen et al., 2023). Recent SD variants have sought to enhance efficiency by incorporating additional modules (Kim et al., 2023; Sun et al., 2023; Du et al., 2024; Li et al., 2024a; b) or introducing new training objectives (Liu et al., 2023a; Kou et al., 2024; Zhou et al., 2024; Gloeckle et al., 2024). However, these approaches necessitate extra parameters or extensive training, limiting their applicability across different models. Another line of research has explored plug-and-play SD methods with Jacobi decoding (Santilli et al., 2023; Fu et al., 2024), which predict multiple steps in parallel by appending pseudo tokens to the input and refining them iteratively. As shown in Table 1, our work complements these efforts by investigating a novel plug-and-play SD method with layer-skipping, which exploits the inherent sparsity of LLM layers to accelerate inference. The most related approaches to ours include Self-SD (Zhang et al., 2024) and LayerSkip (Elhoushi et al., 2024), which also skip intermediate layers of LLMs to form the draft model. However, both methods require a time-consuming offline training process, making them neither plug-and-play nor easily generalizable across different models and tasks.
| Eagle (Li et al., 2024a; b) | Draft Heads | Yes | ✗ | ✓ | ✓ | ✓ | - |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Rest (He et al., 2024) | Context Retrieval | Yes | ✗ | ✓ | ✓ | ✓ | - |
| Self-SD (Zhang et al., 2024) | Layer Skipping | No | ✗ | ✓ | ✓ | ✗ | - |
| Parallel (Santilli et al., 2023) | Jacobi Decoding | No | ✓ | ✓ | ✗ | ✗ | $0.9\times$ $\sim$ $1.0\times$ |
| Lookahead (Fu et al., 2024) | Jacobi Decoding | No | ✓ | ✓ | ✓ | ✓ | $1.2\times$ $\sim$ $1.4\times$ |
| (Ours) | Layer Skipping | No | ✓ | ✓ | ✓ | ✓ | $1.3\times$ $\sim$ $1.6\times$ |
Table 1: Comparison of with existing SD methods. “ AM ” denotes whether the method requires auxiliary modules such as additional parameters or data stores. “ Greedy ”, “ Sampling ”, and “ Token Tree ” denote whether the method supports greedy decoding, multinomial sampling, and token tree verification, respectively. is the first plug-and-play layer-skipping SD method, which is orthogonal to those Jacobi-based methods such as Lookahead (Fu et al., 2024).
Efficient LLMs Utilizing Sparsity
LLMs are powerful but often over-parameterized (Hu et al., 2022). To address this issue, various methods have been proposed to accelerate inference by leveraging different forms of LLM sparsity. One promising research direction is model compression, which includes approaches such as quantization (Dettmers et al., 2022; Frantar et al., 2023; Ma et al., 2024), parameter pruning (Liu et al., 2019; Hoefler et al., 2021; Liu et al., 2023b), and knowledge distillation (Touvron et al., 2021; Hsieh et al., 2023; Gu et al., 2024). These approaches aim to reduce model sparsity by compressing LLMs into more compact forms, thereby decreasing memory usage and computational overhead during inference. Our proposed method, , focuses specifically on sparsity within LLM layer computations, providing a more streamlined approach to efficient LLM inference that builds upon recent advances in layer skipping (Corro et al., 2023; Zhu et al., 2024; Jaiswal et al., 2024; Liu et al., 2024). Unlike these existing layer-skipping methods that may lead to information loss and performance degradation, investigates the utilization of layer sparsity to enable lossless acceleration of LLM inference.
## 3 Preliminaries
### 3.1 Self-Speculative Decoding
Unlike most SD methods that require additional parameters, self-speculative decoding (Self-SD) first proposed utilizing parts of an LLM as a compact draft model (Zhang et al., 2024). In each decoding step, this approach skips intermediate layers of the LLM to efficiently generate draft tokens; these tokens are then validated in parallel by the full-parameter LLM to ensure that the output distribution of the target LLM remains unchanged. The primary challenge of Self-SD lies in determining which layers, and how many, should be skipped – referred to as the skipped layer set – during the drafting stage, which is formulated as an optimization problem. Formally, given the input data $\mathcal{X}$ and the target LLM $\mathscr{M}_{T}$ with $L$ layers (including both attention and MLP layers), Self-SD aims to identify the optimal skipped layer set $\bm{z}$ that minimizes the average inference time per token:
$$
\bm{z}^{*}=\underset{\bm{z}}{\arg\min}\frac{\sum_{\bm{x}\in\mathcal{X}}f\left(
\bm{x}\mid\bm{z};\bm{\theta}_{\mathscr{M}_{T}}\right)}{\sum_{\bm{x}\in\mathcal
{X}}|\bm{x}|},\quad\text{ s.t. }\bm{z}\in\{0,1\}^{L}, \tag{1}
$$
where $f(\cdot)$ is a black-box function that returns the inference latency of sample $\bm{x}$ , $\bm{z}_{i}\in\{0,1\}$ denotes whether layer $i$ of the target LLM is skipped when drafting, and $|\bm{x}|$ represents the sample length. Self-SD addresses this problem through a Bayesian optimization process (Jones et al., 1998). Before inference, this process iteratively selects new inputs $\bm{z}$ based on a Gaussian process (Rasmussen & Williams, 2006) and evaluates Eq (1) on the training set of $\mathcal{X}$ . After a specified number of iterations, the best $\bm{z}$ is considered an approximation of $\bm{z}^{*}$ and is held fixed for inference.
While Self-SD has proven effective, its reliance on a time-intensive Bayesian optimization process poses certain limitations. For each task, Self-SD must sequentially evaluate all selected training samples during every iteration to optimize Eq (1); Moreover, the computational burden of Bayesian optimization escalates substantially with the number of iterations. As a result, processing just eight CNN/Daily Mail (Nallapati et al., 2016) samples for 1000 Bayesian iterations requires nearly 7.5 hours for LLaMA-2-13B and 20 hours for LLaMA-2-70B on an NVIDIA A6000 server. These computational demands restrict the generalizability of Self-SD across different models and tasks.
### 3.2 Experimental Observations
This subsection delves into Self-SD, exploring the plug-and-play potential of this layer-skipping SD paradigm for lossless LLM inference acceleration. Our key findings are detailed below.
<details>
<summary>x2.png Details</summary>

### Visual Description
## [Chart Pair]: Performance Metrics of a Unified Skipping Pattern
### Overview
The image contains two distinct charts, labeled (a) and (b), which present performance data related to a "Unified Skipping Pattern" in a computational or machine learning context. Chart (a) is a dual-axis line chart showing the relationship between the number of skipped sub-layers and two performance metrics. Chart (b) is a grouped bar chart showing speedup variations across different evaluation tasks under domain shift.
### Components/Axes
**Chart (a): Speedups with a Unified Skipping Pattern**
* **Type:** Dual-axis line chart.
* **X-Axis:** "Number of Sub-layers to Skip". Scale ranges from 25 to approximately 48, with major ticks at 25, 30, 35, 40, 45.
* **Left Y-Axis (Blue):** "Token Acceptance Rate". Scale ranges from 0.2 to 1.0, with major ticks at 0.2, 0.4, 0.6, 0.8, 1.0.
* **Right Y-Axis (Green):** "Speedup". Scale ranges from 0.8 to 1.2, with major ticks at 0.8, 0.9, 1.0, 1.1, 1.2.
* **Legend (Bottom-Left):** Contains two entries:
* `Top-k candidates` (Green line with circle markers).
* `Top-1 candidates` (Blue line with triangle markers).
* **Data Series:**
1. **Top-k candidates (Green, circles):** Plotted against the right Y-axis (Speedup). The line starts high, peaks, then declines.
2. **Top-1 candidates (Blue, triangles):** Plotted against the left Y-axis (Token Acceptance Rate). The line shows a general downward trend.
**Chart (b): Speedup Variations under Domain Shift**
* **Type:** Grouped bar chart.
* **X-Axis:** "Evaluation Tasks". Four categories: `Summarization`, `Reasoning`, `StoryTelling`, `Translation`.
* **Y-Axis:** "Speedup". Scale ranges from 1.0 to 1.5, with major ticks at 1.0, 1.1, 1.2, 1.3, 1.4, 1.5.
* **Legend (Top-Left):** Contains four entries, each corresponding to a bar color within each task group:
* `Sum. LS` (Teal)
* `Rea. LS` (Orange)
* `Story. LS` (Blue)
* `Trans. LS` (Pink/Salmon)
* **Data Series (Bars):** For each of the four tasks, there are four bars representing the speedup for the corresponding "LS" (likely "Layer Skipping") variant.
### Detailed Analysis
**Chart (a) Data Points & Trends:**
* **Trend Verification - Top-k candidates (Green, Speedup):** The line starts at a speedup of ~1.1 at 25 skipped layers, rises to a peak of ~1.2 at 40 skipped layers, then drops sharply to ~0.9 at 45 layers and ~0.8 at 48 layers. The shaded green area suggests a confidence interval or variance, which widens significantly after the peak.
* **Trend Verification - Top-1 candidates (Blue, Token Acceptance Rate):** The line starts at a high acceptance rate of ~0.97 at 25 layers, declines steadily to ~0.58 at 40 layers, and then drops more steeply to ~0.45 at 45 layers and ~0.18 at 48 layers.
* **Approximate Data Points (X, Top-k Speedup, Top-1 Acceptance):**
* (25, ~1.10, ~0.97)
* (30, ~1.12, ~0.95)
* (35, ~1.15, ~0.80)
* (40, ~1.20, ~0.58)
* (42, ~1.18, ~0.55)
* (45, ~0.90, ~0.45)
* (48, ~0.80, ~0.18)
**Chart (b) Data Points:**
* **Summarization:**
* Sum. LS (Teal): 1.28
* Rea. LS (Orange): 0.99
* Story. LS (Blue): 1.20
* Trans. LS (Pink): 1.17
* **Reasoning:**
* Sum. LS (Teal): 1.10
* Rea. LS (Orange): 1.12
* Story. LS (Blue): 1.01
* Trans. LS (Pink): 1.04
* **StoryTelling:**
* Sum. LS (Teal): 1.34
* Rea. LS (Orange): 1.28
* Story. LS (Blue): 1.47
* Trans. LS (Pink): 1.24
* **Translation:**
* Sum. LS (Teal): 1.05
* Rea. LS (Orange): 1.08
* Story. LS (Blue): 1.06
* Trans. LS (Pink): 1.15
### Key Observations
1. **Performance Peak and Cliff (Chart a):** There is a clear optimal point for the "Top-k candidates" speedup at around 40 skipped sub-layers. Beyond this point, both speedup and token acceptance rate degrade rapidly, indicating a failure mode or excessive information loss.
2. **Metric Trade-off (Chart a):** As the number of skipped layers increases, the Token Acceptance Rate (for Top-1) decreases monotonically. The Speedup (for Top-k) initially improves but eventually collapses, showing a non-linear trade-off.
3. **Task-Dependent Performance (Chart b):** Speedup is highly sensitive to both the task and the specific Layer Skipping (LS) variant used. No single LS variant is best across all tasks.
4. **Domain Shift Impact (Chart b):** The "StoryTelling" task shows the highest overall speedups (up to 1.47x), while "Translation" and "Reasoning" show more modest gains. The "Rea. LS" variant performs poorly on "Summarization" (0.99x, a slowdown) but is the best for its namesake "Reasoning" task.
### Interpretation
The data suggests that the "Unified Skipping Pattern" is a technique for accelerating model inference by dynamically skipping computational sub-layers. Chart (a) reveals its operational limits: aggressive skipping (beyond ~40 layers) severely harms output quality (Token Acceptance Rate) and eventually negates speed benefits. The technique's effectiveness is not universal; it is highly context-dependent, as shown in Chart (b). The performance of a given skipping strategy (e.g., `Sum. LS`) is tied to the alignment between its design and the task's domain (e.g., `Sum. LS` excels at Summarization and StoryTelling but not Reasoning). This implies that for real-world deployment, a system would need to select or adapt its skipping strategy based on the incoming task type to maximize acceleration without sacrificing quality. The "StoryTelling" task appears most amenable to this acceleration technique.
</details>
Figure 2: (a) LLMs possess self-acceleration potential via layer sparsity. By utilizing drafts from the top- $k$ candidates, we found that uniformly skipping half of the layers during drafting yields a notable $1.2\times$ speedup. (b) Layer sparsity is task-specific. Each task requires its own optimal set of skipped layers, and applying the skipped layer configuration from one task to another can lead to substantial performance degradation. “ X LS ” represents the skipped layer set optimized for task X.
#### 3.2.1 LLMs Possess Self-Acceleration Potential via Layer Sparsity
We begin by investigating the potential of behavior alignment between the target LLM and its layer-skipping variant. Unlike previous work (Zhang et al., 2024) that focused solely on greedy draft predictions, we leverage potential draft candidates from top- $k$ predictions, as detailed in Section 4.2. We conducted experiments using LLaMA-2-13B across the CNN/Daily Mail (Nallapati et al., 2016), GSM8K (Cobbe et al., 2021), and TinyStories (Eldan & Li, 2023) datasets. We applied a uniform layer-skipping pattern with $k$ set to 10. The experimental results, illustrated in Figure 2 (a), demonstrate a $30\$ average improvement in the token acceptance rate by leveraging top- $k$ predictions, with over $90\$ of draft tokens accepted by the target LLM. Consequently, compared to Self-SD, which achieved a maximum speedup of $1.01\times$ in this experimental setting, we revealed that the layer-skipping SD paradigm could yield an average wall-clock speedup of $1.22\times$ over conventional autoregressive decoding with a uniform layer-skipping pattern. This finding challenges the prevailing belief that the selection of skipped layers must be meticulously curated, suggesting instead that LLMs possess greater potential for self-acceleration through inherent layer sparsity.
#### 3.2.2 Layer Sparsity is Task-specific
We further explore the following research question: Is the skipped layer set optimized for one specific task applicable to other tasks? To address this, we conducted domain shift experiments using LLaMA-2-13B on the CNN/Daily Mail, GSM8K, TinyStories, and WMT16 DE-EN datasets. The experimental results, depicted in Figure 2 (b), reveal two critical findings: 1) Each task requires its own optimal skipped layer set. As illustrated in Figure 2 (b), the highest speedup performance is consistently achieved by the skipped layer configuration specifically optimized for each task. The detailed configuration of these layers is presented in Appendix A, demonstrating that the optimal configurations differ across tasks. 2) Applying the static skipped layer configuration across different tasks can lead to substantial efficiency degradation. For example, the speedup decreases from $1.47\times$ to $1.01\times$ when the optimized skipped layer set from a storytelling task is applied to a mathematical reasoning task, indicating that the optimized skipped layer set for one specific task does not generalize effectively to others.
These findings lay the groundwork for our plug-and-play solution within layer-skipping SD. Section 3.2.1 provides a strong foundation for real-time skipped layer selection, suggesting that additional optimization using training data may be unnecessary; Section 3.2.2 highlights the limitations of static layer-skipping patterns for dynamic input data streams across various tasks, underscoring the necessity for adaptive layer optimization during inference. Building on these insights, we present our on-the-fly self-speculative decoding method for efficient and adaptive layer set optimization.
## 4 SWIFT: On-the-Fly Self-Speculative Decoding
We introduce , the first plug-and-play self-speculative decoding approach that optimizes the skipped layer set of the target LLM on the fly, facilitating lossless LLM acceleration across diverse input data streams. As shown in Figure 3, divides LLM inference into two distinct phases: (1) context-based layer set optimization (§ 4.1), which aims to identify the optimal skipped layer set given the input stream, and (2) confidence-aware inference acceleration (§ 4.2), which employs the determined configuration to accelerate LLM inference.
<details>
<summary>x3.png Details</summary>

### Visual Description
## Diagram: Two-Phase Token Generation Optimization Process
### Overview
The image is a technical diagram illustrating a two-stage process for optimizing and accelerating the generation of tokens (likely in an autoregressive language model). The process is depicted along a horizontal timeline representing the sequence of "Generated Tokens." The first stage involves iterative cycles of context accumulation and layer set optimization, while the second stage is a continuous acceleration phase.
### Components/Axes
* **Main Title/Process Labels:**
* Left Section: "Context-based Layer Set Optimization"
* Right Section: "Confidence-aware Inference Acceleration"
* **Horizontal Axis:** Labeled "Generated Tokens" with an arrow pointing right, indicating progression. Key markers are placed at intervals: `0`, `N`, `2N`, `...`, `mN`, `(m+1)N`, `(m+2)N`, `...`.
* **Legend (Bottom Center):**
* Yellow hatched rectangle: "context accumulation"
* Red hatched rectangle: "layer set optimization"
* Green hatched rectangle: "acceleration"
### Detailed Analysis
The diagram is segmented into two distinct phases along the token generation timeline:
1. **Phase 1: Context-based Layer Set Optimization (From token 0 to mN)**
* This phase consists of a repeating pattern of two alternating processes.
* **Process A (Yellow):** "context accumulation" blocks appear first in each cycle.
* **Process B (Red):** "layer set optimization" blocks follow each context accumulation block.
* The pattern is: Yellow -> Red -> Yellow -> Red -> ... This cycle repeats multiple times, as indicated by the ellipsis (`...`) between the `2N` and `mN` markers.
* The final cycle in this phase ends with a red "layer set optimization" block that concludes at the `mN` token marker.
2. **Phase 2: Confidence-aware Inference Acceleration (From token mN onward)**
* Starting precisely at the `mN` token marker, a single, continuous green "acceleration" block begins.
* This green block extends horizontally past the `(m+1)N` and `(m+2)N` markers and continues indefinitely, as indicated by the final ellipsis (`...`).
* This represents a sustained operational mode that follows the initial optimization phase.
### Key Observations
* **Clear Phase Transition:** There is a definitive handoff point at `mN` generated tokens, where the system switches from an alternating optimization cycle to a continuous acceleration mode.
* **Iterative vs. Continuous:** The first phase is iterative (cyclical), while the second phase is linear and continuous.
* **Spatial Grounding:** The legend is positioned at the bottom center of the diagram. The color coding is consistent: all yellow blocks are "context accumulation," all red blocks are "layer set optimization," and the single green block is "acceleration."
* **Temporal Structure:** The use of `N` as a unit suggests the processes operate on chunks or windows of `N` tokens. The variable `m` denotes the number of full optimization cycles completed before acceleration begins.
### Interpretation
This diagram outlines a strategy to improve the efficiency of sequential token generation, a core process in large language models. The underlying logic suggests:
1. **Investment in Setup:** The initial "Context-based Layer Set Optimization" phase is an investment. By repeatedly accumulating context and using it to optimize which layers of the neural network are used (or how they are configured), the system builds a more efficient internal state. This is likely a form of dynamic model pruning or conditional computation tailored to the specific context.
2. **Payoff in Speed:** Once this optimized state is achieved (at token `mN`), the system enters the "Confidence-aware Inference Acceleration" phase. The term "confidence-aware" implies the acceleration mechanism may be gated by the model's predictive confidence, allowing it to skip computations or use faster pathways when certain. The continuous green block signifies that this optimized, faster generation mode is maintained for all subsequent tokens.
3. **Overall Goal:** The process aims to reduce the average computational cost per token. It front-loads some overhead (the optimization cycles) to achieve a lower, sustained cost for the majority of the generation process. This is particularly valuable for generating long sequences, where the acceleration phase dominates.
**Note:** The diagram is conceptual and does not provide specific numerical data, performance metrics, or details on the algorithms used for "layer set optimization" or "acceleration." It illustrates the high-level workflow and temporal relationship between the components.
</details>
Figure 3: Timeline of inference. N denotes the maximum generation length per instance.
### 4.1 Context-based Layer Set Optimization
Layer set optimization is a critical challenge in self-speculative decoding, as it determines which layers of the target LLM should be skipped to form the draft model (see Section 3.1). Unlike prior methods that rely on time-intensive offline optimization, our work emphasizes on-the-fly layer set optimization, which poses a greater challenge to the latency-accuracy trade-off: the optimization must be efficient enough to avoid delays during inference while ensuring accurate drafting of subsequent decoding steps. To address this, we propose an adaptive optimization mechanism that balances efficiency with drafting accuracy. Our method minimizes overhead by performing only a single forward pass of the draft model per step to validate potential skipped layer set candidates. The core innovation is the use of LLM-generated tokens (i.e., prior context) as ground truth, allowing for simultaneous validation of the draft model’s accuracy in predicting future decoding steps.
In the following subsections, we illustrate the detailed process of this optimization phase for each input instance, which includes context accumulation (§ 4.1.1) and layer set optimization (§ 4.1.2).
#### 4.1.1 Context Accumulation
Given an input instance in the optimization phase, the draft model is initialized by uniformly skipping layers in the target LLM. This initial layer-skipping pattern is maintained to accelerate inference until a specified number of LLM-generated tokens, referred to as the context window, has been accumulated. Upon reaching this window length, the inference transitions to layer set optimization.
<details>
<summary>x4.png Details</summary>

### Visual Description
## Technical Diagram: LLM Layer Skipping Optimization Process
### Overview
The image is a technical flowchart illustrating a two-stage process for optimizing Large Language Model (LLM) inference by dynamically selecting which layers to skip. The system uses draft models and verification to accelerate generation while maintaining output quality. The diagram is divided into two main dashed-box sections: (a) Efficient Layer Set Suggestion and (b) Parallel Candidate Evaluation, connected by a feedback loop.
### Components/Axes
The diagram is a process flow with labeled boxes, arrows indicating data flow, and a legend.
**Main Sections:**
1. **Left Input:** "LLM Inputs" (a sequence of colored token blocks).
2. **Section (a) - Efficient Layer Set Suggestion:** A dashed box containing:
* Two optimization methods: "Random Search" (with an icon of dice and text `np.random.choice()`) and "Bayes Optimization" (with an icon of a sampled function).
* A layer selection matrix showing a stack of "MLP" and "Attention" layers, each associated with a binary value (0 or 1) in a column labeled `z`. The sequence from top to bottom is: MLP-0, Attention-1, MLP-0, Attention-0, MLP-1, Attention-0.
3. **Section (b) - Parallel Candidate Evaluation:** A dashed box containing:
* "Original Outputs" (a sequence of colored token blocks).
* "Draft Tokens" (a sequence of colored token blocks).
* A "Calculate Matchness" step comparing Original and Draft tokens.
* A "Gaussian Update" box.
* An "Alter Skipped Layer Set" box (with an icon of swapping squares).
* A "Compact Draft Model" box (with an icon of a document and pen).
4. **Feedback & Verification Loop:**
* "Target LLM Verification" box (with a shield/check icon).
* Arrows labeled "update", "Accepted tokens", and "Draft multiple steps".
5. **Legend (Bottom Center):** Defines the color coding for token types:
* Yellow box: "input tokens"
* Green box: "LLM-generated tokens"
* Blue box: "draft tokens"
* Orange box: "accepted tokens"
**Spatial Grounding:**
* The entire flow moves generally from left to right.
* Section (a) is on the left, feeding into Section (b) on the right via an arrow labeled "Parallel Draft".
* The "Target LLM Verification" is centered below the two main sections.
* The legend is positioned at the very bottom, centered horizontally.
### Detailed Analysis
**Process Flow:**
1. **Input:** "LLM Inputs" (yellow and green tokens) enter the system.
2. **Layer Suggestion (a):** The system uses either "Random Search" or "Bayes Optimization" to propose a set of layers to skip. This is represented by the binary vector `z` applied to the MLP and Attention layers. A value of `1` likely means the layer is active, `0` means it is skipped.
3. **Draft Generation:** The suggested layer set is used to create a "Parallel Draft" via a "Compact Draft Model". This generates "Draft Tokens" (blue).
4. **Evaluation (b):** The "Draft Tokens" are compared to the "Original Outputs" (green) to "Calculate Matchness".
5. **Optimization:** If the matchness is good ("if best"), the system performs a "Gaussian Update" and proceeds to "Alter Skipped Layer Set", refining the layer selection strategy.
6. **Verification & Acceptance:** The draft tokens undergo "Target LLM Verification". Tokens that pass are output as "Accepted tokens" (orange) and also fed back via an "update" arrow to inform future "LLM Inputs". The process can "Draft multiple steps" before verification.
**Token Color Coding (from Legend):**
* The initial "LLM Inputs" block contains 4 yellow (input) and 3 green (LLM-generated) tokens.
* The "Original Outputs" block contains 4 green tokens.
* The "Draft Tokens" block contains 4 blue tokens.
* The final "Accepted tokens" block contains 4 orange tokens.
### Key Observations
1. **Hybrid Optimization:** The system combines stochastic ("Random Search") and model-based ("Bayes Optimization") methods to find optimal layer skip patterns.
2. **Parallel Drafting:** The "Compact Draft Model" generates multiple draft tokens in parallel, which are then verified, suggesting a speculative decoding approach.
3. **Closed-Loop Learning:** The process is iterative. Results from verification ("Accepted tokens") and matchness calculation ("Gaussian Update") feed back to improve the layer suggestion and draft model.
4. **Binary Layer Control:** The core mechanism is a binary mask (`z`) applied to the transformer's MLP and Attention layers, enabling fine-grained control over the model's active computation path.
### Interpretation
This diagram depicts a sophisticated system for **accelerating LLM inference through dynamic layer skipping and speculative decoding**. The core idea is to use a smaller, faster "draft model" (which skips certain layers as per the suggested set) to generate candidate tokens quickly. These candidates are then verified in parallel by the full "target LLM". Only the accepted tokens are kept, ensuring output quality matches the full model.
The "Efficient Layer Set Suggestion" module is the brain of the operation, using optimization algorithms to learn which layers are most dispensable for a given input context, thereby maximizing speed without sacrificing accuracy. The "Parallel Candidate Evaluation" module is the engine, efficiently testing multiple draft hypotheses. The feedback loops create a self-improving system where the layer selection strategy and draft model are continuously refined based on verification outcomes.
**Significance:** This approach addresses the key trade-off in LLM deployment: speed versus quality. By intelligently skipping computation and verifying results, it promises significant reductions in latency and computational cost for applications like real-time chat, translation, and code generation, without degrading the user experience. The use of both random and Bayesian optimization suggests a robust strategy to avoid local minima in finding the optimal skip pattern.
</details>
Figure 4: Layer set optimization process in . During the optimization stage, performs an optimization step prior to each LLM decoding step to adjust the skipped layer set, which involves: (a) Efficient layer set optimization. integrates random search with interval Bayesian optimization to propose layer set candidates; (b) Parallel candidate evaluation. uses LLM-generated tokens (i.e., prior context) as ground truth, enabling simultaneous validation of the proposed candidates. The best-performing layer set is selected to accelerate the current decoding step.
#### 4.1.2 Layer Set Optimization
During this stage, as illustrated in Figure 4, we integrate an optimization step before each LLM decoding step to refine the skipped layer set, which comprises two substeps:
Efficient Layer Set Suggestion
This substep aims to suggest a potential layer set candidate. Formally, given a target LLM $\mathscr{M}_{T}$ with $L$ layers, our goal is to identify an optimal skipped layer set $\bm{z}\in\{0,1\}^{L}$ to form the compact draft model. Unlike Zhang et al. (2024), which relies entirely on a time-consuming Bayesian optimization process, we introduce an efficient strategy that combines random search with Bayesian optimization. In this approach, random sampling efficiently handles most of the exploration. Specifically, given a fixed skipping ratio $r$ , applies Bayesian optimization at regular intervals of $\beta$ optimization steps (e.g., $\beta=25$ ) to suggest the next layer set candidate, while random search is employed during other optimization steps.
$$
\bm{z}=\left\{\begin{array}[]{ll}\operatorname{Bayesian\_Optimization}(\bm{l})
&\text{ if }o\text{ \
\operatorname{Random\_Search}(\bm{l})&\text{ otherwise }\end{array},\right. \tag{2}
$$
where $1\leq o\leq S$ is the current optimization step; $S$ denotes the maximum number of optimization steps; $\bm{l}=\binom{L}{rL}$ denotes the input space, i.e., all possible combinations of layers that can be skipped.
Parallel Candidate Evaluation
leverages LLM-generated context to simultaneously validate the candidate draft model’s performance in predicting future decoding steps. Formally, given an input sequence $\bm{x}$ and the previously generated tokens within the context window, denoted as $\bm{y}=\{y_{1},\dots,y_{\gamma}\}$ , the draft model $\mathscr{M}_{D}$ , which skips the designated layers $\bm{z}$ of the target LLM, is employed to predict these context tokens in parallel:
$$
y^{\prime}_{i}=\arg\max_{y}\log P\left(y\mid\bm{x},\bm{y}_{<i};\bm{\theta}_{
\mathscr{M}_{D}}\right),1\leq i\leq\gamma, \tag{3}
$$
where $\gamma$ represents the context window. The cached key-value pairs in the target LLM $\mathscr{M}_{T}$ are reused by $\mathscr{M}_{D}$ , presumably aligning $\mathscr{M}_{D}$ ’s distribution with $\mathscr{M}_{T}$ and reducing the redundant computation. The matchness score is defined as the exact match ratio between $\bm{y}$ and $\bm{y}^{\prime}$ :
$$
\texttt{matchness}=\frac{\sum_{i}\mathbb{I}\left(y_{i}=y^{\prime}_{i}\right)}{
\gamma},1\leq i\leq\gamma, \tag{4}
$$
where $\mathbb{I}(\cdot)$ denotes the indicator function. This score serves as the optimization objective during optimization, reflecting $\mathscr{M}_{D}$ ’s accuracy in predicting future decoding steps. As shown in Figure 4, the matchness score at each step is integrated into the Gaussian process model to guide Bayesian optimization, with the highest-scoring layer set candidate being retained to form the draft model.
As illustrated in Figure 3, the process of context accumulation and layer set optimization alternates for each instance until a termination condition is met – either the maximum number of optimization steps is reached or the best candidate remains unchanged over multiple iterations. Once the optimization phase concludes, the inference process transitions to the confidence-aware inference acceleration phase, where the optimized draft model is employed to speed up LLM inference.
### 4.2 Confidence-aware Inference Acceleration
<details>
<summary>x5.png Details</summary>

### Visual Description
## Diagram: Early-stopping Drafting and Dynamic Verification Process
### Overview
The image is a technical diagram illustrating a two-stage process for text generation or sequence modeling, likely in the context of large language models or speculative decoding. It is divided into two main panels: (a) Early-stopping Drafting on the left and (b) Dynamic Verification on the right. The diagram uses color-coding (blue and red) and dashed/solid lines to differentiate between two parallel processes or hypotheses.
### Components/Axes
**Panel (a) - Early-stopping Drafting:**
* **Left Trapezoid (Blue Outline):**
* **Header Label:** "Continue" (in blue, italicized).
* **Probability Statement:** `P_is = 0.85 > ε` (where ε is a threshold symbol).
* **Internal Text (Top to Bottom):** "is" (solid blue box), "will" (dashed blue box), "that" (plain text).
* **Input Arrow:** Labeled "Attention" pointing upward into a green box below.
* **Right Trapezoid (Red Outline):**
* **Header Label:** "Early Stop!" (in red, italicized).
* **Probability Statement:** `P_all = 0.65 < ε`.
* **Internal Text (Top to Bottom):** "all" (solid red box), "the" (dashed red box), "best" (dashed red box).
* **Input Arrow:** Labeled "is" pointing upward into a green box below.
* **Green Boxes:** Both trapezoids are fed from identical green rectangular boxes labeled `M_D` (likely a model or drafting module).
* **Flow Arrow:** A dashed black arrow curves from the "is" token in the left trapezoid to the input "is" of the right trapezoid, indicating a sequential or conditional relationship.
**Panel (b) - Dynamic Verification:**
* **Title:** "Dynamic Verification" (below the panel).
* **Attention Matrix:** A 5x5 grid (5 rows, 5 columns).
* **Row Labels (Left, Vertical):** "Attention" (title), followed by the tokens: "is" (blue box), "all" (red box), "will" (dashed blue box), "the" (dashed red box), "best" (dashed red box).
* **Column Labels (Bottom, Horizontal):** The same five tokens in the same order and styling as the row labels.
* **Matrix Content:** A grid where specific cells are filled with solid yellow, representing attention weights or alignments. The pattern is not a simple diagonal.
* **Legend/Key:** Located below the matrix, it explicitly maps the token styles:
* Solid blue box: "is"
* Solid red box: "all"
* Dashed blue box: "will"
* Dashed red box: "the"
* Dashed red box: "best"
### Detailed Analysis
**Process Flow (Panel a):**
1. The system appears to be drafting or predicting sequences of tokens ("is", "will", "that" vs. "all", "the", "best").
2. A probability score (`P`) is calculated for each draft sequence. The left sequence ("is"-led) has a high probability (`0.85`) exceeding a threshold `ε`, leading to a "Continue" decision.
3. The right sequence ("all"-led) has a lower probability (`0.65`) below `ε`, triggering an "Early Stop!" decision.
4. The dashed arrow suggests the "is" token from the continued draft is used as input to generate or evaluate the next potential sequence ("all", "the", "best").
**Attention Matrix Details (Panel b):**
The yellow-filled cells in the 5x5 grid indicate which tokens attend to which other tokens. Mapping the grid (Row, Column) with (1,1) as top-left:
* **Row 1 ("is"):** Attends to Column 1 ("is") and Column 2 ("all").
* **Row 2 ("all"):** Attends to Column 1 ("is"), Column 2 ("all"), and Column 3 ("will").
* **Row 3 ("will"):** Attends to Column 2 ("all") and Column 4 ("the").
* **Row 4 ("the"):** Attends to Column 3 ("will") and Column 5 ("best").
* **Row 5 ("best"):** Attends to Column 4 ("the") and Column 5 ("best").
### Key Observations
1. **Color-Coded Correspondence:** The blue/red and solid/dashed styling is consistently maintained between the draft sequences in panel (a) and the attention matrix labels in panel (b), creating a clear visual link.
2. **Probabilistic Gating:** The core mechanism is a probability threshold (`ε`) that decides whether to continue generating a sequence or to stop early, optimizing computational resources.
3. **Attention Pattern:** The attention matrix does not show a simple 1:1 alignment. Tokens attend to a small subset of others, primarily their immediate neighbors in the sequence and the key tokens ("is", "all") from the drafting stage. The "all" token (red) receives attention from four out of five tokens.
4. **Asymmetric Process:** The "Continue" path (blue) uses a generic "Attention" input, while the "Early Stop" path (red) is specifically triggered by the "is" token from the first path.
### Interpretation
This diagram illustrates an efficiency optimization technique for autoregressive text generation, such as **speculative decoding with early stopping**.
* **What it demonstrates:** The system runs two drafting processes in parallel or sequence. One is a high-confidence, continued draft. The other is a lower-confidence, alternative draft that is evaluated but terminated early if its probability is too low (`P_all < ε`). This avoids wasting computation on unlikely sequences.
* **Relationship between elements:** Panel (a) shows the *decision logic* based on sequence probability. Panel (b) shows the *underlying mechanism* (attention) that likely informs those probability calculations. The attention matrix reveals the model's focus during verification, showing how tokens relate to each other to compute the `P` scores.
* **Notable insight:** The "Early Stop!" condition (`P_all = 0.65`) is not extremely low, suggesting the threshold `ε` is set conservatively to prune only moderately unlikely paths. The attention pattern highlights "all" as a central token in the stopped sequence, which may be a key factor in its lower probability assessment compared to the "is"-led sequence. The process aims to maintain generation quality (`Continue` on high-probability paths) while improving speed (`Early Stop` on lower-probability paths).
</details>
Figure 5: Confidence-aware inference process of . (a) The drafting terminates early if the confidence score drops below threshold $\epsilon$ . (b) Draft candidates are dynamically selected based on confidence and then verified in parallel by the target LLM.
During the acceleration phase, the optimization step is removed. applies the best-performed layer set to form the compact draft model and decodes following the draft-then-verify paradigm. Specifically, at each decoding step, given the input $\bm{x}$ and previous LLM outputs $\bm{y}$ , the draft model $\mathscr{M}_{D}$ predicts future LLM decoding steps in an autoregressive manner:
$$
y^{\prime}_{j}=\arg\max_{y}\log P\left(y\mid\bm{x},\bm{y},\bm{y}^{\prime}_{<j}
;\bm{\theta}_{\mathscr{M}_{D}}\right), \tag{5}
$$
where $1\leq j\leq N_{D}$ is the current draft step, $N_{D}$ denotes the maximum draft length, $\bm{y}^{\prime}_{<j}$ represents previous draft tokens, and $P(\cdot)$ denotes the probability distribution of the next draft token. The KV cache of the target LLM $\mathscr{M}_{T}$ and preceding draft tokens $\bm{y}^{\prime}_{<j}$ is reused to reduce the computational cost.
Let $p_{j}=\max P(\cdot)$ denote the probability of the top-1 draft prediction $y^{\prime}_{j}$ , which can be regarded as a confidence score. Recent research (Li et al., 2024b; Du et al., 2024) shows that this score is highly correlated with the likelihood that the draft token $y^{\prime}_{j}$ will pass verification – higher confidence scores indicate a greater chance of acceptance. Therefore, following previous studies (Zhang et al., 2024; Du et al., 2024), we leverage the confidence score to prune unnecessary draft steps and select valuable draft candidates, improving both speculation accuracy and verification efficiency.
As shown in Figure 5, we integrate with two confidence-aware inference strategies These confidence-aware inference strategies are also applied during the optimization phase, where the current optimal layer set is used to form the draft model and accelerate the corresponding LLM decoding step.: 1) Early-stopping Drafting. The autoregressive drafting process halts if the confidence $p_{j}$ falls below a specified threshold $\epsilon$ , avoiding any waste of subsequant drafting computation. 2) Dynamic Verification. Each $y^{\prime}_{j}$ is dynamically extended with its top- $k$ draft predictions for parallel verification to enhance speculation accuracy, with $k$ determined by the confidence score $p_{j}$ . Concretely, $k$ is set to 10, 5, 3, and 1 for $p$ in the ranges of $(0,0.5]$ , $(0.5,0.8]$ , $(0.8,0.95]$ , and $(0.95,1]$ , respectively. All draft candidates are linearized into a single sequence and verified in parallel by the target LLM using a special causal attention mask (see Figure 5 (b)).
## 5 Experiments
### 5.1 Experimental Setup
Implementation Details
We mainly evaluate on LLaMA-2 (Touvron et al., 2023b) and CodeLLaMA series (Rozière et al., 2023) across various tasks, including summarization, mathematical reasoning, storytelling, and code generation. The evaluation datasets include CNN/Daily Mail (CNN/DM) (Nallapati et al., 2016), GSM8K (Cobbe et al., 2021), TinyStories (Eldan & Li, 2023), and HumanEval (Chen et al., 2021). The maximum generation lengths on CNN/DM, GSM8K, and TinyStories are set to 64, 64, and 128, respectively. We conduct 1-shot evaluation for CNN/DM and TinyStories, and 5-shot evaluation for GSM8K. We compare pass@1 and pass@10 for HumanEval. We randomly sample 1000 instances from the test set for each dataset except HumanEval. The maximum generation lengths for HumanEval and all analyses are set to 512. During optimization, we employ both random search and Bayesian optimization https://github.com/bayesian-optimization/BayesianOptimization to suggest skipped layer set candidates. Following prior work, we adopt speculative sampling (Leviathan et al., 2023) as our acceptance strategy with a batch size of 1. Detailed setups are provided in Appendix B.1 and B.2.
Baselines
In our main experiments, we compare to two existing plug-and-play methods: Parallel Decoding (Santilli et al., 2023) and Lookahead Decoding (Fu et al., 2024), both of which employ Jacobi decoding for efficient LLM drafting. It is important to note that , as a layer-skipping SD method, is orthogonal to these Jacobi-based SD methods, and integrating with them could further boost inference efficiency. We exclude other SD methods from our comparison as they necessitate additional modules or extensive training, which limits their generalizability.
Evaluation Metrics
We report two widely-used metrics for evaluation: mean generated length $M$ (Stern et al., 2018) and token acceptance rate $\alpha$ (Leviathan et al., 2023). Detailed descriptions of these metrics can be found in Appendix B.3. In addition to these metrics, we report the actual decoding speed (tokens/s) and wall-time speedup ratio compared with vanilla autoregressive decoding. The acceleration of theoretically guarantees the preservation of the target LLMs’ output distribution, making it unnecessary to evaluate the generation quality. However, to provide a point of reference, we present the evaluation scores for code generation tasks.
| LLaMA-2-13B Parallel Lookahead | Vanilla 1.04 1.38 | 1.00 0.95 $\times$ 1.16 $\times$ | 1.00 $\times$ 1.11 1.50 | 1.00 0.99 $\times$ 1.29 $\times$ | 1.00 $\times$ 1.06 1.62 | 1.00 0.97 $\times$ 1.37 $\times$ | 1.00 $\times$ 19.49 25.46 | 20.10 0.97 $\times$ 1.27 $\times$ | 1.00 $\times$ |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 4.34 | 1.37 $\times$ † | 3.13 | 1.31 $\times$ † | 8.21 | 1.53 $\times$ † | 28.26 | 1.41 $\times$ | | |
| LLaMA-2-13B -Chat | Vanilla | 1.00 | 1.00 $\times$ | 1.00 | 1.00 $\times$ | 1.00 | 1.00 $\times$ | 19.96 | 1.00 $\times$ |
| Parallel | 1.06 | 0.96 $\times$ | 1.08 | 0.97 $\times$ | 1.10 | 0.98 $\times$ | 19.26 | 0.97 $\times$ | |
| Lookahead | 1.35 | 1.15 $\times$ | 1.57 | 1.31 $\times$ | 1.66 | 1.40 $\times$ | 25.69 | 1.29 $\times$ | |
| 3.54 | 1.28 $\times$ | 2.95 | 1.25 $\times$ | 7.42 | 1.50 $\times$ † | 26.80 | 1.34 $\times$ | | |
| LLaMA-2-70B | Vanilla | 1.00 | 1.00 $\times$ | 1.00 | 1.00 $\times$ | 1.00 | 1.00 $\times$ | 4.32 | 1.00 $\times$ |
| Parallel | 1.05 | 0.95 $\times$ | 1.07 | 0.97 $\times$ | 1.05 | 0.96 $\times$ | 4.14 | 0.96 $\times$ | |
| Lookahead | 1.36 | 1.15 $\times$ | 1.54 | 1.30 $\times$ | 1.59 | 1.35 $\times$ | 5.45 | 1.26 $\times$ | |
| 3.85 | 1.43 $\times$ † | 2.99 | 1.39 $\times$ † | 6.17 | 1.62 $\times$ † | 6.41 | 1.48 $\times$ | | |
Table 2: Comparison between and prior plug-and-play methods. We report the mean generated length M, speedup ratio, and average decoding speed (tokens/s) under greedy decoding. † indicates results with a token acceptance rate $\alpha$ above 0.98. More details are provided in Appendix C.1.
| HumanEval (pass@1) HumanEval (pass@10) | Vanilla 4.75 Vanilla | 1.00 0.98 1.00 | - 0.311 - | 0.311 1.40 $\times$ 0.628 | 1.00 $\times$ 3.79 1.00 $\times$ | 1.00 0.88 1.00 | - 0.372 - | 0.372 1.46 $\times$ 0.677 | 1.00 $\times$ 1.00 $\times$ |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 3.55 | 0.93 | 0.628 | 1.29 $\times$ | 2.79 | 0.90 | 0.683 | 1.30 $\times$ | | |
Table 3: Experimental results of on code generation tasks. We report the mean generated length M, acceptance rate $\alpha$ , accuracy (Acc.), and speedup ratio for comparison. We use greedy decoding for pass@1 and random sampling with a temperature of 0.6 for pass@10.
### 5.2 Main Results
Table 2 presents the comparison between and previous plug-and-play methods on text generation tasks. The experimental results demonstrate the following findings: (1) shows superior efficiency over prior methods, achieving consistent speedups of $1.3\times$ $\sim$ $1.6\times$ over vanilla autoregressive decoding across various models and tasks. (2) The efficiency of is driven by the high behavior consistency between the target LLM and its layer-skipping draft variant. As shown in Table 2, produces a mean generated length M of 5.01, with a high token acceptance rate $\alpha$ ranging from $90\$ to $100\$ . Notably, for the LLaMA-2 series, this acceptance rate remains stable at $98\$ $\sim$ $100\$ , indicating that nearly all draft tokens are accepted by the target LLM. (3) Compared with 13B models, LLaMA-2-70B achieves higher speedups with a larger layer skip ratio ( $0.45$ $\rightarrow$ $0.5$ ), suggesting that larger-scale LLMs exhibit greater layer sparsity. This underscores ’s potential to deliver even greater speedups as LLM scales continue to grow. A detailed analysis of this finding is presented in Section 5.3, while additional experimental results for LLaMA-70B models, including LLaMA-3-70B, are presented in Appendix C.2.
Table 3 shows the evaluation results of on code generation tasks. achieves speedups of $1.3\times$ $\sim$ $1.5\times$ over vanilla autoregressive decoding, demonstrating its effectiveness across both greedy decoding and random sampling settings. Additionally, speculative sampling theoretically guarantees that maintains the original output distribution of the target LLM. This is empirically validated by the task performance metrics in Table 3. Despite a slight variation in the pass@10 metric for CodeLLaMA-34B, achieves identical performance to autoregressive decoding.
### 5.3 In-depth Analysis
<details>
<summary>x6.png Details</summary>

### Visual Description
## Dual-Axis Line Chart with Latency Breakdown Table
### Overview
The image displays a dual-axis line chart on the left, plotting "Matchness" and "Speedup" against the number of instances, alongside a data table on the right titled "Latency Breakdown per Token." The chart visualizes the performance of an optimization process over 100 instances, showing improvements in matchness and speedup, with a notable event marked at 10 instances.
### Components/Axes
**Chart Area (Left Side):**
* **X-Axis:** Labeled "# of Instances". Scale runs from 0 to 100 with major ticks every 10 units.
* **Primary Y-Axis (Left):** Labeled "Matchness". Scale runs from 0.0 to 1.0 with major ticks every 0.2 units.
* **Secondary Y-Axis (Right):** Labeled "Speedup". Scale runs from 1.2 to 1.6 with major ticks every 0.1 units.
* **Legend:** Located in the bottom-right corner of the chart area.
* Green line with circular markers: "Overall Speedup"
* Gray line with circular markers: "Instance Speedup"
* **Data Series:**
1. **Blue Line (Matchness):** A solid blue line with circular markers, plotted against the left y-axis.
2. **Green Line (Overall Speedup):** A solid green line with circular markers, plotted against the right y-axis. It is accompanied by a light green shaded area, likely representing a confidence interval or variance.
3. **Gray Dots (Instance Speedup):** Individual gray circular markers scattered across the chart, plotted against the right y-axis. A thin, light gray line connects these points.
* **Annotations:**
* A vertical red dashed line at x=10.
* Text "Optimization Stop!" in red, italic font, positioned to the right of the red dashed line, near the bottom of the chart.
* Text "Average" in black, positioned near the top-right of the chart area, above the gray data points.
**Table Area (Right Side):**
* **Title:** "Latency Breakdown per Token"
| Modules | Latency (ms) | Ratio (%) |
|---------|--------------|-----------|
| Optimize | 0.24 ± 0.02 | 0.8 |
| Draft | 19.93 ± 1.36 | 64.4 |
| Verify | 8.80 ± 2.21 | 28.4 |
| Others | 1.98 ± 0.13 | 6.4 |
| Total | 30.95 ± 2.84 | 100.0 |
### Detailed Analysis
**Chart Trends and Data Points:**
* **Matchness (Blue Line):** Shows a steep, near-linear increase from approximately 0.45 at 0 instances to about 0.95 at 10 instances. After the "Optimization Stop!" line (x=10), the trend plateaus, fluctuating slightly between ~0.95 and 1.0 for the remainder of the instances (10 to 100).
* **Overall Speedup (Green Line):** Exhibits a steady, logarithmic-like increase. It starts at approximately 1.25 at 0 instances, crosses 1.4 around 20 instances, and asymptotically approaches ~1.52 by 100 instances. The shaded green area is widest at the beginning (indicating higher variance) and narrows as the number of instances increases.
* **Instance Speedup (Gray Dots):** The individual data points show significant scatter, especially in the early instances (0-30). The values range from a low of ~1.28 to a high of ~1.58. The connecting gray line reveals high volatility. After the "Optimization Stop!" point, the scatter remains but the average trend aligns closely with the green "Overall Speedup" line. The "Average" label suggests the gray dots represent individual measurements whose mean is tracked by the green line.
* **Key Event:** The vertical red dashed line at x=10, labeled "Optimization Stop!", marks a critical point. After this point, the Matchness metric stabilizes at a high value, while the Speedup metrics continue their gradual improvement.
**Table Data:**
The table provides a precise breakdown of computational latency per token.
* The **"Draft"** module is the dominant contributor, accounting for 64.4% of the total latency (19.93 ± 1.36 ms).
* The **"Verify"** module is the second largest at 28.4% (8.80 ± 2.21 ms).
* **"Optimize"** and **"Others"** are minor contributors, at 0.8% and 6.4% respectively.
* The **Total** latency is 30.95 ± 2.84 ms per token.
### Key Observations
1. **Phase Change at Instance 10:** There is a clear regime shift after 10 instances. The rapid improvement in Matchness halts, suggesting the optimization goal was largely achieved. Speedup continues to improve but at a diminishing rate.
2. **High Initial Variance:** Both the Matchness curve and the Instance Speedup scatter show the greatest change and variability in the first 10-20 instances, indicating an active learning or adaptation phase.
3. **Dominant Latency Component:** The "Draft" module is the primary bottleneck, consuming nearly two-thirds of the total processing time per token.
4. **Correlation of Metrics:** The improvement in Speedup (green line) correlates with the stabilization of high Matchness (blue line) after the optimization stop point, suggesting the system becomes both accurate and efficient.
### Interpretation
This visualization tells the story of an optimization system's training or adaptation process. The "Optimization Stop!" event at 10 instances likely represents a point where a primary objective (high Matchness) was met, after which the system continued to fine-tune for efficiency (Speedup). The high initial variance in Instance Speedup suggests the system was exploring different strategies early on.
The latency table provides crucial context for the "Speedup" metric. The overall speedup (reaching ~1.52x) is achieved despite the "Draft" phase being extremely costly. This implies that the optimization process is successfully reducing the *relative* time spent in other phases or improving the efficiency of the Draft phase itself over instances. The system's value lies in its ability to achieve high matchness quickly (within 10 instances) and then continue to deliver incremental speed improvements, making it suitable for scenarios where rapid initial accuracy is critical, followed by sustained performance gains. The large uncertainty (± values) in the "Verify" and "Total" latency suggests variability in the complexity of the tokens being processed.
</details>
Figure 6: Illustration and latency breakdown of inference. As the left figure shows, after the context-based layer set optimization phase, the overall speedup of steadily increases, reaching the average instance speedup during the acceleration phase. The additional optimization steps account for only $\bf{0.8\$ of the total inference latency, as illustrated in the right figure.
Illustration of Inference
As described in Section 4, divides the LLM inference process into two distinct phases: optimization and acceleration. Figure 6 (left) illustrates the detailed acceleration effect of during LLM inference. Specifically, the optimization phase begins at the start of inference, where an optimization step is performed before each decoding step to adjust the skipped layer set forming the draft model. As shown in Figure 6, in this phase, the matchness score of the draft model rises sharply from 0.45 to 0.73 during the inference of the first instance. This score then gradually increases to 0.98, which triggers the termination of the optimization process. Subsequently, the inference transitions to the acceleration phase, during which the optimization step is removed, and the draft model remains fixed to accelerate LLM inference. As illustrated, the instance speedup increases with the matchness score, reaching an average of $1.53\times$ in the acceleration phase. The overall speedup gradually rises as more tokens are generated, eventually approaching the average instance speedup. This dynamic reflects a key feature of : the efficiency of improves with increasing input length and the number of instances.
Breakdown of Computation
Figure 6 (right) presents the computation breakdown of different modules in with 1000 CNN/DM samples using LLaMA-2-13B. The results demonstrate that the optimization step only takes $\bf{0.8\$ of the overall inference process, indicating the efficiency of our strategy. Compared with Self-SD (Zhang et al., 2024) that requires a time-consuming optimization process (e.g., 7.5 hours for LLaMA-2-13B on CNN/DM), achieves a nearly 180 $\times$ optimization time reduction, facilitating on-the-fly inference acceleration. Besides, the results show that the drafting stage of consumes the majority of inference latency. This is consistent with our results of mean generated length in Table 2 and 3, which shows that nearly $80\$ output tokens are generated by the efficient draft model, demonstrating the effectiveness of our framework.
<details>
<summary>x7.png Details</summary>

### Visual Description
## Combination Bar and Line Chart: Performance Comparison of Vanilla, Self-SD, and SWIFT Methods
### Overview
This image is a technical performance chart comparing three methods—Vanilla, Self-SD, and SWIFT—across five different natural language processing tasks. It uses a dual-axis design: a bar chart on the primary (left) y-axis to show "Speedup" and a line chart on the secondary (right) y-axis to show "Token Acceptance." The chart demonstrates that the SWIFT method consistently achieves the highest speedup and maintains high token acceptance across all tasks.
### Components/Axes
* **Chart Type:** Combination bar and line chart with dual y-axes.
* **Primary Y-Axis (Left):** Labeled "Speedup." Scale ranges from 0.8 to 1.6, with major gridlines at 0.2 intervals. This axis corresponds to the bar heights.
* **Secondary Y-Axis (Right):** Labeled "Token Acceptance." Scale ranges from 0.5 to 1.0, with major gridlines at 0.1 intervals. This axis corresponds to the line data points.
* **X-Axis:** Lists five task categories. From left to right: "Summarization", "Reasoning", "Instruction", "Translation", "QA".
* **Legend (Top-Center):** Contains two sections.
* **Bar Legend (Left):** Defines the three bar colors: Orange for "Vanilla", Teal for "Self-SD", Blue for "SWIFT".
* **Line Legend (Right):** Defines the two line series: A green dashed line with circle markers for "SWIFT", and a gray dashed line with circle markers for "Self-SD". The "Vanilla" method does not have a corresponding line for Token Acceptance.
* **Data Labels:** Each bar has a numerical label at its top indicating the exact speedup multiplier (e.g., "1.00x", "1.56x").
### Detailed Analysis
The data is grouped by task. For each task, three bars are shown, and two lines are plotted across the entire chart.
**1. Speedup (Bar Chart - Primary Y-Axis):**
* **Summarization:**
* Vanilla (Orange): 1.00x
* Self-SD (Teal): 1.28x
* SWIFT (Blue): 1.56x
* **Reasoning:**
* Vanilla (Orange): 1.00x
* Self-SD (Teal): 1.10x
* SWIFT (Blue): 1.45x
* **Instruction:**
* Vanilla (Orange): 1.00x
* Self-SD (Teal): 1.08x
* SWIFT (Blue): 1.47x
* **Translation:**
* Vanilla (Orange): 1.00x
* Self-SD (Teal): 1.05x
* SWIFT (Blue): 1.27x
* **QA:**
* Vanilla (Orange): 1.00x
* Self-SD (Teal): 1.02x
* SWIFT (Blue): 1.35x
**Trend Verification (Speedup):** The blue SWIFT bars are consistently the tallest in every task group, indicating the highest speedup. The teal Self-SD bars are always taller than the orange Vanilla bars but shorter than the blue SWIFT bars. The orange Vanilla bars are all at the baseline of 1.00x.
**2. Token Acceptance (Line Chart - Secondary Y-Axis):**
* **SWIFT (Green dashed line with circles):** The line starts high (≈0.98) for Summarization, dips slightly for Reasoning (≈0.95), peaks for Instruction (≈0.98), dips for Translation (≈0.90), and ends high for QA (≈0.95). The trend is generally high and stable, with a notable dip at the Translation task.
* **Self-SD (Gray dashed line with circles):** The line starts moderately high for Summarization (≈0.90), drops significantly for Reasoning (≈0.70), recovers slightly for Instruction (≈0.65), dips again for Translation (≈0.60), and rises slightly for QA (≈0.65). The trend is more volatile and consistently lower than the SWIFT line.
**Spatial Grounding (Lines):** The green SWIFT line is positioned in the upper portion of the chart area, corresponding to values between 0.9 and 1.0 on the right axis. The gray Self-SD line is positioned in the middle to lower portion, corresponding to values between 0.6 and 0.9.
### Key Observations
1. **Dominant Performance of SWIFT:** The SWIFT method (blue bars, green line) outperforms the other two methods on both metrics across all five tasks. Its speedup advantage is most pronounced in Summarization (1.56x) and Instruction (1.47x).
2. **Baseline Comparison:** The "Vanilla" method serves as a consistent baseline with a speedup of 1.00x for all tasks. It has no associated token acceptance data.
3. **Self-SD Performance:** Self-SD provides a modest speedup over Vanilla (ranging from 1.02x to 1.28x) but exhibits significantly lower and more variable token acceptance rates compared to SWIFT.
4. **Task-Specific Anomaly:** The "Translation" task shows the smallest speedup advantage for SWIFT (1.27x) and the lowest token acceptance point for both SWIFT (≈0.90) and Self-SD (≈0.60), suggesting it may be a more challenging task for these methods.
5. **Metric Relationship:** There is a positive correlation between higher speedup and higher token acceptance when comparing the SWIFT and Self-SD methods. SWIFT leads in both.
### Interpretation
This chart presents a compelling case for the SWIFT method as a superior optimization technique. The data suggests that SWIFT not only accelerates model inference (higher Speedup) but does so while maintaining or even improving the quality or acceptance rate of the generated tokens (higher Token Acceptance). This is a significant finding, as optimizations often trade off speed for quality.
The consistent underperformance of Self-SD relative to SWIFT on both metrics indicates that the mechanism behind SWIFT is more effective. The Vanilla baseline's flat 1.00x speedup confirms it is the unoptimized reference point.
The dip in performance for the "Translation" task for all methods could imply that translation requires a different kind of processing or has inherent complexities that are less amenable to the specific optimizations provided by Self-SD and SWIFT. This identifies a potential area for further investigation and targeted improvement.
In summary, the chart is designed to demonstrate that SWIFT achieves the desirable outcome of making the model faster without compromising—and often improving—the acceptability of its outputs, making it a robust solution across diverse language tasks.
</details>
Figure 7: Comparison between and Self-SD in handling dynamic data input streams. Unlike Self-SD, which suffers from efficiency reduction during distribution shift, maintains stable acceleration performance with an acceptance rate exceeding 0.9.
Dynamic Input Data Streams
We further validate the effectiveness of in handling dynamic input data streams. We selected CNN/DM, GSM8K, Alpaca (Taori et al., 2023), WMT14 DE-EN, and Nature Questions (Kwiatkowski et al., 2019) for the evaluation on summarization, reasoning, instruction following, translation, and question answering tasks, respectively. For each task, we randomly sample 500 instances from the test set and concatenate them task-by-task to form the input stream. The experimental results are presented in Figure 7. As demonstrated, Self-SD is sensitive to domain shifts, with the average token acceptance rate dropping from $92\$ to $68\$ . Consequently, it suffers from severe speedup reduction from $1.33\times$ to an average of $1.05\times$ under domain shifts. In contrast, exhibits promising adaptation capability to different domains with an average token acceptance rate of $96\$ , leading to a consistent $1.3\times$ $\sim$ $1.6\times$ speedup.
<details>
<summary>x8.png Details</summary>

### Visual Description
## Line Graphs: Flexible Optimization Strategy & Scaling Law of SWIFT
### Overview
The image contains two distinct line graphs, labeled (a) and (b), presented side-by-side. Both graphs plot "Speedup" on the y-axis against different independent variables on the x-axis. Graph (a) analyzes the impact of the number of instances on speedup under different optimization parameters. Graph (b) analyzes the impact of a "Layer Skip Ratio" on speedup for different model sizes.
### Components/Axes
**Graph (a): Flexible Optimization Strategy**
* **Title:** (a) Flexible Optimization Strategy
* **Y-axis:** Label: "Speedup". Scale: Linear, ranging from 1.25 to 1.50, with major ticks every 0.05.
* **X-axis:** Label: "# of Instances". Scale: Linear, ranging from 0 to 50, with major ticks every 5.
* **Legend:** Located in the bottom-right quadrant of the plot area. Contains three entries:
1. Blue line with circle markers: `S=1000, β=25`
2. Orange line with circle markers: `S=500, β=25`
3. Green line with circle markers: `S=1000, β=50`
* **Grid:** Light gray grid lines are present for both axes.
**Graph (b): Scaling Law of SWIFT**
* **Title:** (b) Scaling Law of SWIFT
* **Y-axis:** Label: "Speedup". Scale: Linear, ranging from 1.2 to 1.6, with major ticks every 0.1.
* **X-axis:** Label: "Layer Skip Ratio r". Scale: Linear, ranging from 0.30 to 0.60, with major ticks every 0.05.
* **Legend:** Located in the bottom-left quadrant of the plot area. Contains three entries:
1. Blue line with circle markers: `7B`
2. Orange line with circle markers: `13B`
3. Green line with circle markers: `70B`
* **Grid:** Light gray grid lines are present for both axes.
### Detailed Analysis
**Graph (a): Flexible Optimization Strategy**
* **Trend Verification:** All three data series show a clear, monotonically increasing trend with a concave-down shape, indicating diminishing returns as the number of instances grows. The lines do not cross after the initial points.
* **Data Series & Approximate Values:**
* **Blue Line (S=1000, β=25):** Starts lowest at ~1.27 (0 instances). Increases steadily, crossing above the orange line around 10 instances. Reaches the highest final speedup of ~1.49 at 50 instances.
* **Orange Line (S=500, β=25):** Starts at ~1.29 (0 instances). Initially the highest, but is overtaken by the blue line. Follows a similar curve, ending at ~1.47 at 50 instances.
* **Green Line (S=1000, β=50):** Starts at ~1.30 (0 instances). Initially between the other two, but its growth rate is slower. It is overtaken by both the blue and orange lines by around 15 instances. Ends at the lowest final speedup of ~1.45 at 50 instances.
* **Key Observation:** The configuration with the highest `S` and lowest `β` (Blue: S=1000, β=25) achieves the greatest speedup at scale, despite starting the lowest. Increasing `β` from 25 to 50 (comparing Blue vs. Green, both S=1000) significantly reduces the speedup gain from adding instances.
**Graph (b): Scaling Law of SWIFT**
* **Trend Verification:** All three data series show a non-monotonic trend: speedup initially increases with the Layer Skip Ratio `r`, reaches a peak, and then declines sharply. The peak occurs at different `r` values for each model size.
* **Data Series & Approximate Values:**
* **Blue Line (7B):** Starts at ~1.36 (r=0.30). Peaks earliest at ~1.43 around r=0.40. Declines steeply to ~1.23 at r=0.50 (the last data point for this series).
* **Orange Line (13B):** Starts at ~1.46 (r=0.30). Peaks at ~1.56 around r=0.45. Declines to ~1.31 at r=0.55.
* **Green Line (70B):** Starts highest at ~1.48 (r=0.30). Peaks latest and highest at ~1.58 around r=0.50. Declines to ~1.33 at r=0.60.
* **Key Observation:** Larger models (70B) achieve higher peak speedups and can sustain them at higher Layer Skip Ratios (`r`) before performance degrades compared to smaller models (7B, 13B). The optimal `r` value increases with model size.
### Interpretation
The data presents two key insights into system optimization:
1. **Trade-offs in Flexible Optimization (Graph a):** The strategy's effectiveness is highly sensitive to its parameters (`S` and `β`). There is a clear trade-off: a higher `S` (likely representing a scale or buffer parameter) enables greater long-term speedup as more instances are added, but this benefit is negated by increasing `β` (likely a penalty or constraint parameter). The optimal configuration (Blue) requires balancing a high `S` with a low `β` to maximize scalability.
2. **Model-Dependent Scaling Laws (Graph b):** The "SWIFT" system exhibits a scaling law where performance (speedup) is a concave function of the Layer Skip Ratio `r`. This indicates an optimal operating point for skipping computations. Crucially, this optimum is not universal; it shifts to higher `r` values for larger models. This suggests that larger, more over-parameterized models have greater redundancy, allowing more aggressive layer skipping before accuracy or functionality is impaired, leading to higher potential speedups. The sharp decline after the peak warns of a "cliff" where excessive skipping severely harms performance.
**Overall Implication:** Effective optimization requires tailoring parameters to both the system configuration (instance count, `S`, `β`) and the model scale (7B vs. 70B). A one-size-fits-all approach would be suboptimal. The graphs provide an empirical guide for selecting parameters to maximize speedup without crossing critical thresholds that cause performance collapse.
</details>
Figure 8: In-depth analysis of , which includes: (a) Flexible optimization strategy. The maximum optimization iteration $S$ and Bayesian interval $\beta$ can be flexibly adjusted to accommodate different input data types. (b) Scaling law. The speedup and optimal layer skip ratio of increase with larger model sizes, indicating that larger LLMs exhibit greater layer sparsity.
Flexible Optimization & Scaling Law
Figure 8 (a) presents the flexibility of in handling various input types by adjusting the maximum optimization step $S$ and Bayesian interval $\beta$ . For input with fewer instances, reducing $S$ enables an earlier transition to the acceleration phase while increasing $\beta$ reduces the overhead during the optimization phase, enhancing speedups during the initial stages of inference. In cases with sufficient input data, enables exploring more optimization paths, thereby enhancing the overall speedup. Figure 8 (b) illustrates the scaling law of : as the model size increases, both the optimal layer-skip ratio and overall speedup improve, indicating that larger LLMs exhibit more layer sparsity. This finding highlights the potential of for accelerating LLMs of larger sizes (e.g., 175B), which we leave for future investigation.
<details>
<summary>x9.png Details</summary>

### Visual Description
## Grouped Bar Chart: Speedup Comparison of Model Variants
### Overview
This image is a grouped bar chart comparing the "Speedup" metric for two large language models, each with three training variants: Vanilla, Base, and Instruct. The chart visually demonstrates the performance improvement (speedup) of the Base and Instruct variants relative to the Vanilla baseline for each model.
### Components/Axes
* **Chart Type:** Grouped Bar Chart.
* **Y-Axis:**
* **Label:** "Speedup"
* **Scale:** Linear scale ranging from 1.0 to 1.6, with major gridlines at intervals of 0.1 (1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6).
* **X-Axis:**
* **Primary Categories (Model Names):** Two distinct groups labeled "Yi-34B" (left group) and "DeepSeek-Coder-33B" (right group).
* **Legend:**
* **Position:** Centered at the top of the chart area.
* **Items:**
1. **Vanilla:** Represented by an orange color.
2. **Base:** Represented by a medium blue color.
3. **Instruct:** Represented by a teal/greenish-blue color.
* **Data Series:** Each model group contains three bars corresponding to the legend items, ordered from left to right as Vanilla, Base, Instruct.
### Detailed Analysis
The chart presents the following specific data points, confirmed by matching bar colors to the legend and reading the numerical labels placed directly above each bar:
**1. Model: Yi-34B (Left Group)**
* **Vanilla (Orange Bar):** Speedup = **1.00**. This is the baseline value.
* **Base (Blue Bar):** Speedup = **1.31**. This bar is the tallest in the Yi-34B group.
* **Instruct (Teal Bar):** Speedup = **1.26**. This bar is shorter than the Base bar but taller than the Vanilla bar.
**2. Model: DeepSeek-Coder-33B (Right Group)**
* **Vanilla (Orange Bar):** Speedup = **1.00**. This is the baseline value, identical to the Yi-34B Vanilla.
* **Base (Blue Bar):** Speedup = **1.54**. This is the tallest bar in the entire chart.
* **Instruct (Teal Bar):** Speedup = **1.39**. This bar is shorter than the DeepSeek-Coder-33B Base bar but taller than its Vanilla bar.
**Trend Verification:**
* For **Yi-34B**, the visual trend is: Base (highest) > Instruct > Vanilla (lowest).
* For **DeepSeek-Coder-33B**, the visual trend is: Base (highest) > Instruct > Vanilla (lowest).
* Comparing across models, both the Base and Instruct variants of DeepSeek-Coder-33B show a higher speedup than their counterparts in Yi-34B.
### Key Observations
1. **Baseline Consistency:** The "Vanilla" variant for both models is set as the baseline with a Speedup value of exactly 1.00.
2. **Performance Hierarchy:** For both models, the "Base" variant achieves the highest speedup, followed by the "Instruct" variant, with "Vanilla" performing the worst.
3. **Model Comparison:** DeepSeek-Coder-33B shows a greater relative improvement from its Base training (1.54 vs. 1.31) and a slightly greater improvement from its Instruct training (1.39 vs. 1.26) compared to Yi-34B.
4. **Magnitude of Improvement:** The most significant single improvement shown is the DeepSeek-Coder-33B Base variant, which is 54% faster than its Vanilla baseline.
### Interpretation
The data suggests that the training methodology significantly impacts inference or processing speedup for these models. The "Base" training approach consistently yields the greatest speedup, indicating it may be the most optimized for raw performance. The "Instruct" variant, while faster than "Vanilla," is slower than "Base," which could imply that adding instruction-following capabilities introduces some computational overhead compared to the base-optimized model.
The fact that DeepSeek-Coder-33B achieves higher speedup values in its optimized variants (Base and Instruct) than Yi-34B could indicate several possibilities: the DeepSeek architecture may be more amenable to these optimization techniques, the training data or process for its variants was more effective for speed, or the baseline "Vanilla" performance of DeepSeek-Coder-33B was different (though both are normalized to 1.00 here). This chart effectively argues that choosing the correct model variant (Base over Instruct or Vanilla) is crucial for maximizing speed, and that the DeepSeek-Coder-33B model, when using its Base variant, offers the highest performance in this specific benchmark.
</details>
Figure 9: Speedups of on LLM backbones and their instruction-tuned variants.
Other LLM Backbones
Beyond LLaMA, we assess the effectiveness of on additional LLM backbones. Specifically, we include Yi-34B (Young et al., 2024) and DeepSeek-Coder-33B (Guo et al., 2024) along with their instruction-tuned variants for text and code generation tasks, respectively. The speedup results of are illustrated in Figure 9, demonstrating that achieves efficiency improvements ranging from $26\$ to $54\$ on these LLM backbones. Further experimental details are provided in Appendix C.3.
## 6 Conclusion
In this work, we introduce , an on-the-fly self-speculative decoding algorithm that adaptively selects certain intermediate layers of LLMs to skip during inference. The proposed method does not require additional training or auxiliary models, making it a plug-and-play solution for accelerating LLM inference across diverse input data streams. Extensive experiments conducted across various LLMs and tasks demonstrate that achieves over a $1.3\times$ $\sim$ $1.6\times$ speedup while preserving the distribution of the generated text. Furthermore, our in-depth analysis highlights the effectiveness of in handling dynamic input data streams and its seamless integration with various LLM backbones, showcasing the great potential of this paradigm for practical LLM inference acceleration.
## Ethics Statement
The datasets used in our experiments are publicly released and labeled through interaction with humans in English. In this process, user privacy is protected, and no personal information is contained in the dataset. The scientific artifacts that we used are available for research with permissive licenses. The use of these artifacts in this paper is consistent with their intended purpose.
## Acknowledgements
We thank all anonymous reviewers for their valuable comments during the review process. The work described in this paper was supported by Research Grants Council of Hong Kong (PolyU/15207122, PolyU/15209724, PolyU/15207821, PolyU/15213323) and PolyU internal grants (BDWP).
## Reproducibility Statement
All the results in this work are reproducible. We provide all the necessary code in the Supplementary Material to replicate our results. The repository includes environment configurations, scripts, and other relevant materials. We discuss the experimental settings in Section 5.1 and Appendix C, including implementation details such as models, datasets, inference setup, and evaluation metrics.
## References
- Ankner et al. (2024) Zachary Ankner, Rishab Parthasarathy, Aniruddha Nrusimha, Christopher Rinard, Jonathan Ragan-Kelley, and William Brandon. Hydra: Sequentially-dependent draft heads for medusa decoding. CoRR, abs/2402.05109, 2024. doi: 10.48550/ARXIV.2402.05109. URL https://doi.org/10.48550/arXiv.2402.05109.
- Bae et al. (2023) Sangmin Bae, Jongwoo Ko, Hwanjun Song, and Se-Young Yun. Fast and robust early-exiting framework for autoregressive language models with synchronized parallel decoding. In Houda Bouamor, Juan Pino, and Kalika Bali (eds.), Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing, pp. 5910–5924, Singapore, December 2023. Association for Computational Linguistics. doi: 10.18653/v1/2023.emnlp-main.362. URL https://aclanthology.org/2023.emnlp-main.362.
- Cai et al. (2024) Tianle Cai, Yuhong Li, Zhengyang Geng, Hongwu Peng, Jason D. Lee, Deming Chen, and Tri Dao. Medusa: Simple LLM inference acceleration framework with multiple decoding heads. In Forty-first International Conference on Machine Learning, ICML 2024, Vienna, Austria, July 21-27, 2024. OpenReview.net, 2024. URL https://openreview.net/forum?id=PEpbUobfJv.
- Chen et al. (2023) Charlie Chen, Sebastian Borgeaud, Geoffrey Irving, Jean-Baptiste Lespiau, Laurent Sifre, and John Jumper. Accelerating large language model decoding with speculative sampling. CoRR, abs/2302.01318, 2023. doi: 10.48550/arXiv.2302.01318. URL https://doi.org/10.48550/arXiv.2302.01318.
- Chen et al. (2021) Mark Chen, Jerry Tworek, Heewoo Jun, Qiming Yuan, Henrique Pondé de Oliveira Pinto, Jared Kaplan, Harrison Edwards, et al. Evaluating large language models trained on code. CoRR, abs/2107.03374, 2021. URL https://arxiv.org/abs/2107.03374.
- Cobbe et al. (2021) Karl Cobbe, Vineet Kosaraju, Mohammad Bavarian, Mark Chen, Heewoo Jun, Lukasz Kaiser, Matthias Plappert, Jerry Tworek, Jacob Hilton, Reiichiro Nakano, Christopher Hesse, and John Schulman. Training verifiers to solve math word problems. CoRR, abs/2110.14168, 2021. URL https://arxiv.org/abs/2110.14168.
- Corro et al. (2023) Luciano Del Corro, Allie Del Giorno, Sahaj Agarwal, Bin Yu, Ahmed Awadallah, and Subhabrata Mukherjee. Skipdecode: Autoregressive skip decoding with batching and caching for efficient LLM inference. CoRR, abs/2307.02628, 2023. doi: 10.48550/ARXIV.2307.02628. URL https://doi.org/10.48550/arXiv.2307.02628.
- Dettmers et al. (2022) Tim Dettmers, Mike Lewis, Younes Belkada, and Luke Zettlemoyer. Gpt3.int8(): 8-bit matrix multiplication for transformers at scale. In Sanmi Koyejo, S. Mohamed, A. Agarwal, Danielle Belgrave, K. Cho, and A. Oh (eds.), Advances in Neural Information Processing Systems 35: Annual Conference on Neural Information Processing Systems 2022, NeurIPS 2022, New Orleans, LA, USA, November 28 - December 9, 2022, 2022. URL http://papers.nips.cc/paper_files/paper/2022/hash/c3ba4962c05c49636d4c6206a97e9c8a-Abstract-Conference.html.
- Du et al. (2024) Cunxiao Du, Jing Jiang, Yuanchen Xu, Jiawei Wu, Sicheng Yu, Yongqi Li, Shenggui Li, Kai Xu, Liqiang Nie, Zhaopeng Tu, and Yang You. Glide with a cape: A low-hassle method to accelerate speculative decoding. In Forty-first International Conference on Machine Learning, ICML 2024, Vienna, Austria, July 21-27, 2024. OpenReview.net, 2024. URL https://openreview.net/forum?id=mk8oRhox2l.
- Dubey et al. (2024) Abhimanyu Dubey, Abhinav Jauhri, Abhinav Pandey, Abhishek Kadian, Ahmad Al-Dahle, et al. The llama 3 herd of models, 2024. URL https://arxiv.org/abs/2407.21783.
- Eldan & Li (2023) Ronen Eldan and Yuanzhi Li. Tinystories: How small can language models be and still speak coherent english? CoRR, abs/2305.07759, 2023. doi: 10.48550/ARXIV.2305.07759. URL https://doi.org/10.48550/arXiv.2305.07759.
- Elhoushi et al. (2024) Mostafa Elhoushi, Akshat Shrivastava, Diana Liskovich, Basil Hosmer, Bram Wasti, Liangzhen Lai, Anas Mahmoud, Bilge Acun, Saurabh Agarwal, Ahmed Roman, Ahmed Aly, Beidi Chen, and Carole-Jean Wu. LayerSkip: Enabling early exit inference and self-speculative decoding. In Lun-Wei Ku, Andre Martins, and Vivek Srikumar (eds.), Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 12622–12642, Bangkok, Thailand, August 2024. Association for Computational Linguistics. URL https://aclanthology.org/2024.acl-long.681.
- Frantar et al. (2023) Elias Frantar, Saleh Ashkboos, Torsten Hoefler, and Dan Alistarh. OPTQ: Accurate quantization for generative pre-trained transformers. In The Eleventh International Conference on Learning Representations, 2023. URL https://openreview.net/forum?id=tcbBPnfwxS.
- Fu et al. (2024) Yichao Fu, Peter Bailis, Ion Stoica, and Hao Zhang. Break the sequential dependency of LLM inference using lookahead decoding. In Forty-first International Conference on Machine Learning, ICML 2024, Vienna, Austria, July 21-27, 2024. OpenReview.net, 2024. URL https://openreview.net/forum?id=eDjvSFOkXw.
- Gloeckle et al. (2024) Fabian Gloeckle, Badr Youbi Idrissi, Baptiste Rozière, David Lopez-Paz, and Gabriel Synnaeve. Better & faster large language models via multi-token prediction. CoRR, abs/2404.19737, 2024. doi: 10.48550/ARXIV.2404.19737. URL https://doi.org/10.48550/arXiv.2404.19737.
- Gu et al. (2024) Yuxian Gu, Li Dong, Furu Wei, and Minlie Huang. MiniLLM: Knowledge distillation of large language models. In The Twelfth International Conference on Learning Representations, 2024. URL https://openreview.net/forum?id=5h0qf7IBZZ.
- Guo et al. (2024) Daya Guo, Qihao Zhu, Dejian Yang, Zhenda Xie, Kai Dong, Wentao Zhang, Guanting Chen, Xiao Bi, Y. Wu, Y. K. Li, Fuli Luo, Yingfei Xiong, and Wenfeng Liang. Deepseek-coder: When the large language model meets programming - the rise of code intelligence. CoRR, abs/2401.14196, 2024. doi: 10.48550/ARXIV.2401.14196. URL https://doi.org/10.48550/arXiv.2401.14196.
- He et al. (2024) Zhenyu He, Zexuan Zhong, Tianle Cai, Jason Lee, and Di He. REST: Retrieval-based speculative decoding. In Kevin Duh, Helena Gomez, and Steven Bethard (eds.), Proceedings of the 2024 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies (Volume 1: Long Papers), pp. 1582–1595, Mexico City, Mexico, June 2024. Association for Computational Linguistics. URL https://aclanthology.org/2024.naacl-long.88.
- Hoefler et al. (2021) Torsten Hoefler, Dan Alistarh, Tal Ben-Nun, Nikoli Dryden, and Alexandra Peste. Sparsity in deep learning: Pruning and growth for efficient inference and training in neural networks. J. Mach. Learn. Res., 22(241):1–124, 2021.
- Hooper et al. (2023) Coleman Hooper, Sehoon Kim, Hiva Mohammadzadeh, Hasan Genc, Kurt Keutzer, Amir Gholami, and Yakun Sophia Shao. SPEED: speculative pipelined execution for efficient decoding. CoRR, abs/2310.12072, 2023. doi: 10.48550/ARXIV.2310.12072. URL https://doi.org/10.48550/arXiv.2310.12072.
- Hsieh et al. (2023) Cheng-Yu Hsieh, Chun-Liang Li, Chih-Kuan Yeh, Hootan Nakhost, Yasuhisa Fujii, Alex Ratner, Ranjay Krishna, Chen-Yu Lee, and Tomas Pfister. Distilling step-by-step! outperforming larger language models with less training data and smaller model sizes. In Anna Rogers, Jordan L. Boyd-Graber, and Naoaki Okazaki (eds.), Findings of the Association for Computational Linguistics: ACL 2023, Toronto, Canada, July 9-14, 2023, pp. 8003–8017. Association for Computational Linguistics, 2023. doi: 10.18653/V1/2023.FINDINGS-ACL.507. URL https://doi.org/10.18653/v1/2023.findings-acl.507.
- Hu et al. (2022) Edward J. Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen. Lora: Low-rank adaptation of large language models. In The Tenth International Conference on Learning Representations, ICLR 2022, Virtual Event, April 25-29, 2022. OpenReview.net, 2022. URL https://openreview.net/forum?id=nZeVKeeFYf9.
- Jaiswal et al. (2024) Ajay Jaiswal, Bodun Hu, Lu Yin, Yeonju Ro, Shiwei Liu, Tianlong Chen, and Aditya Akella. Ffn-skipllm: A hidden gem for autoregressive decoding with adaptive feed forward skipping. CoRR, abs/2404.03865, 2024. doi: 10.48550/ARXIV.2404.03865. URL https://doi.org/10.48550/arXiv.2404.03865.
- Jones et al. (1998) Donald R. Jones, Matthias Schonlau, and William J. Welch. Efficient global optimization of expensive black-box functions. J. Glob. Optim., 13(4):455–492, 1998. doi: 10.1023/A:1008306431147. URL https://doi.org/10.1023/A:1008306431147.
- Kim et al. (2023) Sehoon Kim, Karttikeya Mangalam, Suhong Moon, Jitendra Malik, Michael W. Mahoney, Amir Gholami, and Kurt Keutzer. Speculative decoding with big little decoder. In Alice Oh, Tristan Naumann, Amir Globerson, Kate Saenko, Moritz Hardt, and Sergey Levine (eds.), Advances in Neural Information Processing Systems 36: Annual Conference on Neural Information Processing Systems 2023, NeurIPS 2023, New Orleans, LA, USA, December 10 - 16, 2023, 2023. URL http://papers.nips.cc/paper_files/paper/2023/hash/7b97adeafa1c51cf65263459ca9d0d7c-Abstract-Conference.html.
- Kim et al. (2024) Taehyeon Kim, Ananda Theertha Suresh, Kishore A Papineni, Michael Riley, Sanjiv Kumar, and Adrian Benton. Accelerating blockwise parallel language models with draft refinement. In The Thirty-eighth Annual Conference on Neural Information Processing Systems, 2024. URL https://openreview.net/forum?id=KT6F5Sw0eg.
- Kou et al. (2024) Siqi Kou, Lanxiang Hu, Zhezhi He, Zhijie Deng, and Hao Zhang. Cllms: Consistency large language models. In Forty-first International Conference on Machine Learning, ICML 2024, Vienna, Austria, July 21-27, 2024. OpenReview.net, 2024. URL https://openreview.net/forum?id=8uzBOVmh8H.
- Kwiatkowski et al. (2019) Tom Kwiatkowski, Jennimaria Palomaki, Olivia Redfield, Michael Collins, Ankur Parikh, Chris Alberti, Danielle Epstein, Illia Polosukhin, Jacob Devlin, Kenton Lee, Kristina Toutanova, Llion Jones, Matthew Kelcey, Ming-Wei Chang, Andrew M. Dai, Jakob Uszkoreit, Quoc Le, and Slav Petrov. Natural questions: A benchmark for question answering research. Transactions of the Association for Computational Linguistics, 7:452–466, 2019. doi: 10.1162/tacl˙a˙00276. URL https://aclanthology.org/Q19-1026.
- Leviathan et al. (2023) Yaniv Leviathan, Matan Kalman, and Yossi Matias. Fast inference from transformers via speculative decoding. In Andreas Krause, Emma Brunskill, Kyunghyun Cho, Barbara Engelhardt, Sivan Sabato, and Jonathan Scarlett (eds.), International Conference on Machine Learning, ICML 2023, 23-29 July 2023, Honolulu, Hawaii, USA, volume 202 of Proceedings of Machine Learning Research, pp. 19274–19286. PMLR, 2023. URL https://proceedings.mlr.press/v202/leviathan23a.html.
- Li et al. (2024a) Yuhui Li, Fangyun Wei, Chao Zhang, and Hongyang Zhang. Eagle: Speculative sampling requires rethinking feature uncertainty, 2024a.
- Li et al. (2024b) Yuhui Li, Fangyun Wei, Chao Zhang, and Hongyang Zhang. EAGLE-2: faster inference of language models with dynamic draft trees. CoRR, abs/2406.16858, 2024b. doi: 10.48550/ARXIV.2406.16858. URL https://doi.org/10.48550/arXiv.2406.16858.
- Liu et al. (2023a) Xiaoxuan Liu, Lanxiang Hu, Peter Bailis, Ion Stoica, Zhijie Deng, Alvin Cheung, and Hao Zhang. Online speculative decoding. CoRR, abs/2310.07177, 2023a. doi: 10.48550/ARXIV.2310.07177. URL https://doi.org/10.48550/arXiv.2310.07177.
- Liu et al. (2024) Yijin Liu, Fandong Meng, and Jie Zhou. Accelerating inference in large language models with a unified layer skipping strategy. CoRR, abs/2404.06954, 2024. doi: 10.48550/ARXIV.2404.06954. URL https://doi.org/10.48550/arXiv.2404.06954.
- Liu et al. (2019) Zhuang Liu, Mingjie Sun, Tinghui Zhou, Gao Huang, and Trevor Darrell. Rethinking the value of network pruning. In 7th International Conference on Learning Representations, ICLR 2019, New Orleans, LA, USA, May 6-9, 2019. OpenReview.net, 2019. URL https://openreview.net/forum?id=rJlnB3C5Ym.
- Liu et al. (2023b) Zichang Liu, Jue Wang, Tri Dao, Tianyi Zhou, Binhang Yuan, Zhao Song, Anshumali Shrivastava, Ce Zhang, Yuandong Tian, Christopher Re, et al. Deja vu: Contextual sparsity for efficient llms at inference time. In International Conference on Machine Learning, pp. 22137–22176. PMLR, 2023b.
- Ma et al. (2024) Shuming Ma, Hongyu Wang, Lingxiao Ma, Lei Wang, Wenhui Wang, Shaohan Huang, Li Dong, Ruiping Wang, Jilong Xue, and Furu Wei. The era of 1-bit llms: All large language models are in 1.58 bits. CoRR, abs/2402.17764, 2024. doi: 10.48550/ARXIV.2402.17764. URL https://doi.org/10.48550/arXiv.2402.17764.
- Miao et al. (2024) Xupeng Miao, Gabriele Oliaro, Zhihao Zhang, Xinhao Cheng, Zeyu Wang, Zhengxin Zhang, Rae Ying Yee Wong, Alan Zhu, Lijie Yang, Xiaoxiang Shi, Chunan Shi, Zhuoming Chen, Daiyaan Arfeen, Reyna Abhyankar, and Zhihao Jia. Specinfer: Accelerating large language model serving with tree-based speculative inference and verification. In Proceedings of the 29th ACM International Conference on Architectural Support for Programming Languages and Operating Systems, Volume 3, ASPLOS ’24, pp. 932–949, New York, NY, USA, 2024. Association for Computing Machinery. ISBN 9798400703867. doi: 10.1145/3620666.3651335. URL https://doi.org/10.1145/3620666.3651335.
- Nallapati et al. (2016) Ramesh Nallapati, Bowen Zhou, Cícero Nogueira dos Santos, Çaglar Gülçehre, and Bing Xiang. Abstractive text summarization using sequence-to-sequence rnns and beyond. In Yoav Goldberg and Stefan Riezler (eds.), Proceedings of the 20th SIGNLL Conference on Computational Natural Language Learning, CoNLL 2016, Berlin, Germany, August 11-12, 2016, pp. 280–290. ACL, 2016. doi: 10.18653/V1/K16-1028. URL https://doi.org/10.18653/v1/k16-1028.
- OpenAI (2023) OpenAI. GPT-4 technical report. CoRR, abs/2303.08774, 2023. doi: 10.48550/ARXIV.2303.08774. URL https://doi.org/10.48550/arXiv.2303.08774.
- Patterson (2004) David A. Patterson. Latency lags bandwith. Commun. ACM, 47(10):71–75, 2004. doi: 10.1145/1022594.1022596. URL https://doi.org/10.1145/1022594.1022596.
- Pope et al. (2023) Reiner Pope, Sholto Douglas, Aakanksha Chowdhery, Jacob Devlin, James Bradbury, Jonathan Heek, Kefan Xiao, Shivani Agrawal, and Jeff Dean. Efficiently scaling transformer inference. In Dawn Song, Michael Carbin, and Tianqi Chen (eds.), Proceedings of the Sixth Conference on Machine Learning and Systems, MLSys 2023, Miami, FL, USA, June 4-8, 2023. mlsys.org, 2023. URL https://proceedings.mlsys.org/paper_files/paper/2023/hash/c4be71ab8d24cdfb45e3d06dbfca2780-Abstract-mlsys2023.html.
- Rasmussen & Williams (2006) Carl Edward Rasmussen and Christopher K. I. Williams. Gaussian processes for machine learning. Adaptive computation and machine learning. MIT Press, 2006. ISBN 026218253X. URL https://www.worldcat.org/oclc/61285753.
- Rozière et al. (2023) Baptiste Rozière, Jonas Gehring, Fabian Gloeckle, Sten Sootla, Itai Gat, Xiaoqing Ellen Tan, Yossi Adi, Jingyu Liu, Tal Remez, Jérémy Rapin, Artyom Kozhevnikov, Ivan Evtimov, Joanna Bitton, Manish Bhatt, Cristian Canton-Ferrer, Aaron Grattafiori, Wenhan Xiong, Alexandre Défossez, Jade Copet, Faisal Azhar, Hugo Touvron, Louis Martin, Nicolas Usunier, Thomas Scialom, and Gabriel Synnaeve. Code llama: Open foundation models for code. CoRR, abs/2308.12950, 2023. doi: 10.48550/ARXIV.2308.12950. URL https://doi.org/10.48550/arXiv.2308.12950.
- Santilli et al. (2023) Andrea Santilli, Silvio Severino, Emilian Postolache, Valentino Maiorca, Michele Mancusi, Riccardo Marin, and Emanuele Rodolà. Accelerating transformer inference for translation via parallel decoding. In Anna Rogers, Jordan L. Boyd-Graber, and Naoaki Okazaki (eds.), Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), ACL 2023, Toronto, Canada, July 9-14, 2023, pp. 12336–12355. Association for Computational Linguistics, 2023. doi: 10.18653/v1/2023.acl-long.689. URL https://doi.org/10.18653/v1/2023.acl-long.689.
- Shazeer (2019) Noam Shazeer. Fast transformer decoding: One write-head is all you need. CoRR, abs/1911.02150, 2019. URL http://arxiv.org/abs/1911.02150.
- Stern et al. (2018) Mitchell Stern, Noam Shazeer, and Jakob Uszkoreit. Blockwise parallel decoding for deep autoregressive models. In Samy Bengio, Hanna M. Wallach, Hugo Larochelle, Kristen Grauman, Nicolò Cesa-Bianchi, and Roman Garnett (eds.), Advances in Neural Information Processing Systems 31: Annual Conference on Neural Information Processing Systems 2018, NeurIPS 2018, December 3-8, 2018, Montréal, Canada, pp. 10107–10116, 2018. URL https://proceedings.neurips.cc/paper/2018/hash/c4127b9194fe8562c64dc0f5bf2c93bc-Abstract.html.
- Sun et al. (2023) Ziteng Sun, Ananda Theertha Suresh, Jae Hun Ro, Ahmad Beirami, Himanshu Jain, and Felix Yu. Spectr: Fast speculative decoding via optimal transport. In Thirty-seventh Conference on Neural Information Processing Systems, 2023. URL https://openreview.net/forum?id=SdYHLTCC5J.
- Taori et al. (2023) Rohan Taori, Ishaan Gulrajani, Tianyi Zhang, Yann Dubois, Xuechen Li, Carlos Guestrin, Percy Liang, and Tatsunori B. Hashimoto. Stanford alpaca: An instruction-following llama model. https://github.com/tatsu-lab/stanford_alpaca, 2023.
- Touvron et al. (2021) Hugo Touvron, Matthieu Cord, Matthijs Douze, Francisco Massa, Alexandre Sablayrolles, and Hervé Jégou. Training data-efficient image transformers & distillation through attention. In International Conference on Machine Learning, pp. 10347–10357. PMLR, 2021.
- Touvron et al. (2023a) Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothée Lacroix, Baptiste Rozière, Naman Goyal, Eric Hambro, Faisal Azhar, Aurélien Rodriguez, Armand Joulin, Edouard Grave, and Guillaume Lample. Llama: Open and efficient foundation language models. CoRR, abs/2302.13971, 2023a. doi: 10.48550/arXiv.2302.13971. URL https://doi.org/10.48550/arXiv.2302.13971.
- Touvron et al. (2023b) Hugo Touvron, Louis Martin, Kevin Stone, Peter Albert, Amjad Almahairi, Yasmine Babaei, et al. Llama 2: Open foundation and fine-tuned chat models. CoRR, abs/2307.09288, 2023b. doi: 10.48550/ARXIV.2307.09288. URL https://doi.org/10.48550/arXiv.2307.09288.
- Xia et al. (2023) Heming Xia, Tao Ge, Peiyi Wang, Si-Qing Chen, Furu Wei, and Zhifang Sui. Speculative decoding: Exploiting speculative execution for accelerating seq2seq generation. In Houda Bouamor, Juan Pino, and Kalika Bali (eds.), Findings of the Association for Computational Linguistics: EMNLP 2023, Singapore, December 6-10, 2023, pp. 3909–3925. Association for Computational Linguistics, 2023. doi: 10.18653/V1/2023.FINDINGS-EMNLP.257. URL https://doi.org/10.18653/v1/2023.findings-emnlp.257.
- Xia et al. (2024) Heming Xia, Zhe Yang, Qingxiu Dong, Peiyi Wang, Yongqi Li, Tao Ge, Tianyu Liu, Wenjie Li, and Zhifang Sui. Unlocking efficiency in large language model inference: A comprehensive survey of speculative decoding. In Lun-Wei Ku, Andre Martins, and Vivek Srikumar (eds.), Findings of the Association for Computational Linguistics ACL 2024, pp. 7655–7671, Bangkok, Thailand and virtual meeting, August 2024. Association for Computational Linguistics. URL https://aclanthology.org/2024.findings-acl.456.
- Yang et al. (2023) Seongjun Yang, Gibbeum Lee, Jaewoong Cho, Dimitris S. Papailiopoulos, and Kangwook Lee. Predictive pipelined decoding: A compute-latency trade-off for exact LLM decoding. CoRR, abs/2307.05908, 2023. doi: 10.48550/ARXIV.2307.05908. URL https://doi.org/10.48550/arXiv.2307.05908.
- Yi et al. (2024) Hanling Yi, Feng Lin, Hongbin Li, Ning Peiyang, Xiaotian Yu, and Rong Xiao. Generation meets verification: Accelerating large language model inference with smart parallel auto-correct decoding. In Lun-Wei Ku, Andre Martins, and Vivek Srikumar (eds.), Findings of the Association for Computational Linguistics ACL 2024, pp. 5285–5299, Bangkok, Thailand and virtual meeting, August 2024. Association for Computational Linguistics. URL https://aclanthology.org/2024.findings-acl.313.
- Young et al. (2024) Alex Young, Bei Chen, Chao Li, Chengen Huang, Ge Zhang, Guanwei Zhang, Heng Li, Jiangcheng Zhu, Jianqun Chen, Jing Chang, Kaidong Yu, Peng Liu, Qiang Liu, Shawn Yue, Senbin Yang, Shiming Yang, Tao Yu, Wen Xie, Wenhao Huang, Xiaohui Hu, Xiaoyi Ren, Xinyao Niu, Pengcheng Nie, Yuchi Xu, Yudong Liu, Yue Wang, Yuxuan Cai, Zhenyu Gu, Zhiyuan Liu, and Zonghong Dai. Yi: Open foundation models by 01.ai. CoRR, abs/2403.04652, 2024. doi: 10.48550/ARXIV.2403.04652. URL https://doi.org/10.48550/arXiv.2403.04652.
- Zhang et al. (2024) Jun Zhang, Jue Wang, Huan Li, Lidan Shou, Ke Chen, Gang Chen, and Sharad Mehrotra. Draft& verify: Lossless large language model acceleration via self-speculative decoding. In Lun-Wei Ku, Andre Martins, and Vivek Srikumar (eds.), Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 11263–11282, Bangkok, Thailand, August 2024. Association for Computational Linguistics. URL https://aclanthology.org/2024.acl-long.607.
- Zhou et al. (2024) Yongchao Zhou, Kaifeng Lyu, Ankit Singh Rawat, Aditya Krishna Menon, Afshin Rostamizadeh, Sanjiv Kumar, Jean-François Kagy, and Rishabh Agarwal. Distillspec: Improving speculative decoding via knowledge distillation. In The Twelfth International Conference on Learning Representations, 2024. URL https://openreview.net/forum?id=rsY6J3ZaTF.
- Zhu et al. (2024) Yunqi Zhu, Xuebing Yang, Yuanyuan Wu, and Wensheng Zhang. Hierarchical skip decoding for efficient autoregressive text generation. CoRR, abs/2403.14919, 2024. doi: 10.48550/ARXIV.2403.14919. URL https://doi.org/10.48550/arXiv.2403.14919.
## Appendix
## Appendix A Preliminary Details
We present the detailed configuration of Self-SD across four task domains in Figure 10, demonstrating that the optimal skipped layer configurations vary depending on the specific task.
<details>
<summary>x10.png Details</summary>

### Visual Description
## Table Diagram: MLP and ATT Layer/Unit Selection
### Overview
The image displays a two-row table or diagram comparing two entities labeled "MLP" and "ATT". Each row contains a sequence of numbers, with specific numbers highlighted in color. The layout suggests a representation of selected layers, units, or indices within two different model architectures or components.
### Components/Axes
* **Row Labels (Left-aligned):**
* Top Row: `MLP`
* Bottom Row: `ATT`
* **Data Series:** Each row consists of a horizontal sequence of numbers contained within individual cells.
* **Color Legend (Implicit):**
* **Blue Highlight:** Applied to specific numbers in the `MLP` row.
* **Red Highlight:** Applied to specific numbers in the `ATT` row.
* **Spatial Layout:** The `MLP` row is positioned directly above the `ATT` row. The numbers within each row are arranged sequentially from left to right.
### Detailed Analysis
**1. MLP Row (Top Row):**
* **Trend/Pattern:** The numbers form a near-complete sequence of even numbers from 2 to 80. The highlighted (blue) cells form a continuous block.
* **Full Sequence (Visible Numbers):** 2, 4, 6, 8, 10, 12, 14, **16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76**, 78, 80.
* **Highlighted (Blue) Values:** 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76.
* **Observation:** The blue highlight covers a contiguous range from 16 to 76, inclusive. This represents 31 consecutive even numbers.
**2. ATT Row (Bottom Row):**
* **Trend/Pattern:** The numbers form a near-complete sequence of odd numbers from 1 to 79. The highlighted (red) cells are scattered, forming several distinct clusters.
* **Full Sequence (Visible Numbers):** 1, 3, **5**, 7, 9, **11**, 13, **15**, 17, 19, **21, 23**, 25, 27, **29**, 31, **33**, 35, 37, 39, 41, **43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65**, 67, **69, 71, 73**, 75, 77, 79.
* **Highlighted (Red) Values:** 5, 11, 15, 21, 23, 29, 33, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 69, 71, 73.
* **Observation:** The red highlights are not contiguous. They appear as:
* Isolated points: 5, 11, 15, 29, 33.
* A pair: 21, 23.
* A large, dense block: 43 through 65 (all odd numbers in this range).
* A final cluster: 69, 71, 73.
### Key Observations
1. **Structural Contrast:** The `MLP` selection is a single, unbroken block of indices. The `ATT` selection is fragmented, with one large central block and several smaller, outlying selections.
2. **Index Parity:** The `MLP` row exclusively uses even numbers, while the `ATT` row exclusively uses odd numbers. This suggests a deliberate separation or interleaving scheme.
3. **Density:** The `ATT` row has a higher density of highlighted cells in the middle-to-late section (43-65) compared to the `MLP` row's uniform block.
4. **Spatial Grounding:** The legend (color meaning) is defined by the row label. Blue is always associated with `MLP` (top row), and red is always associated with `ATT` (bottom row). There is no separate legend box; the association is positional.
### Interpretation
This diagram likely visualizes the **selection or activation pattern of layers, attention heads, or neurons** in a neural network analysis. The labels `MLP` (Multi-Layer Perceptron) and `ATT` (Attention) are standard components in transformer architectures.
* **What the data suggests:** The pattern implies a comparative study. The `MLP` component has a broad, continuous region of interest (layers/units 16-76). In contrast, the `ATT` component shows a more complex, non-uniform pattern of importance, with a highly active core (43-65) and several specific, isolated points of interest earlier in the sequence.
* **How elements relate:** The two rows are directly comparable, sharing the same numerical index space (though parity differs). The visualization allows for immediate comparison of the "footprint" of each component type across the same index range.
* **Notable anomalies/patterns:** The strict even/odd separation is the most striking pattern. It could indicate that the indices represent two interleaved sequences (e.g., even indices for one model stream, odd for another) or that the analysis was performed on two distinct, non-overlapping sets of units. The large, contiguous block in `ATT` (43-65) suggests a critical functional module within the attention mechanism, while the scattered early points (5, 11, 15, etc.) may represent specialized or early-processing attention heads.
</details>
(a) Summarization - CNN/DM
<details>
<summary>x11.png Details</summary>

### Visual Description
## Categorical Heatmap: MLP vs. ATT Number Series
### Overview
The image displays a two-row categorical heatmap or chart. Each row is labeled with an acronym ("MLP" and "ATT") and contains a sequence of numbers from 1 to 80. The numbers are presented in individual cells, with specific numbers highlighted in either blue or red. The chart appears to compare two different models, methods, or categories (MLP and ATT) across a common set of numerical identifiers or indices.
### Components/Axes
* **Row Labels (Left Side):**
* Top Row: `MLP`
* Bottom Row: `ATT`
* **Column/Cell Labels:** Each cell contains a number, forming a sequence from 1 to 80 across the two rows. The numbers are not in strict sequential order per row but are interleaved.
* **Color Legend (Implicit):** There is no explicit legend. The colors are used categorically:
* **Blue:** Applied to specific numbers in the `MLP` row.
* **Red:** Applied to specific numbers in the `ATT` row.
* **Neutral/White:** Numbers not highlighted in either color.
### Detailed Analysis
The data is presented in a grid format. Below is the reconstruction of the sequence and color coding for each row.
**Row 1: MLP**
* **Sequence & Color:** The numbers 1 through 80 are listed. The following numbers are highlighted in **blue**: 8, 12, 16, 18, 20, 22, 32, 36, 38, 40, 44, 48, 52, 54, 56, 58, 60, 62, 64, 66, 68, 78.
* **Trend/Pattern:** The blue highlights are not continuous. They appear in clusters, with a dense cluster from 52 to 68 (every even number). The first highlighted number is 8, and the last is 78.
**Row 2: ATT**
* **Sequence & Color:** The numbers 1 through 80 are listed. The following numbers are highlighted in **red**: 7, 11, 15, 19, 21, 25, 31, 33, 39, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 77.
* **Trend/Pattern:** The red highlights also appear in clusters. There is a dense, nearly continuous cluster from 49 to 69 (every odd number). The first highlighted number is 7, and the last is 77.
**Spatial & Cross-Reference Analysis:**
* The legend (color meaning) is embedded directly in the row labels: Blue corresponds to MLP, Red corresponds to ATT.
* The two rows are aligned vertically, allowing for direct column-wise comparison. For example, at column index ~7, the `MLP` row shows a neutral "7" while the `ATT` row shows a red "7".
* There is minimal overlap in the highlighted numbers between the two rows. The sets are largely distinct.
### Key Observations
1. **Distinct Highlight Sets:** The numbers highlighted for MLP (blue) and ATT (red) are almost entirely different. Only a few numbers (e.g., 21, 33, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69) appear in both highlighted sets, but they are colored according to their respective row.
2. **Cluster Density:** Both rows exhibit a dense cluster of highlights in the higher number range (50s-60s). The MLP cluster (52-68) is on even numbers, while the ATT cluster (49-69) is on odd numbers.
3. **Starting Points:** The highlighted sequences begin at different points: MLP at 8, ATT at 7.
4. **Visual Layout:** The chart is a simple, flat design with no gradients or complex textures. The focus is purely on the categorical color coding of the numerical sequence.
### Interpretation
This chart likely visualizes the activation, selection, or performance of two different models or algorithms (MLP and ATT) across a series of test cases, data points, or parameters numbered 1 to 80.
* **What the data suggests:** The distinct color patterns indicate that MLP and ATT respond to or are associated with different subsets of the numbered items. The dense clusters in the 50-70 range for both models might indicate a region of the input space where both models are highly active or where the data points share common characteristics that trigger both models, albeit on different specific indices (even vs. odd).
* **Relationship between elements:** The direct vertical alignment facilitates a point-by-point comparison. One can quickly see, for any given number, whether it is "selected" by MLP, ATT, both, or neither.
* **Notable anomalies/patterns:** The strict separation of highlights into even numbers for MLP and odd numbers for ATT within the main cluster (50s-60s) is a striking pattern. This could be an artifact of the data (e.g., the test set is structured with even/odd splits) or a fundamental difference in how the two models operate. The lack of overlap in the earlier numbers (1-40) suggests the models have very different sensitivities or decision boundaries for that portion of the sequence.
**In summary, this is a comparative visualization showing that two entities, MLP and ATT, have largely non-overlapping associations with a set of 80 numbered items, with both showing concentrated activity in the higher-numbered range but on interleaved (even/odd) indices.**
</details>
(b) Reasoning - GSM8K
<details>
<summary>x12.png Details</summary>

### Visual Description
\n
## Table Diagram: MLP and ATT Layer Activation Indices
### Overview
The image displays a two-row table or diagram comparing two sequences of numerical indices, labeled "MLP" and "ATT". The numbers are arranged horizontally in ascending order. Specific numbers in each row are highlighted with a colored background, suggesting a selection, activation, or grouping of those particular indices. The visual presentation is simple, using a monospaced font on a white background with colored cell highlights.
### Components/Axes
* **Row Labels (Left-aligned):**
* Top Row: `MLP`
* Bottom Row: `ATT`
* **Data Series:** Each row contains a sequence of integers.
* **MLP Row:** Contains even numbers from 2 to 80.
* **ATT Row:** Contains odd numbers from 1 to 79.
* **Highlighting Scheme:**
* **MLP:** Selected numbers are highlighted with a medium blue background.
* **ATT:** Selected numbers are highlighted with a medium red background.
* **Spatial Layout:** The numbers are presented in a single, continuous horizontal line for each row, starting from the left edge. The highlighting is applied to the background of individual number cells.
### Detailed Analysis
**1. MLP Row (Even Numbers, 2-80):**
* **Full Sequence:** 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80.
* **Highlighted (Blue) Indices:** 6, 18, 20, 22, 24, 26, 28, 30, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80.
* **Pattern:** The first highlighted index is 6. After a gap (8-16 are not highlighted), a contiguous block from 18 to 30 is highlighted. Another gap follows (32, 34). From 36 onward, all subsequent even numbers up to 80 are highlighted.
**2. ATT Row (Odd Numbers, 1-79):**
* **Full Sequence:** 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79.
* **Highlighted (Red) Indices:** 5, 17, 21, 23, 33, 43, 45, 49, 53, 63, 67, 73.
* **Pattern:** The highlighting is more sporadic compared to the MLP row. There is no large contiguous block. Highlights appear at seemingly irregular intervals, with some pairs close together (e.g., 21 & 23, 43 & 45) and larger gaps between others.
### Key Observations
1. **Complementary Sequences:** The two rows form complementary sets of integers: MLP uses even numbers, ATT uses odd numbers.
2. **Divergent Highlighting Patterns:** The MLP row shows a clear trend towards **increasing density** of highlighted indices as the numbers increase, culminating in a solid block from 36 to 80. The ATT row maintains a **sparse and irregular** highlighting pattern throughout its range.
3. **Potential Correlation:** There is a loose visual correlation where indices highlighted in one row often have a nearby index highlighted in the other (e.g., MLP 6 / ATT 5, MLP 18 / ATT 17, MLP 42/44 / ATT 43/45). However, this is not a strict one-to-one mapping.
4. **Data Density:** The MLP row contains 40 total numbers with 31 highlighted (77.5% highlighted). The ATT row contains 40 total numbers with 12 highlighted (30% highlighted).
### Interpretation
This diagram likely represents the **activation pattern or selection of layers/units** within two different components of a neural network architecture, specifically a Multi-Layer Perceptron (MLP) and an Attention mechanism (ATT).
* **What the data suggests:** The pattern implies that as the network depth or index increases, the MLP component increasingly utilizes or activates its later layers/units (from index 36 onward). In contrast, the Attention mechanism's usage remains selective and non-contiguous across its entire depth, suggesting it performs specific, targeted computations at certain layers rather than a broad, increasing engagement.
* **Relationship between elements:** The complementary even/odd numbering may simply be a labeling convention to distinguish between the two parallel sequences. The loose correlation between highlighted indices in MLP and ATT could indicate points in the network where both components are actively processing information, potentially for integrated feature transformation.
* **Notable anomaly/trend:** The most significant trend is the **phase shift** in the MLP row. The transition from sporadic highlighting (indices 6, 18-30) to complete saturation (36-80) suggests a potential architectural boundary or a change in the role of the MLP subnetwork at a certain depth. The ATT row's persistent sparsity is characteristic of attention mechanisms, which compute context-dependent weights rather than applying uniform transformations.
**In summary, this is not a chart of measured data but a schematic diagram illustrating the structural activation profile of two model components. It visually argues that the MLP's role becomes dominant and uniform in the later stages, while the Attention mechanism's role remains specialized and selective throughout.**
</details>
(c) Storytelling - TinyStories
<details>
<summary>x13.png Details</summary>

### Visual Description
## Horizontal Sequence Chart: MLP vs. ATT Number Series
### Overview
The image displays a horizontal sequence chart comparing two series of numbers, labeled "MLP" and "ATT". Each series is presented as a row of colored, rectangular boxes containing integers. The chart visually maps out two distinct, interleaved numerical sequences from 1 to 80.
### Components/Axes
* **Row Labels (Left Side):**
* Top Row: `MLP`
* Bottom Row: `ATT`
* **Data Series:**
* **MLP Series:** Represented by a sequence of **blue** boxes.
* **ATT Series:** Represented by a sequence of **red** boxes.
* **Data Points:** Each box contains a single integer. The numbers are arranged in ascending order from left to right within each row.
* **Spatial Layout:** The two rows are stacked vertically. The `MLP` row is positioned directly above the `ATT` row. The boxes within each row are aligned in a strict horizontal line with consistent spacing.
### Detailed Analysis
**1. MLP Series (Blue Boxes - Top Row):**
* **Trend:** The series consists of consecutive **even numbers**, increasing by 2 at each step.
* **Complete Data Sequence (Left to Right):** 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80.
* **Count:** 40 data points.
* **Range:** Starts at 2, ends at 80.
**2. ATT Series (Red Boxes - Bottom Row):**
* **Trend:** The series consists of consecutive **odd numbers**, increasing by 2 at each step.
* **Complete Data Sequence (Left to Right):** 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79.
* **Count:** 40 data points.
* **Range:** Starts at 1, ends at 79.
### Key Observations
1. **Complementary Sequences:** The two series are perfectly complementary. Together, they contain every integer from 1 to 80 exactly once, with no overlaps or gaps. The `MLP` series holds all even numbers, and the `ATT` series holds all odd numbers within that range.
2. **Perfect Regularity:** Both sequences exhibit perfect arithmetic progression with a common difference of 2. There are no outliers, deviations, or irregularities in the pattern.
3. **Visual Alignment:** The boxes are aligned such that each number in the `ATT` row is positioned directly below the space between two numbers in the `MLP` row (e.g., `ATT`'s `1` is below the space before `MLP`'s `2`; `ATT`'s `3` is below the space between `MLP`'s `2` and `4`). This creates a staggered, interlocking visual effect.
### Interpretation
This chart is a clear, visual representation of the fundamental mathematical partition of integers into even and odd sets. The labels "MLP" and "ATT" likely serve as placeholders or identifiers for two distinct entities, processes, or models (e.g., in a machine learning context, MLP could stand for Multi-Layer Perceptron and ATT for Attention mechanism). The chart's primary function is to illustrate that these two entities are assigned or operate on mutually exclusive, interleaved subsets of a sequential data range (1-80).
The perfect, non-overlapping coverage suggests a design for parallel processing, load balancing, or a comparative analysis where each entity handles a distinct, equally sized portion of the total workload or data spectrum. The visual interlocking reinforces the idea of two complementary parts forming a complete whole. The absence of any data variation or anomaly indicates this is a schematic or conceptual diagram rather than a plot of empirical results.
</details>
(d) Translation - WMT16
Figure 10: Visualization of skipped layer set configurations of LLaMA-2-13B optimized by Self-SD (Zhang et al., 2024) on different task domains. Gray squares indicate retained layers, red squares denote skipped attention layers, and blue squares signify skipped MLP layers.
## Appendix B Experimental Setups
### B.1 Models and Datasets
Our experiments mainly evaluate the effectiveness of on LLaMA-2 (Touvron et al., 2023b) and CodeLLaMA series (Rozière et al., 2023). We provide empirical validation on a diverse range of generation tasks. For summarization, mathematical reasoning, storytelling, and code generation tasks, we chose the CNN/Daily Mail (CNN/DM) (Nallapati et al., 2016), GSM8K (Cobbe et al., 2021), TinyStories (Eldan & Li, 2023), and HumanEval (Chen et al., 2021) datasets, respectively. We perform 1-shot evaluation for CNN/DM and TinyStories, and 5-shot evaluation for GSM8K. The maximum generation lengths on CNN/DM, GSM8K, and TinyStories are set to 64, 64, and 128, respectively. We compare pass@1 and pass@10 for HumanEval. In our further analysis, we include three more datasets to validate the capability of in handling dynamic input data streams. Specifically, we select Alpaca (Taori et al., 2023), WMT14 DE-EN, and Nature Questions (Kwiatkowski et al., 2019) for the instruction following, translation, and question answering tasks, respectively. The maximum generation lengths for HumanEval and all analyses are set to 512. We randomly sample 1000 instances from the test set for each dataset except HumanEval.
### B.2 Inference Setup
In the optimization phase, we employ both random search and Bayesian optimization to suggest potential skipped layer set candidates, striking a balance between optimization performance and efficiency. The context window $\gamma$ is set to 32. The maximum draft length $N_{D}$ is set to 25. For random sampling in code generation tasks, we apply a temperature of 0.6 and $top\_p=0.95$ . The maximum number of layer set optimization steps $S$ is set to 1000, with Bayesian optimization performed every $\beta=25$ steps. The optimization phase is set to be early stopped if the matchness score does not improve after 300 steps or exceeds 0.95. The layer skip ratio $r$ is fixed at 0.45 for the 13B model and 0.5 for the 34B and 70B models. All experiments were conducted using Pytorch 2.1.0 on 4 $\times$ NVIDIA RTX A6000 GPU (40GB) with CUDA 12.1, and an Intel(R) Xeon(R) Platinum 8370C CPU with 32 cores. Inference for our method and all baselines was performed using the Huggingface transformers package. Following prior work, we adopt speculative sampling (Leviathan et al., 2023) as our acceptance strategy, and the batch size is set to 1.
### B.3 Evaluation Metrics
This subsection provides a detailed illustration of our evaluation metrics, which are mean generated length $M$ and token acceptance rate $\alpha$ . Specifically, the mean generated length $M$ refers to the average number of output tokens produced per forward pass of the target LLM; the acceptance rate $\alpha$ is defined as the ratio of accepted tokens to the total number of draft steps. In other words, it represents the expected probability of the target LLM accepting a potential token from a forward pass of the draft model. These two metrics are independent of computational hardware and, therefore considered as more objective metrics. Given the mean generated length $M$ , acceptance rate $\alpha$ , and the layer skip ratio $r$ , the mathematical formula for the expected wall-time speedup during the acceleration phase is derived as follows:
$$
\mathbb{E}(\text{Spd.})=\frac{M}{(M-1)\times\frac{c}{\alpha}+1}=\frac{M\alpha}
{(M-1)c+\alpha},\quad c=1-r, \tag{6}
$$
where $c$ is defined as the cost coefficient in Leviathan et al. (2023). It is calculated as the ratio between the single forward time of the draft model and that of the target LLM. In summary, the ideal speedup will be higher with the larger $M$ and $\alpha$ and smaller $c$ .
## Appendix C Experimental Details
### C.1 Details of Main Results
We present the detailed statistics of our main experimental results in Table 4. consistently achieves a token acceptance rate $\alpha$ exceeding $90\$ across all evaluation settings, with the mean generated length M ranging from 2.99 to 8.21. These statistics indicate strong behavior alignment between the target LLM and its layer-skipping draft variant, as discussed in Section 5.2. Additionally, we report the expected speedup $\mathbb{E}(\text{Spd.})$ calculated using Eq (6), indicating that the current implementation of has significant potential for further optimization to boost its efficiency.
| LLaMA-2-13B LLaMA-2-13B -Chat | Vanilla 4.34 Vanilla | 1.00 0.99 1.00 | - 1.52 $\times$ - | 1.00 $\times$ 3.13 1.00 $\times$ | 1.00 0.98 1.00 | - 1.43 $\times$ - | 1.00 $\times$ 8.21 1.00 $\times$ | 1.00 1.00 1.00 | - 1.65 $\times$ - | 1.00 $\times$ 1.53 $\times$ 1.00 $\times$ | 1.00 $\times$ 1.00 $\times$ |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 3.54 | 0.90 | 1.39 $\times$ | 2.95 | 0.92 | 1.36 $\times$ | 7.42 | 0.99 | 1.62 $\times$ | 1.46 $\times$ | | |
| LLaMA-2-70B | Vanilla | 1.00 | - | 1.00 $\times$ | 1.00 | - | 1.00 $\times$ | 1.00 | - | 1.00 $\times$ | 1.00 $\times$ |
| 3.85 | 0.99 | 1.58 $\times$ | 2.99 | 0.98 | 1.48 $\times$ | 6.17 | 0.99 | 1.71 $\times$ | 1.59 $\times$ | | |
Table 4: Detailed results of on text generation tasks using LLaMA-2 series. We report the mean generated length M, token acceptance rate $\alpha$ , and the expected speedup $\mathbb{E}(\text{Spd.})$ calculated by Eq (6) under the setting of greedy decoding with FP16 precision.
### C.2 Additional Results on LLaMA-70B Models
In addition to the main results presented in Table 2, we provide further experimental evaluations of on LLaMA-70B models, including LLaMA-2-70B and LLaMA-3-70B, along with their instruction-tuned variants, under the same experimental settings. The results demonstrate that consistently achieves a $1.4\times$ $\sim$ $1.5\times$ wall-clock speedup across both the LLaMA-2 and LLaMA-3 series. Notably, achieves a token acceptance rate $\alpha$ exceeding $85\$ across various evaluation settings, with the mean generated length M ranging from 3.43 to 7.80. Although differences in layer redundancy are observed between models (e.g., skip ratio $r$ for LLaMA-2-70B vs. LLaMA-3-70B During the optimization phase, the layer skip ratio $r$ for LLaMA-3-70B was automatically adjusted from 0.5 to 0.4 as the token acceptance rate $\alpha$ remained below the tolerance threshold of 0.7.), demonstrates robust adaptability, maintaining consistent acceleration performance regardless of model version.
| LLaMA-2-70B LLaMA-2-70B -Chat | Vanilla 3.85 Vanilla | 1.00 0.99 1.00 | - 1.43 $\times$ - | 1.00 $\times$ 2.99 1.00 $\times$ | 1.00 0.98 1.00 | - 1.39 $\times$ - | 1.00 $\times$ 6.17 1.00 $\times$ | 1.00 0.99 1.00 | - 1.62 $\times$ - | 1.00 $\times$ 1.48 $\times$ 1.00 $\times$ | 1.00 $\times$ 1.00 $\times$ |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 3.43 | 0.85 | 1.31 $\times$ | 3.12 | 0.89 | 1.32 $\times$ | 5.45 | 0.95 | 1.53 $\times$ | 1.37 $\times$ | | |
| LLaMA-3-70B | Vanilla | 1.00 | - | 1.00 $\times$ | 1.00 | - | 1.00 $\times$ | 1.00 | - | 1.00 $\times$ | 1.00 $\times$ |
| 5.43 | 0.99 | 1.41 $\times$ | 4.11 | 0.99 | 1.37 $\times$ | 7.80 | 0.99 | 1.51 $\times$ | 1.43 $\times$ | | |
| LLaMA-3-70B -Instruct | Vanilla | 1.00 | - | 1.00 $\times$ | 1.00 | - | 1.00 $\times$ | 1.00 | - | 1.00 $\times$ | 1.00 $\times$ |
| 3.76 | 0.95 | 1.33 $\times$ | 3.92 | 0.93 | 1.31 $\times$ | 5.87 | 0.97 | 1.43 $\times$ | 1.36 $\times$ | | |
Table 5: Experimental results of on text generation tasks using the LLaMA-70B series. We report the mean generated length M, token acceptance rate $\alpha$ , and speedup ratio under the setting of greedy decoding. The skip ratio $r$ is set to 0.5 for LLaMA-2 models and 0.4 for LLaMA-3 models.
### C.3 Detailed Results of LLM Backbones
To further validate the effectiveness of , we conducted experiments using additional LLM backbones beyond the LLaMA series. Specifically, we select two recently representative LLMs: Yi-34B for text generation and DeepSeek-Coder-33B for code generation tasks. The experimental results are illustrated in Table 6 and 7, demonstrating the efficacy of across these LLM backbones. achieves a consistent $1.2\times$ $\sim$ $1.3\times$ wall-clock speedup on the Yi-34B series and a $1.3\times$ $\sim$ $1.5\times$ on the DeepSeek-Coder-33B series. Notably, for the DeepSeek-Coder-33B series, attains a mean generate length M ranging from 3.16 to 4.17, alongside a token acceptance rate $\alpha$ exceeding $83\$ . These findings substantiate the utility of as a general-purpose, plug-and-play SD method, offering promising inference acceleration across diverse LLM backbones.
| Yi-34B Yi-34B-Chat | Vanilla 2.74 Vanilla | 1.00 0.94 1.00 | - 1.30 $\times$ - | 1.00 $\times$ 2.65 1.00 $\times$ | 1.00 0.97 1.00 | - 1.28 $\times$ - | 1.00 $\times$ 3.25 1.00 $\times$ | 1.00 0.98 1.00 | - 1.34 $\times$ - | 1.00 $\times$ 1.31 $\times$ 1.00 $\times$ | 1.00 $\times$ 1.00 $\times$ |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 2.84 | 0.91 | 1.29 $\times$ | 2.77 | 0.89 | 1.27 $\times$ | 2.52 | 0.80 | 1.21 $\times$ | 1.26 $\times$ | | |
Table 6: Experimental results of on text generation tasks using Yi-34B series. We report the mean generated length M, token acceptance rate $\alpha$ and speedup ratio under the setting of greedy decoding with FP16 precision. The skip ratio $r$ is set to 0.45.
## Appendix D Further Analysis and Discussion
### D.1 Ablation Study
Table 8 presents the ablation study of using LLaMA-2-13B on CNN/DM. The experimental results demonstrate that each component of contributes to its overall speedup of . Specifically, early-stopping drafting effectively reduces the number of ineffective draft steps, improving the token acceptance rate $\alpha$ by $55\$ . Dynamic verification further enhances efficiency by selecting suitable draft candidates from the top- $k$ predictions based on their confidence scores; removing this component leads to a decrease in both the mean generated length (M) and the overall speedup ratio. Additionally, the optimization phase refines the set of skipped layers, improving speedup by $34\$ compared to the initial uniform layer-skipping strategy. In summary, these results confirm the effectiveness of each proposed innovation in .
| HumanEval (pass@1) HumanEval (pass@10) | Vanilla 4.97 Vanilla | 1.00 0.99 1.00 | - 1.54 $\times$ - | 1.00 $\times$ 3.80 1.00 $\times$ | 1.00 0.88 1.00 | - 1.39 $\times$ - | 1.00 $\times$ 1.00 $\times$ |
| --- | --- | --- | --- | --- | --- | --- | --- |
| 3.16 | 0.91 | 1.36 $\times$ | 3.74 | 0.83 | 1.31 $\times$ | | |
Table 7: Experimental results of on code generation tasks using DeepSeek-Coder-33B series. The skip ratio $r$ is set to 0.5. We use greedy decoding for pass@1 and random sampling with a temperature of 0.6 for pass@10. “ DS ” denotes the abbreviation of DeepSeek.
| w/o early-stopping-w/o dynamic ver. | 5.82 11.16 4.39 | 0.98 0.43 0.90 | 1.560 $\times$ 0.896 $\times$ 1.342 $\times$ |
| --- | --- | --- | --- |
| w/o optimization | 2.15 | 0.90 | 1.224 $\times$ |
Table 8: Ablation study of . “ ver. ” denotes the abbreviation of verification.
| 16 32 64 | 3.91 5.82 5.56 | 0.95 0.98 0.99 | 1.341 $\times$ 1.560 $\times$ 1.552 $\times$ | 0.242ms 0.244ms 0.312ms |
| --- | --- | --- | --- | --- |
| 128 | 5.61 | 0.98 | 1.550 $\times$ | 0.425ms |
Table 9: Speedups of across different context window $\gamma$ . The latency of the optimization step is reported to illustrate the associated overhead.
### D.2 Context Window
In Table 9, we show a detailed analysis of context window $\gamma$ , which determines the number of LLM-generated tokens used in the layer set optimization process. A smaller $\gamma$ introduces greater randomness in the matchness score calculation, resulting in suboptimal performance, while a larger $\gamma$ increases the computational overhead of the optimization step. The results indicate that $\gamma=32$ provides an optimal balance between optimization performance and computational overhead.
### D.3 Comparisons with Prior Layer-Skipping Methods
In this subsection, we compare with two representative layer-skipping speculative decoding (SD) methods: LayerSkip (Elhoushi et al., 2024) and Self-SD (Zhang et al., 2024). Specifically, LayerSkip (Elhoushi et al., 2024) introduces an innovative approach to self-speculative decoding by implementing early-exit drafting, where the LLM generates drafts using only its earlier layers. However, this method necessitates a time-consuming pretraining or finetuning process, which modifies the original output distribution of the target LLM. Such alterations may compromise the reliability of the generated outputs; Self-SD (Zhang et al., 2024) proposed to construct the compact draft model by skipping intermediate layers, using an extensive Bayesian Optimization process before inference to determine the optimal skipped layers within the target LLM. As illustrated in Section 3.1, while effective, Self-SD suffers from significant optimization latency (nearly 7.5 hours for LLaMA-2-13B and 20 hours for LLaMA-2-70B). This prolonged optimization process limits its practicality and generalizability across diverse models and tasks.
Tables 10 and 11 summarize the comparative results in terms of acceleration performance and training/optimization costs, respectively. Below, we detail the advantages of over these methods:
- Comparison with LayerSkip: LayerSkip achieves an aggressive skip ratio ( $r=0.8$ ), resulting in an average generated length of $2.42$ and a token acceptance rate of $0.64$ . However, its reliance on pretraining or finetuning alters the original distribution of the target LLM, potentially reducing reliability. In contrast, preserves the original distribution of the target LLM while delivering a comparable $1.56\times$ speedup without requiring additional training.
- Comparison with Self-SD: Self-SD relies on a time-intensive Bayesian Optimization process, which incurs substantial latency before inference. eliminates this bottleneck through an on-the-fly optimization strategy, achieving an approximately $\mathbf{200\times}$ reduction in optimization latency while maintaining the same $1.56\times$ speedup. We further augmented Self-SD with our Confidence-aware Inference Acceleration strategy (Self-SD w/ dynamic ver.). Even compared to this augmented version, achieves competitive speedups.
These findings highlight the efficiency and practicality of over previous layer-skipping SD methods. As the first plug-and-play layer-skipping SD approach, we hope that could provide valuable insights and inspire further research in this area.
| LayerSkip | ✗ | ✗ | 0.80 | 2.42 | 0.64 | 1.64 $\times$ |
| --- | --- | --- | --- | --- | --- | --- |
| Self-SD | ✗ | ✓ | 0.43 | 4.02 | 0.85 | 1.29 $\times$ |
| Self-SD w/ dynamic ver. | ✗ | ✓ | 0.43 | 5.69 | 0.98 | 1.52 $\times$ |
| (Ours) | ✓ | ✓ | 0.45 | 5.82 | 0.98 | 1.56 $\times$ |
Table 10: Comparison of and prior layer-skipping SD methods. We report the skip ratio $r$ , mean generated length M, token acceptance $\alpha$ , and speedup ratio under greedy decoding. The results are obtained with LLaMA-2-13B on CNN/DM. “ ver. ” denotes the abbreviation of verification.
| LayerSkip Self-SD (Ours) | $50\times 10^{3}$ training steps with 64 A100 (80GB) 1000 Bayesian Optimization Iterations Before inference N/A | - $\sim$ $7.5$ hours $\sim$ $\mathbf{2}$ minutes |
| --- | --- | --- |
Table 11: Comparison of and prior layer-skipping SD methods in terms of training cost and optimization latency for LLaMA-2-13B. Training costs are sourced from the original papers, while optimization latency is measured from our re-implementation on an A6000 GPU. demonstrates a $\sim$ $\mathbf{200\times}$ reduction in optimization latency compared to previous methods without requiring additional training, establishing it as an efficient plug-and-play SD method.
### D.4 Detailed Comparisons with Self-SD
<details>
<summary>x14.png Details</summary>

### Visual Description
## Line Chart: Speedup vs. Optimization Latency
### Overview
The image is a 2D line chart comparing the performance of two methods, "Self-SD" and "SWIFT," plotting "Speedup" against "Optimization Latency (s)." The chart demonstrates the trade-off between the time spent on optimization and the resulting performance gain.
### Components/Axes
* **X-Axis (Horizontal):** Labeled "Optimization Latency (s)". The scale runs from 0 to 6000 seconds, with major tick marks at 0, 2000, 4000, and 6000.
* **Y-Axis (Vertical):** Labeled "Speedup". The scale runs from 0.95 to 1.55, with major tick marks at 0.95, 1.15, 1.35, and 1.55.
* **Legend:** Located in the top-right corner of the chart area.
* A blue circle icon corresponds to the label "Self-SD".
* A red star icon corresponds to the label "SWIFT".
* **Data Series:**
1. **Self-SD (Blue Line with Circle Markers):** A single continuous line connecting several data points, each marked with a blue circle.
2. **SWIFT (Red Star Marker):** A single, isolated data point represented by a large red star.
### Detailed Analysis
**Data Series: Self-SD (Blue Line)**
* **Trend:** The line shows a positive, sub-linear (logarithmic-like) trend. It starts low and increases as optimization latency increases, but the rate of speedup gain diminishes at higher latencies.
* **Approximate Data Points (Latency (s), Speedup):**
* (0, ~0.95)
* (~250, ~0.96)
* (~500, ~0.98)
* (~1500, ~1.05)
* (~3000, ~1.20)
* (~5500, ~1.25)
**Data Point: SWIFT (Red Star)**
* **Trend:** This is a single, high-leverage point. It achieves a very high speedup with near-zero optimization latency.
* **Approximate Data Point:** (~0, ~1.55)
### Key Observations
1. **Performance Gap:** There is a significant performance gap between the two methods at the low-latency end of the spectrum. SWIFT achieves a speedup of ~1.55 with negligible latency, while Self-SD starts at a speedup of ~0.95 (a slowdown) at zero latency.
2. **Self-SD's Trajectory:** The Self-SD method requires substantial optimization time (over 5000 seconds) to achieve a speedup of ~1.25, which is still considerably lower than SWIFT's speedup at the start.
3. **Diminishing Returns for Self-SD:** The curve for Self-SD flattens, indicating that after a certain point (~3000s), investing more optimization time yields progressively smaller improvements in speedup.
4. **Spatial Placement:** The SWIFT data point is positioned in the top-left quadrant, visually emphasizing its superior efficiency (high Y-value, low X-value). The Self-SD line traverses the chart from bottom-left to center-right.
### Interpretation
The chart presents a compelling case for the SWIFT method over the Self-SD method in the context of this evaluation. The data suggests that **SWIFT is fundamentally more efficient**, delivering a high performance boost (55% speedup) without requiring a costly optimization phase. In contrast, **Self-SD represents a traditional trade-off**: it can improve performance over its baseline, but only after investing significant computational time (latency), and its maximum achievable gain appears limited compared to SWIFT's starting point.
The underlying message is one of algorithmic or architectural superiority. SWIFT likely employs a more intelligent or pre-optimized approach that avoids the lengthy iterative tuning process that Self-SD depends on. For practical applications, especially those where setup time is critical or computational resources are constrained, SWIFT would be the strongly preferred choice based on this data. The chart effectively argues that SWIFT decouples high performance from high optimization cost.
</details>
Figure 11: Comparison of and Self-SD in terms of optimization latency and speedup. achieves a $1.56\times$ speedup with an optimization latency of 116 seconds.
In this subsection, we provide a detailed comparison of and Self-SD (Zhang et al., 2024). Figure 11 presents the speedups of Self-SD across varying optimization latencies, reflecting the increase in Bayesian Optimization iterations. As shown, Self-SD achieves minimal speedup improvement – almost equivalent to unified skipping – with fewer than 50 Bayesian iterations, corresponding to an optimization latency below 1474 seconds. At 100 Bayesian iterations, Self-SD achieves a $1.19\times$ speedup; however, its optimization latency is nearly 25 times longer than that of (2898s vs. 116s).
Table 12 compares and Self-SD (first two rows) under similar optimization latencies. The results highlight ’s superiority in both optimization efficiency (116s vs. 155s) and speedup ( $1.56\times$ vs. $0.97\times$ ). Even when compared to the augmented version of Self-SD (w/ dynamic verification), achieves a substantial $30\$ relative improvement in speedup. Below, we analyze the factors contributing to this advantage (elaborated in Section 3.1):
- Optimization Objective Granularity: Self-SD calculates its optimization objective at a multi-sample level, requiring sequential decoding of all selected training samples (e.g., 8 samples with 32 tokens each) for every iteration to optimize Equation 1. In contrast, adopts a step-level optimization objective, optimizing the layer set dynamically at each decoding step.
- Bayesian Optimization Complexity: The computational complexity of Bayesian optimization increases significantly with the number of iterations. mitigates this burden by combining random search with interval Bayesian optimization, accelerating convergence of the optimization process while reducing computational overhead.
To further examine optimization trade-offs, we reduce Self-SD’s sequential optimization requirement to a single sample with 8 tokens, enabling more Bayesian Optimization iterations within a comparable latency. The corresponding results, denoted as Self-SD c (rows 3-4), are presented in Table 12. Even with these optimized settings, demonstrates substantial superior speedup and efficiency, highlighting the effectiveness of our proposed strategies.
| Self-SD | - | 5 | 155 | 0.50 | 1.80 | 0.57 | 0.97 $\times$ |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Self-SD w/ dynamic ver. | - | 5 | 155 | 0.50 | 2.07 | 0.86 | 1.17 $\times$ |
| Self-SD c | - | 30 | 199 | 0.45 | 2.08 | 0.70 | 1.04 $\times$ |
| Self-SD c w/ dynamic ver. | - | 30 | 199 | 0.45 | 2.44 | 0.93 | 1.22 $\times$ |
| (Ours) | 552 | 23 | 116 | 0.45 | 5.82 | 0.98 | 1.56 $\times$ |
Table 12: Comparison of and Self-SD at similar optimization latencies. We report the skip ratio $r$ , mean generated length M, token acceptance rate $\alpha$ , and speedup under greedy decoding. The results are obtained with LLaMA-2-13B on CNN/DM, with “ ver. ” indicating verification.
### D.5 The Necessity of Plug-and-Play SD Methods
There has been a surge of recent interest in Speculative Decoding (SD), leading to the development of numerous promising strategies in the field, which can be broadly categorized into two directions:
- Training-required SD. These methods require additional pretraining or fine-tuning to improve speculative accuracy, often involving the integration of extra parameters. For instance, Medusa (Cai et al., 2024) and Eagle (Li et al., 2024a; b) incorporate lightweight draft heads into target LLMs and fine-tune them, achieving $3\times$ $\sim$ $4\times$ speedups.
- Plug-and-play SD. These approaches offer immediate acceleration of LLM inference without relying on auxiliary models or additional training. Notable examples include Parallel Decoding (Santilli et al., 2023) and Lookahead (Fu et al., 2024), which leverage Jacobi-based drafting, achieving $1.2\times$ $\sim$ $1.4\times$ speedups across various LLMs.
While training-required SD methods generally deliver higher speedups, their reliance on additional training and parameters limits both their generalizability and practicality. This has sparked debate within the academic community regarding the value of plug-and-play SD methods. To address these concerns, we present a detailed analysis below to highlight the necessity of plug-and-play SD approaches and underscore the contributions of our proposed :
1) Training costs of training-required SD methods are often prohibitive.
Training-required methods such as Medusa (Cai et al., 2024) and Eagle (Li et al., 2024a; b), while achieving higher speedups, incur substantial training costs. Despite efforts to reduce training overhead, these methods still require extensive computational resources (e.g., GPU time and datasets) to deliver valid acceleration performance. For example, Eagle requires 1–2 days of training with 8 RTX 3090 GPUs for LLaMA-33B or up to 2 days on 4 A100 (40G) GPUs for LLaMA-2-Chat-70B, using a dataset of 70k dialogues from ShareGPT. Such computational burdens introduce challenges in several scenarios:
- Users must train new draft models for unsupported target LLMs. For example, if the user’s target LLM is not among the released checkpoints or if the base model is updated (e.g., LLaMA-3.x), users are forced to train a new draft model, which may exceed their available GPU resources (e.g., GPU time).
- Users with small-scale acceleration needs face inefficiencies. For instance, a researcher needing to evaluate a small set of samples (e.g., 10 hours of evaluation) would find the 1–2 day training requirement disproportionate and hinder overall research efficiency.
2) Plug-and-play SD fills critical gaps unaddressed by training-required methods.
Plug-and-play SD methods, including , are model-agnostic and training-free, providing immediate acceleration without requiring additional computational overhead. These attributes are particularly critical for large models (70B–340B) and for use cases requiring rapid integration. The growing adoption of plug-and-play SD methods, such as Lookahead (Fu et al., 2024), further underscores their importance. These methods cater to scenarios where ease of use and computational efficiency are paramount, validating their research significance.
3) pioneers plug-and-play SD with layer-skipping drafting.
represents the first plug-and-play SD method to incorporate layer-skipping drafting. It consistently achieves $1.3\times$ $\sim$ $1.6\times$ speedups over vanilla autoregressive decoding across diverse models and tasks. Additionally, it demonstrates $10\$ $\sim$ $20\$ higher efficiency compared to Lookahead (Fu et al., 2024). Despite its effectiveness, introduces a complementary research direction for existing plug-and-play SD. Its approach is orthogonal to Lookahead Decoding, and combining the two could further amplify their collective efficiency. We believe this study provides valuable insights and paves the way for future SD advancements, particularly for practical and cost-effective LLM acceleration.
To sum up, while training-required SD methods achieve higher speedups, their high computational costs and limited flexibility reduce practicality. Plug-and-play SD methods, like , offer training-free, model-agnostic acceleration, making them ideal for diverse scenarios. We hope this clarification fosters greater awareness and recognition of the value of plug-and-play SD research.
### D.6 Additional Discussions with Related Work
In this work, we leverage the inherent layer sparsity of LLMs through layer skipping, which selectively bypasses intermediate layers within the target LLM to construct the compact draft model. In addition to layer skipping, there has been another research direction in SD that focuses on early exiting, where inference halts at earlier layers to improve computational efficiency (Yang et al., 2023; Hooper et al., 2023; Bae et al., 2023; Elhoushi et al., 2024). Particularly, LayerSkip (Elhoushi et al., 2024) explores early-exit drafting by generating drafts using only the earlier layers of the target LLM, followed by verification with the full-parameter model. This approach requires training involving layer dropout and early exit losses. Similarly, PPD (Yang et al., 2023) employs early exiting but trains individual classifiers for each layer instead of relying on a single final-layer classifier. Although effective, these methods rely on extensive fine-tuning to enable early-exiting capabilities, incurring substantial computational costs. Moreover, the training process alters the target LLM’s original output distribution, potentially compromising the reliability of generated outputs. In contrast, our proposed does not require auxiliary models or additional training, preserving the original output distribution of the target LLM while delivering comparable acceleration benefits.
There has been a parallel line of training-required SD research focusing on non-autoregressive drafting strategies (Stern et al., 2018; Cai et al., 2024; Gloeckle et al., 2024; Kim et al., 2024). These methods integrate multiple draft heads into the target LLM, enabling the parallel generation of draft tokens at each decoding step. Notably, Kim et al. (2024) builds on the Blockwise Parallel Decoding paradigm introduced in Stern et al. (2018), accelerating inference by refining block drafts with task-independent n-grams and lightweight rescorers using smaller LMs. While these approaches achieve notable acceleration, they also necessitate extensive training of draft models. complements these efforts by pioneering plug-and-play SD that eliminates the need for auxiliary models or additional training, offering a more flexible and practical solution for diverse use cases.
### D.7 Optimization Steps
We present the detailed configuration of across various optimization steps in Figure 10. As the process continues, the skipped layer set is gradually refined toward the optimal configuration.
<details>
<summary>x15.png Details</summary>

### Visual Description
## Data Table Diagram: Sequential Number Series by Category
### Overview
The image displays a two-row data table or diagram presenting two distinct series of sequential integers, each associated with a specific label ("MLP" and "ATT"). The numbers are presented in individual colored boxes arranged horizontally. The primary distinction between the series is that one contains even numbers and the other contains odd numbers.
### Components/Axes
* **Row Labels (Left-aligned):**
* Top Row Label: `MLP`
* Bottom Row Label: `ATT`
* **Data Series:** Each label corresponds to a horizontal sequence of numbers enclosed in colored rectangular boxes.
* **Color Legend (Implied by Row Label):**
* `MLP` series: Blue boxes.
* `ATT` series: Red boxes.
* **Spatial Layout:** The two rows are stacked vertically. The labels are positioned to the far left of their respective rows. The numbered boxes extend horizontally to the right from each label.
### Detailed Analysis
**1. MLP Series (Top Row, Blue Boxes):**
* **Trend/Pattern:** This series consists of consecutive even integers.
* **Sequence:** The numbers start at 2 and increase by 2 for each subsequent box.
* **Complete List of Extracted Values:** 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80.
* **Range:** 2 to 80 (inclusive).
* **Count:** 40 data points.
**2. ATT Series (Bottom Row, Red Boxes):**
* **Trend/Pattern:** This series consists of consecutive odd integers.
* **Sequence:** The numbers start at 1 and increase by 2 for each subsequent box.
* **Complete List of Extracted Values:** 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79.
* **Range:** 1 to 79 (inclusive).
* **Count:** 40 data points.
### Key Observations
1. **Perfect Complementarity:** The two series together form a complete set of all integers from 1 to 80. The `MLP` (even) and `ATT` (odd) series partition this set without overlap or omission.
2. **Identical Length:** Both series contain exactly 40 data points.
3. **Visual Encoding:** The primary method of distinguishing the series is through color (blue vs. red) and the row label. The numerical pattern (even vs. odd) is a direct consequence of the label assignment.
4. **No Missing Data:** Within the defined ranges (1-79 for ATT, 2-80 for MLP), every applicable integer is present in its respective series.
### Interpretation
This diagram is a clear, visual representation of a **binary classification or partitioning of a numerical sequence**. The labels "MLP" and "ATT" likely represent two distinct categories, models, processes, or groups. The data demonstrates that these two categories are assigned to mutually exclusive and collectively exhaustive subsets of the integers from 1 to 80 based on parity (even/odd).
The structure suggests a technical context, possibly illustrating:
* **Data Sharding:** How a dataset (numbers 1-80) is split between two systems (`MLP` and `ATT`).
* **Model Assignment:** Which numerical inputs are processed by which model (e.g., an MLP neural network vs. an Attention-based model).
* **Resource Allocation:** A round-robin or alternating assignment of tasks (numbered 1-80) to two workers or threads.
The perfect, unbroken sequences imply an idealized or systematic allocation rule. The use of color and spatial separation makes the partitioning immediately visually apparent, serving as an effective explanatory aid for a technical audience to understand how a dataset or workload is divided.
</details>
(a) Optimization Step 0
<details>
<summary>x16.png Details</summary>

### Visual Description
## Table Chart: MLP and ATT Numerical Sequences with Highlighted Values
### Overview
The image displays a two-row table or chart presenting numerical sequences for two categories labeled "MLP" and "ATT". The numbers are arranged horizontally in ascending order. Specific numbers within each sequence are highlighted with colored backgrounds—blue for MLP and red for ATT—while the remaining numbers have a plain white background. The chart appears to be a visual representation of selected or active indices, parameters, or data points within two distinct series.
### Components/Axes
* **Row Labels (Left Side):**
* Top Row: `MLP`
* Bottom Row: `ATT`
* **Data Series:** Two horizontal sequences of integers.
* **MLP Sequence:** Contains even numbers from 2 to 80, but not all are present.
* **ATT Sequence:** Contains odd numbers from 1 to 79, but not all are present.
* **Visual Encoding:**
* **Color Legend (Implied):** The row label itself serves as the legend. Blue cells correspond to the "MLP" series. Red cells correspond to the "ATT" series.
* **Highlighting:** Cells with a colored background indicate a selected or significant value within its sequence.
### Detailed Analysis
**1. MLP Row (Top, Blue Highlights):**
* **Sequence Trend:** The numbers increase from left to right. The sequence is not continuous; it includes most even numbers but skips several (e.g., 10, 16, 28, 30, 44, 46, 48).
* **Highlighted Values (Blue):** The following numbers have a blue background: `6, 18, 20, 22, 24, 26, 32, 34, 36, 38, 40, 42, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80`.
* **Pattern of Highlights:** After the initial isolated highlight at `6`, the highlights form a nearly continuous block from `18` to `42`, then another block from `50` to `80`. The gap between `42` and `50` (`44, 46, 48`) is not highlighted.
**2. ATT Row (Bottom, Red Highlights):**
* **Sequence Trend:** The numbers increase from left to right. This sequence is also not continuous, containing most odd numbers but skipping several (e.g., 3, 7, 9, 15, 17, 21, 27, 29, 33, 35, 39, 43, 47, 53, 59, 61, 67, 71, 73, 75, 77).
* **Highlighted Values (Red):** The following numbers have a red background: `11, 13, 19, 23, 25, 31, 37, 41, 45, 49, 51, 55, 57, 63, 65, 69`.
* **Pattern of Highlights:** The highlights are more scattered than in the MLP row. They appear as isolated pairs (`11,13`; `23,25`; `55,57`; `63,65`) or single points (`19, 31, 37, 41, 45, 49, 51, 69`), with increasing gaps between them as the numbers grow larger.
**3. Spatial & Cross-Reference Check:**
* The legend (row labels) is positioned at the far left of each row.
* The highlighted cells are placed directly within their respective numerical sequences. For example, the blue cell for `6` is the third cell in the MLP row, and the red cell for `11` is the sixth cell in the ATT row.
* There is no overlap in the numerical values between the two rows (MLP uses evens, ATT uses odds), and their color coding is distinct and consistent.
### Key Observations
* **Density of Highlights:** The MLP series has a much higher density of highlighted values (28 out of ~40 visible numbers) compared to the ATT series (16 out of ~40 visible numbers).
* **Clustering vs. Scattering:** MLP highlights are heavily clustered in two large blocks. ATT highlights are more evenly distributed but appear in smaller, more frequent clusters or as single points.
* **Gaps:** Both sequences have non-highlighted numbers interspersed, but the pattern of gaps differs. MLP has a notable gap in highlights between `42` and `50`. ATT has larger gaps between highlighted clusters as the sequence progresses (e.g., between `25` and `31`, `57` and `63`).
### Interpretation
This chart likely visualizes the selection or activation pattern of elements (e.g., neurons, attention heads, features, parameters, or data indices) within two different computational models or processes, abbreviated as MLP (commonly Multilayer Perceptron) and ATT (commonly Attention).
* **What the data suggests:** The MLP process appears to activate or select large, contiguous blocks of its available elements, suggesting a broad, distributed, or layered processing strategy. In contrast, the ATT process activates elements in a more selective, sparse, and scattered manner, which is characteristic of attention mechanisms that focus on specific, potentially non-local, points of information.
* **Relationship between elements:** The two rows are parallel sequences, allowing for direct comparison of which indices are "active" (highlighted) in each model at similar positions. For instance, around index 20-30, MLP has many active elements while ATT has very few.
* **Notable patterns:** The stark contrast in activation density and clustering is the primary insight. The MLP's block-like activation could indicate processing of continuous features or layers, while ATT's sparse, paired activations might reflect the model focusing on specific relationships or tokens within a sequence. The isolated first highlight in MLP (`6`) versus the first pair in ATT (`11,13`) may indicate different initialization or early-processing behaviors.
</details>
(b) Optimization Step 64
<details>
<summary>x17.png Details</summary>

### Visual Description
## Chart: MLP vs. ATT Layer/Unit Highlighting Pattern
### Overview
The image displays a simple, two-row chart or diagram comparing two sequences labeled "MLP" and "ATT". Each row consists of a series of consecutive integers. Certain numbers in each row are highlighted with a colored background, creating a distinct, non-overlapping pattern between the two rows. The chart appears to be a visual representation of selected indices, layers, or units, likely from a technical or computational context such as neural network architecture.
### Components/Axes
* **Row Labels (Left-aligned):**
* Top Row: `MLP`
* Bottom Row: `ATT`
* **Data Series:** Two horizontal sequences of integers.
* **MLP Sequence:** Even numbers from 2 to 80.
* **ATT Sequence:** Odd numbers from 1 to 79.
* **Highlighting/Legend:**
* **Blue Highlight:** Applied to specific numbers in the `MLP` row.
* **Red Highlight:** Applied to specific numbers in the `ATT` row.
* There is no separate legend box; the row labels and associated highlight colors serve as the key.
### Detailed Analysis
**1. MLP Row (Top, Blue Highlights):**
* **Sequence:** 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80.
* **Highlighted Numbers (Blue):** 6, 12, 16, 18, 20, 24, 32, 34, 36, 42, 44, 46, 54, 56, 58, 62, 64, 66, 72, 74, 76.
* **Pattern:** The highlighting does not follow a simple arithmetic progression. It appears to select clusters of consecutive even numbers (e.g., 16,18,20; 32,34,36; 42,44,46; 54,56,58; 62,64,66; 72,74,76) interspersed with single highlighted numbers (6, 12, 24, 42, 54, 62, 72). The first highlighted value is 6.
**2. ATT Row (Bottom, Red Highlights):**
* **Sequence:** 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79.
* **Highlighted Numbers (Red):** 7, 21, 29, 33, 35, 37, 41, 43, 45, 51, 55, 61, 67, 69, 73, 75, 77.
* **Pattern:** Similar to the MLP row, the highlighting shows clusters (e.g., 33,35,37; 41,43,45; 73,75,77) and single points (7, 21, 29, 51, 55, 61, 67, 69). The first highlighted value is 7.
**3. Cross-Reference & Spatial Grounding:**
* The two rows are perfectly aligned vertically, allowing for direct comparison of indices.
* The highlighted sets are **mutually exclusive**. No number is highlighted in both rows. For example, the even number 6 is blue (MLP), and the odd number 7 is red (ATT).
* The highlighting creates a complementary pattern across the full range of integers from 1 to 80.
### Key Observations
1. **Complementary Selection:** The primary observation is that the blue (MLP) and red (ATT) highlights partition the set of integers {6, 7, 12, 16, 17...} into two disjoint subsets. This suggests a deliberate, non-random selection process where each highlighted index is assigned to exactly one of the two categories.
2. **Clustered Pattern:** Both series exhibit a pattern of selecting small, consecutive blocks of numbers (typically 2-3 in a row) rather than a uniform or random distribution.
3. **Range:** The highlighting begins at index 6 (MLP) and 7 (ATT), leaving the very first few numbers (1-5) unhighlighted in both rows.
4. **Density:** The density of highlighted numbers appears roughly similar between the two rows across the displayed range.
### Interpretation
This chart most likely visualizes the **allocation of specific layers, units, or parameters** between two components of a machine learning model: a Multi-Layer Perceptron (MLP) and an Attention mechanism (ATT).
* **What it suggests:** The data demonstrates a design choice where certain computational resources (indexed by the numbers) are dedicated exclusively to either the MLP sub-network or the Attention sub-network. The clustered pattern might indicate that related or sequential operations are grouped within the same component.
* **How elements relate:** The MLP and ATT rows are parallel and complementary, implying they are two parts of a unified system. The lack of overlap is critical—it shows a clear division of labor with no shared resources at these indices.
* **Notable anomalies:** The absence of any highlights for indices 1-5 is notable. This could mean these initial layers/units serve a different, shared, or foundational purpose not assigned to either the MLP or ATT specific functions.
* **Underlying purpose:** This type of visualization is common in research papers or technical documentation to illustrate novel neural network architectures, such as hybrid models that interleave or separately process information through MLP and attention pathways. The specific indices chosen (e.g., 6, 12, 16...) would correspond to the layer numbers in the model's architecture where these specialized components are applied.
</details>
(c) Optimization Step 128
<details>
<summary>x18.png Details</summary>

### Visual Description
## Sequence Activation Chart: MLP vs. ATT Layer/Neuron Indices
### Overview
The image displays a horizontal sequence chart comparing the activation patterns of two models or components, labeled "MLP" and "ATT". The chart visualizes specific numerical indices (from 1 to 80) that are "active" or selected for each component, represented by colored cells against a light gray background grid of all possible indices.
### Components/Axes
* **Row Labels (Left Side):**
* Top Row: `MLP`
* Bottom Row: `ATT`
* **Data Axis (Horizontal):** A linear sequence of integers from 1 to 80, representing indices (e.g., layer numbers, neuron IDs, or token positions). Each integer occupies a discrete cell.
* **Legend/Color Coding:**
* **Blue Cells:** Correspond to the `MLP` row.
* **Red Cells:** Correspond to the `ATT` row.
* **Light Gray Cells:** Represent inactive or non-selected indices for both components.
### Detailed Analysis
The chart is a direct mapping of active indices for two separate series.
**1. MLP (Top Row - Blue Cells):**
* **Trend/Pattern:** The blue cells are sparsely and irregularly distributed across the 80 positions. There is no simple arithmetic progression; they appear in small clusters and isolated points.
* **Active Indices (Blue):** 16, 22, 26, 28, 38, 44, 46, 50, 58, 60, 78.
* **Spatial Distribution:** The first activation appears at index 16. There is a notable cluster between 22-28. Another cluster exists from 38-50. The final two activations are at 58 and 60, with a final isolated point at 78.
**2. ATT (Bottom Row - Red Cells):**
* **Trend/Pattern:** The red cells are much more frequent and densely packed than the blue cells. They form long, nearly continuous blocks with only occasional gaps.
* **Active Indices (Red):** 5, 9, 13, 17, 25, 27, 29, 31, 33, 41, 45, 47, 49, 51, 53, 55, 57, 63, 69, 73, 77.
* **Spatial Distribution:** Activations begin early at index 5. A dense block runs from 25 to 33. The densest block spans from 41 to 57, with activations at every odd index in that range. Further activations are spaced at 63, 69, 73, and 77.
### Key Observations
1. **Density Disparity:** The `ATT` component has significantly more active indices (21 red cells) compared to the `MLP` component (11 blue cells).
2. **Pattern Contrast:** `ATT` activations form long, regular sequences (often at odd numbers), suggesting a structured, periodic, or widespread engagement. `MLP` activations are more sporadic and clustered, indicating targeted or conditional engagement.
3. **Overlap:** There is **no direct overlap** in the active indices between the two rows. At no point do a blue and red cell occupy the same column (index).
4. **Spatial Grounding:** The row labels are positioned to the immediate left of their respective data sequences. The entire chart is laid out on a uniform grid, with each number centered in its cell.
### Interpretation
This chart likely visualizes the internal activation patterns of a neural network architecture that has both Multi-Layer Perceptron (MLP) and Attention (ATT) components, possibly across 80 layers or processing steps.
* **What the data suggests:** The `ATT` mechanism appears to be broadly and consistently engaged throughout the sequence, with a particularly high concentration of activity in the middle-to-late stages (indices 41-57). This aligns with the role of attention in capturing relationships across a sequence. The `MLP` component shows more selective, burst-like activity, which may correspond to specific feature transformations or computations triggered at particular points.
* **Relationship between elements:** The complete lack of index overlap is striking. It suggests a potential **division of labor** or **specialization** within the model, where attention and MLP functions are activated at distinct, non-interfering stages of processing. They are complementary rather than redundant.
* **Anomalies/Notable Points:** The dense, odd-numbered sequence in the `ATT` row from 41 to 57 is the most prominent feature. This could indicate a core processing phase where the attention mechanism is applied in a sliding-window or iterative fashion. The isolated `MLP` activation at the very end (index 78) might represent a final, high-level feature integration step.
</details>
(d) Optimization Step 512
Figure 12: Visualization of skipped layer set configurations of LLaMA-2-13B optimized by on different optimization steps. Gray squares indicate retained layers, red squares denote skipped attention layers, and blue squares signify skipped MLP layers.
### D.8 Case Study
We present examples from CNN/DM and Humaneval in Table 13 and 14, respectively, comparing token acceptance between and prior plug-and-play approach, Lookahead (Fu et al., 2024). The results demonstrate that accepts a higher number of drafts, which are uniformly distributed in the outputs, highlighting the effectiveness of our approach.
Table 13: CNN/DM example using LLaMA-2-13B; red tokens indicate accepted drafts.
| Lookahead | A Canadian law student was greeted by a friendly note from a stranger when he returned to his car after leaving the head lights on all day . A Canadian law student was gre et ed by a friendly note from a stranger when he returned to his car after leaving the headlights on all day . |
| --- | --- |
Table 14: Humaneval example using CodeLLaMA-13B; red tokens indicate accepted drafts.
| Lookahead | for i in range(len(numbers) - 1): if abs(numbers [i] - numbers [i + 1]) <= threshold: return True return False def has_close_elements_2(numbers: List[float], threshold: float) ->bool: ””” Check if in given list of numbers, are any two numbers closer to each other than given threshold. >>>has_close_elements_2-for i in range(len (numbers) - 1): if abs (numbers [i] - numbers[i + 1]) <= threshold: return True return False def has_close_elements_ 2(numbers: List[float], threshold: float) -> bool: ””” Check if in given list of numbers, are any two numbers closer to each other than given threshold. >>> has _close_elements_2 |
| --- | --- |