Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

Speeding up LLM inference with P-EAGLE in vLLM Speculators

September 3, 2026
Helen Zhao Megan Flynn Dipika Sikka Xin Huang (Amazon)
Related topics:
AI inferenceArtificial intelligenceOpen source
Related products:
Red Hat AI InferenceRed Hat AI

    P-EAGLE (Parallel EAGLE), a new speculative decoding algorithm developed by Amazon, brings the next evolution of speculative decoding to Speculators by extending EAGLE-3 with parallel drafting. Instead of predicting draft tokens one at a time, P-EAGLE generates multiple future tokens in a single forward pass, reducing drafting latency and improving hardware utilization while preserving the exact output quality of the verifier model.

    Speculators v0.6.0 provides a complete open source implementation of P-EAGLE, including data preparation, hidden-state extraction with vLLM, training, evaluation, and deployment. Under the hood, the implementation introduces several key optimizations: COD sampling, learnable mask embeddings and a custom flex-attention mask, making multi-token prediction practical to train at scale while remaining fully compatible with the existing EAGLE-3 framework.

    Whether you want to use one of our pretrained draft models or train a speculator tailored to your own model and workload, Speculators provides an end-to-end workflow that takes you from raw data to production-ready speculative decoding. As the project continues to grow with new algorithms and optimizations, our goal remains the same: make state-of-the-art speculative decoding accessible, reproducible, and easy to deploy for everyone.

    What is speculative decoding?

    Over the past decade, large language models have grown dramatically in size and capability, yet this progress comes at a cost: latency. LLMs generate text sequentially, which requires that each token complete a full forward pass through billions of parameters in order to predict the next token. This token-by-token generation creates a fundamental bottleneck where computational costs scale rapidly as models expand, limiting LLMs despite their impressive abilities.

    Speculative decoding offers a promising solution by enabling LLMs to generate multiple tokens in a single forward pass. The technique pairs a small "draft" model with the full-sized "verifier" model (that is, the LLM you are trying to serve). For the state-of-the-art speculative decoding algorithm EAGLE-3, the draft model is composed only of a single Llama 3 layer.

    This draft model quickly predicts several tokens ahead, which the verifier then evaluates in parallel, accepting or rejecting each prediction. When the verifier rejects a token, it discards the remainder of the speculative sequence, ensuring only validated tokens appear in the final output. This approach achieves faster generation without sacrificing quality. Because the final output maintains the same distribution as if only the verifier model had been used, there is no degradation in model performance while the draft model's small size keeps computational overhead minimal.

    From EAGLE-3 to P-EAGLE

    Frozen target model hidden states and token embeddings feed into P-EAGLE drafter layers to predict parallel output tokens t1 through t4.
    Figure 1: P-EAGLE architecture.

    For EAGLE-3 in particular, the draft model predicts candidate tokens sequentially. While effective, this autoregressive drafting process introduces dependencies between token predictions, limiting the degree of parallelism that can be exploited during generation. To better exploit parallelism during decoding, P-EAGLE extends EAGLE 3 using parallel drafting—multi-token prediction per forward pass. By reducing the number of sequential drafting steps, P-EAGLE lowers drafting latency and improves hardware utilization, resulting in higher decoding throughput and lower end-to-end latency. This parallel drafting strategy is particularly beneficial for long reasoning traces, where the cumulative cost of sequential draft generation can otherwise limit the speedups achievable by speculative decoding.

    P-EAGLE support in Speculators v0.6.0

    Speculators v0.6.0 ships with training support for P-EAGLE, which drafts multiple tokens in a single forward pass. If you've used EAGLE-3 before, P-EAGLE builds directly on top of it. EAGLE-3 drafts tokens autoregressively: predict token 1, feed it back, predict token 2, and so on. P-EAGLE updates this by introducing prediction depths. At each position, the model simultaneously predicts the next K tokens in one shot. The target model then verifies all of them in a single forward pass and accepts the correct prefix. P-EAGLE in Speculators is an extension of the existing EAGLE-3 model definition. Under the hood, the PEagleDraftModel inherits from Eagle3DraftModel and adds three optimizations, including COD sampling, learnable mask parameters, and flex-attention masking.

    COD sampling

    Training a multi-depth model directly without careful design would require memory proportional to the number of depths by sequence length, which increases quickly. Conditional Drop-token (COD) sampling introduced in P-EAGLE avoids this with geometric decay, where depth 0 keeps all positions, depth 1 keeps 0.7 of all positions, depth 2 keeps 0.49 of all positions, and so on. A floor of 0.2 prevents the deepest levels from being starved entirely. This means the model still learns to predict multiple tokens ahead, but deeper predictions train on progressively fewer positions per batch, keeping memory manageable.

    A learnable mask parameter

    At deeper depths, the model doesn't have a real input token because it hasn't been predicted yet. P-EAGLE fills these slots with a dedicated mask_token_id, essentially a placeholder that tells the model "nothing is predicted yet." When training from scratch, resolve_mask_token_id tries to fill the mask token ID with an explicit CLI argument first (you can choose a mask token ID that does not carry any semantic meaning or special character in the vocabulary). If not present, it falls back to the verifier tokenizer's built-in mask token, then tries dynamically adding a <|MASK|> special token if there are unused embedding slots. If there are no empty embedding slots, it tries to use pad, eos, or unk token IDs and raises an error if none succeed.

    The mask token provides token level input, but the model also needs hidden-state information. Instead of EAGLE-3's fixed padding, P-EAGLE learns a mask_hidden tensor that fills in unsampled positions during training. P-EAGLE predicts multiple tokens in parallel, but positions beyond depth 0 don't have a known token yet. While EAGLE-3 uses fixed padding for these unknown positions, P-EAGLE instead introduces mask_hidden, a learnable tensor of shape [1, 1, 3*hidden_size] that fills in the hidden state at unsampled positions. During training, this parameter learns to become a good "I'm empty, look around me" signal, letting the attention mechanism effectively pull information from the real positions at depth 0.

    Learnable embedding

    EAGLE-3 freezes its embedding table because every position has a real token to look up. P-EAGLE, on the other hand, needs to look up a mask token at deeper depths, and the verifier's embedding for that token ID was trained for a completely different purpose. By unfreezing the table, the mask token entry can learn a meaningful "empty position" representation.

    Flex-attention mask

    With multiple depth prediction running in a single forward pass, standard causal masking doesn't apply anymore. We instead need to decide what each position can see, and P-EAGLE builds a custom flex attention mask with the following rules:

    • Depth 0 positions (first draft token) attend causally to each other, exactly like a normal autoregressive model. These are the "base context" with real tokens and real hidden states.
    • Deeper positions in a rollout attend to their own chain. A depth 2 token at anchor position 5 can see the depth-1 and depth-0 tokens at that same anchor, but not tokens from a rollout starting at anchor position 3.
    • All positions attend to preceding depth 0 context. Regardless of depth, every token can look back at the base sequence up to its anchor position, giving it the full causal context it needs to predict.

    In short, each position sees all the causal base context plus its own rollout chain, but never sideways into other rollouts or forward in the base sequence.

    Train your own in 4 steps

    Here's the end-to-end pipeline for Qwen3-8B. The process works the same for other supported models.

    1. Prepare your data:

       python scripts/prepare_data.py \
          --model Qwen/Qwen3-8B --data sharegpt \
          --output ./output/peagle_qwen3_8b \
          --max-samples 5000 --seq-length 4096

      This command takes about 30 seconds. It outputs tokenized Arrow files and a token frequency distribution.

    2. Extract hidden states with vLLM:

      P-EAGLE draft model takes internal hidden states from the target as input. We use vLLM to serve the target and extract them:

      # Launch vLLM with hidden state extraction
        CUDA_VISIBLE_DEVICES=0,1 python scripts/launch_vllm.py Qwen/Qwen3-8B \
          --hidden-states-path ./output/peagle_qwen3_8b/hidden_states \
          -- --data-parallel-size 2 --port 8000
       
        # Generate and cache hidden states
        python scripts/data_generation_offline.py \
          --preprocessed-data ./output/peagle_qwen3_8b \
          --endpoint http://localhost:8000/v1 \
          --output ./output/peagle_qwen3_8b/hidden_states \
          --max-samples 5000 --concurrency 32 --validate-outputs

      For Qwen3-8B, hidden states are pulled from layers 2, 18, and 33 (early, mid, and late representations from the 41-layer model) and concatenated into a 3 × 4096 input tensor.

    3. Train:

      CUDA_VISIBLE_DEVICES=0,1 torchrun --standalone --nproc_per_node 2 \
          scripts/train.py \
          --verifier-name-or-path Qwen/Qwen3-8B \
          --data-path ./output/peagle_qwen3_8b \
          --hidden-states-path ./output/peagle_qwen3_8b/hidden_states \
          --save-path ./output/peagle_qwen3_8b/checkpoints \
          --speculator-type peagle \
          --num-layers 4 --num-depths 4 \
          --down-sample-ratio 0.7 --down-sample-ratio-min 0.2 \
          --no-norm-before-residual \
          --mask-token-id 151669 \
          --scheduler-type cosine --epochs 5 --lr 6e-4 --total-seq-len 4096

      On 4x H100s with 5K samples, training takes about 50 minutes end-to-end.

    4. Deploy:

      Every checkpoint is directly servable in vLLM. It reads the config and enables speculative decoding automatically:

      vllm serve ./output/peagle_qwen3_8b/checkpoints/checkpoint_best

    Example model

    The following table summarizes the results of the trained and published P-EAGLE draft model for the Qwen3-a8B model.

    DatasetPos 1Pos 2Pos 3Pos 4Pos 5Pos 6Pos 7Avg Length
    HumanEval81.3%59.0%41.1%27.9%18.8%12.8%8.9%3.500
    math_reasoning83.3%63.5%47.0%34.3%24.4%17.2%11.8%3.820
    qa70.5%44.7%27.6%17.1%10.8%7.1%4.8%2.830
    question74.6%49.6%31.6%20.2%13.1%8.5%5.6%3.030
    rag73.6%48.4%29.8%18.4%11.3%6.9%4.1%2.930
    summarization68.0%39.0%21.0%10.8%5.4%2.6%1.2%2.480
    tool_call73.7%47.6%28.7%17.1%10.3%6.2%3.7%2.870
    translation73.8%47.7%28.7%17.3%10.4%6.5%4.1%2.890
    writing75.0%50.0%32.1%20.6%13.3%8.7%5.7%3.050
    Average74.9%49.9%31.9%20.4%13.1%8.5%5.5%3.044

    P-EAGLE and the broader Speculators toolkit are open and ready for use today. The fastest way to see speculative decoding in action is to grab one of our pretrained speculators from the Red Hat AI speculator models collection on Hugging Face. Every model and workload is different. If you want a draft model tailored to your target LLM and your data distribution, Speculators provides a single command to train one end-to-end.

    If you're interested in P-EAGLE, follow the steps described in this blog post and train your own!

    Speculators is open source and under active development. We welcome contributions of every kind. Open an issue or a pull request on GitHub and come build the next generation of speculative decoding with us.

    Related Posts

    • Smarter data generation for faster Speculator training

    • Speculators v0.5.0: DFlash support and online training

    • Speculators: Standardized, production-ready speculative decoding

    • How speculative decoding delivers faster LLM inference

    • Performance improvements with speculative decoding in vLLM for gpt-oss

    • Fly Eagle(3) fly: Faster inference with vLLM & speculative decoding

    Recent Posts

    • Speeding up LLM inference with P-EAGLE in vLLM Speculators

    • Evaluating LLM guardrail configs locally with EvalHub

    • Evaluate AI agents with IBM CLEAR & EvalHub on OpenShift AI

    • Extend Layer 2 networks into Red Hat OpenShift Virtualization with BGP and EVPN

    • LoRA backdoor threat: How OpenShift AI mitigates the risk

    What’s up next?

    Learning Path Get started with vLLM feature share

    Get started with vLLM

    Learn how to compress, serve, and benchmark LLMs with vLLM.
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility
    Ask AI