← Back to Pull requests

vxpu/engine: load the plan's prebuilt packages when serving on CPU #799

Closed
unknown closed this pull request without merging on Nov 22, 2026 23:27 UTC
View on GitHub
unknown unknown commented on Nov 22, 2026 02:41 UTC
Author

A serving engine on CPU now loads the prebuilt AOTInductor packages named
in its plan, as an engine on GPU does, and compiles nothing at startup
when all named packages are present.

Previously, Plan.__init__ forced segment_runtime from "aoti" back to "jit"
on non-CUDA devices ("aoti requires CUDA and a compiled split decode").
Additionally, compile_segments unconditionally allocated a CUDA graph memory
pool via torch.cuda.graph_pool_handle(), and GraphedSegment assumed CUDA
graphs by capturing and replaying a CUDAGraph on non-warmup calls. As a
result, packages compiled for CPU machines were ignored at serve time,
forcing every CPU engine start to compile segments with torch.compile.

This change:
1. Removes the CUDA restriction in Plan.__init__ for segment_runtime="aoti",
requiring only split_decode and split_compile.
2. Introduces a direct segment type (aoti.Segment) alongside aoti.GraphedSegment.
compile_segments chooses between them once where the segment is loaded
from what the plan says (plan["segment_graph"]), avoiding device checks
and mode switches inside segment execution. VXPU_SEGMENT_GRAPH is a plan
switch carried by the plan in COORDINATOR_SWITCHES; on CUDA it defaults
to 1 and on CPU it is 0. In production today, nobody sets VXPU_SEGMENT_GRAPH;
the Go planner should carry this switch as a knob in the emitted plan.
StepGraph accepts any loaded aoti.Segment.
3. Allocates the CUDA graph memory pool in compile_segments only when
graphed is True, and rejects unknown or host-op package names.
4. Excludes segments already recorded as failed in the package report from
dense_tasks, running them via torch.compile without retrying doomed builds
at startup. Unscheduled build failures fail the load on all devices.
Engine.__init__ refuses step_graph if any packages failed, naming them.
5. In Packages._build_all, records build failures for all segment names that
share a cache key rather than only the first one.
6. Preserves a single source and single type for packages (PackageReport)
passed to Engine.__init__, avoiding private state inspection by having tests
assert on what the engine already reports via Packages.report().
7. Updates compile_package_test.py to pass plan settings cleanly and assert
on what the engine reports: on CPU, prebuilt packages are loaded from
cache with none built, and generated tokens match the eager reference.

Measurements on Intel Xeon @ 2.20GHz (32 vCPUs, Linux x86_64, tiny DeepSeek
fixture in CompilePackageTest):

  • Engine initialization: 14.90 s before (JIT) vs 14.17 s after (AOTI prebuilt).

  • Time to serve the first token: 23.72 s before (JIT) vs 20.90 s after (AOTI prebuilt),

  • saving 2.82 s (~12% faster start).
  • The remaining ~14 s of startup is non-compilation model rehydration: loading and

  • unarchiving the exported graph from decode.pt2 (9.3 s), probing the checkpoint
    state dict (3.5 s), and binding model parameters (0.8 s) (#454).

    Fixes #793

    Diff: 373 lines (+279 / -94) across 4 files Reviewer: codebot-robot Review duration: 1246m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.43) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 373 lines diff across 4 files
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.354
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #799"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.8% (MEDIUM) · Higher = larger blast radius
    42.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.5% · Safe to merge
    18.5%