← Back to Pull requests

vxpu/engine: read n-gram tables straight from checkpoint files with io_uring #469

Open
unknown opened this pull request with 252 lines diff across 3 files
View on GitHub
unknown unknown commented on Oct 24, 2026 15:57 UTC
Author

When checkpoint files are local (from a local blob directory or an
attached weights disk) and the step graph is off, read n-gram table rows
straight from the checkpoint files at their byte offsets using io_uring
instead of copying them to external_dir and memory-mapping them.

Why:

  • Saves writing ~203 GB to local SSD at load time (2-3 minutes saved per head range).

  • Avoids page faults on cache misses during decode by batching row reads in one submit.
  • Measurements on c3d-standard-30-lssd (2,000 tokens, 96 reads/token):
    Page cache dropped first (cold miss):
    | method | local SSD mean (p99) | weights disk mean (p99) |
    |---|---|---|
    | mmap, 24 threads | 1.04 ms (1.56) | 8.79 ms (17.4) |
    | pread, 24 threads | 0.92 ms (1.31) | 6.71 ms (11.5) |
    | io_uring, 96 reads submit | 0.68 ms (0.83) | 4.05 ms (5.46) |

    Cached rows: mmap 0.022 ms, pread 0.012 ms, io_uring 0.085 ms.

    Table copy cost at load time:

  • local SSD to local SSD: 195.8 s (1.04 GB/s)

  • weights disk to local SSD: 134.9 s (1.5 GB/s)
  • Changes:

  • Add gather_table_rows in csrc/fp4_kernels.cpp to read both weights and scales for a step's lookups in a single io_uring submit, with a concurrent pread fallback across kernel threads.

  • Check submission queue space before preparing reads and wait until every batch completion is reaped, retrying on -EINTR. Tag SQEs with user_data.

  • The Engine owns table file descriptors with POSIX_FADV_RANDOM and closes them when dropped or unmounted.

  • Report io_uring_ready() once at load time in the plan notes instead of per token.

  • Keep the copy path when the step graph is on, noting why (#470).

  • Distinguish short reads from real errors in the pread fallback.

  • Detect liburing headers in kernels.py (-luring, -DVXPU_HAVE_IO_URING).

  • Add liburing-dev to images/executor/Dockerfile and setup-vm.sh.

  • Add rows_bench.cpp benchmark under dev/vm/.

  • Add selftest cases in vectors_test.py verifying gather_table_rows and blob-dir execution without external_dir table files.

  • Update docs/design.md.
  • Fixes #452

    Diff: 252 lines (+189 / -63) across 3 files Reviewer: justinsb Review duration: 1262m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.39) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 252 lines diff across 3 files
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    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
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.331
    Real PR Conversation Timeline
    1 comments
    "Review active on #469"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% 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: 39% (MEDIUM) · Higher = larger blast radius
    39%
    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: 46.7% · Lower = rushed or shallow review
    46.7%
    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: 20.8% · Safe to merge
    20.8%