← Back to Pull requests

vxpu/plan: extract and carry segment reads and writes #833

Closed
unknown closed this pull request without merging on Nov 24, 2026 03:42 UTC
View on GitHub
unknown unknown commented on Nov 23, 2026 17:43 UTC
Author

vxpu/proto: add ValueKind, Value, and reads and writes to Segment

Define ValueKind, Value, and reads and writes on Segment in plan.proto
so segments declare what values they read and write.

Values are distinguished by their lifecycle:

  • Step inputs (such as input_ids and cache_position) do not outlive the step.

  • Resident values (weights, KV caches, scratch buffers, constants) outlive the step.

  • Intermediate values pass between segments within a single step.

  • Step outputs (such as logits) are produced by the last segment and do not outlive the step.
  • Proto doc comments specify what readers may rely on regarding order,
    naming (including individual unpacked identifiers for tuple-returning
    ops), and lifecycle (including in-place resident mutations). Regenerate
    Go and Python protobuf bindings via ap generate.

    ---

    vxpu/plan: extract reads and writes for each segment from the graph

    Extract the values each segment reads and writes from the exported
    graph (decode.pt2) so that an executor can lay out activation slots
    and run segments in order without analysing the graph.

    Values are distinguished by lifecycle:

  • Step inputs (such as input_ids and cache_position) are provided anew

  • for each step and do not outlive the step.
  • Resident values (weights, KV caches, scratch buffers, constants)

  • persist across steps. Every resident value, whether read or written,
    names its persistent slot (parameter_name, buffer_name, or
    tensor_constant_name) in Value.resident and the segment-local tensor
    in Value.name.
  • Intermediate values pass between segments within a single step.

  • Step outputs (such as logits) are produced by the final segment and

  • returned to the caller.

    In vxpu/pkg/kernelplan/segment.go:

  • Use GraphModule.Signature input_specs and output_specs as the sole

  • source of truth for resident values, step inputs, user outputs, and
    buffer mutations; missing specs or missing resident slot names
    return an error.
  • Enforce strict validation: every value a segment reads must be a

  • declared step input, a resident value, or written by an earlier
    segment, or ReadSegments returns an error naming the value.
  • Require node.Outputs on every node (void ops declare an empty list,

  • while omitting outputs returns an error) and register all output
    tensor identifiers for multi-output ops.
  • Record buffer mutations as VALUE_KIND_RESIDENT writes on the

  • producing segment with Name set to the output tensor carrying the
    new value and Resident set to the persistent slot it replaces. Any
    later segment reading that output tensor in the same step is marked
    consistently as VALUE_KIND_RESIDENT with the same Resident slot and
    observes the new state, while a read of the pre-step placeholder
    observes the start-of-step state. At the end of the step, the
    executor commits the mutated output tensor into Resident.
  • Populate seg.Reads and seg.Writes on each segment.
  • Consequence of refusing archives without signatures or node outputs:
    Any test constructing a mock decode.pt2 archive without a signature
    or node outputs fails. Every such test on main is updated in this
    commit:

  • vxpu/pkg/kernelplan/segment_test.go (createTestArchive and callers)

  • vxpu/pkg/kernelplan/package_test.go (createTestArtifact and fixtures)

  • vxpu/cmd/vxpu/plan_test.go (TestCmdPlanSegments,

  • TestCmdPlanTree_Synthetic, createArtifactWithNodes and callers,
    TestCmdPlanPackages, TestPassThroughPlan_NoOpsModel,
    TestPlanTree_GraphWithOpsDefaultSitesMatchNothing,
    TestPlanEmit_SegmentRunModes)
    The only other test on main that constructs a mock decode.pt2 without
    a signature is vxpu/python/vxpu/lower_test.py
    (test_go_plan_segments_refusal_named_versions), which tests bad
    archive_format, archive_version, and schema_version rejections that
    occur before signature validation and continues to pass unchanged.

    In vxpu/cmd/vxpu/plan.go and vxpu/cmd/vxpu/treeui/tree.html:

  • Print reads and writes (including target resident slots) in

  • cmdPlanSegments and render them on the model structure tree page.

    In dev/ci/presubmits/test-vxpu-python and dev/ci/gpu/test-vxpu-gpu:

  • Run TestReadSegments_ReadsWrites_Tiny on tiny DeepSeek and tiny

  • Llama artifacts where a skip or failure is fatal.

    Fixes #828

    Diff: 528 lines (+396 / -132) across 6 files Reviewer: codebot-robot Review duration: 598m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 528 lines diff across 6 files
    0.48
    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%
    60%
    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.375
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #833"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 47.8% (MEDIUM) · Higher = larger blast radius
    47.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: 60.5% · Lower = rushed or shallow review
    60.5%
    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.9% · Safe to merge
    18.9%