← Back to Pull requests

[AffineIR] Check strided shard destinations without pairwise comparisons #9039

Closed
unknown closed this pull request without merging on Nov 18, 2026 01:21 UTC
View on GitHub
unknown unknown commented on Nov 09, 2026 05:58 UTC
Author

Rebased on master (PRs #9010 and #9011 have merged; this branch is rebased on master at 5dc44e8, so the diff contains only this PR's changes).

ParamAffineMap._validate_destinations (added in #8922) checks the box-shaped pieces of a column split by comparing every box of a rank with every other one. validate() runs whenever a ZeRO, AutoEP or block-gather map is built and before every conversion, and this pass has no budget, so validation grows quadratically with the number of strided pieces per rank.

This PR sweeps the boxes with boxes_disjoint from #9011 first. Only a rank that fails the sweep takes the pairwise walk, which names the shared shard address, so error messages are unchanged.

The second commit moves the remaining hand-written geometry onto affine_geometry: _dest_box returns a LogicalBox built with coordinate(), the shared address comes from intersection() and dot(), and address_range() / overlaps_itself() move there from affine.py. The transfer executor reuses address_range() for its buffer-reach check and dot() for chunk offsets. No behavior or message changes.

validate() of 8 ranks with interleaved columns (64 rows; ms, single CPU process):

| pieces per rank | before | after |
|---|---|---|
| 128 | 29 | 4 |
| 512 | 441 | 17 |
| 2048 | 6654 | 68 |

Tests:

  • Randomized check over 200 seeds: column blocks of row bands tiling a shard, half with one block shifted onto another. validate() refuses exactly the maps whose pieces write some shard address twice (enumerated independently in the test), and every refusal names an address that is written twice. The test checks this contract only, so it does not depend on which helper does the sweep.

  • Mutation checks: making the sweep always report "disjoint" fails 48 of the 200 cases. Forcing every rank through the pairwise walk still passes all 200.

  • All tests/unit/checkpoint/test_affine files: 839 passed, 1 skipped on 4× NVIDIA L20 at f6e1f6c. At ac3a329 on CPU (DS_ACCELERATOR=cpu, 4 ranks): 842 passed, 5 skipped.
  • AI assistance

    Implementation, tests and this description were drafted with GitHub Copilot CLI and reviewed/validated by the author.

    Diff: 274 lines (+205 / -69) across 3 files Reviewer: delock Review duration: 12683m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.45) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 274 lines diff across 3 files
    0.45
    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.336
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #9039"
    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: 44.5% (MEDIUM) · Higher = larger blast radius
    44.5%
    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: 19.2% · Safe to merge
    19.2%