← Back to Pull requests

Check where column-split pieces write in a shard #8922

Closed
unknown closed this pull request without merging on Oct 29, 2026 11:58 UTC
View on GitHub
unknown unknown commented on Oct 27, 2026 02:26 UTC
Author

ParamAffineMap.validate() checks where a piece writes in its shard only when the piece's destination is one dense interval. That check came from #8624. A column split has no such interval: each piece writes a few columns of every shard row. So for fused QKV split along columns, Yuan's o_proj, or any sub_param_map / segmented_map / block_gather_map with partition_dim=1, two pieces can write the same shard columns and pass every check.

Reproduction on master (fused QKV (4, 12) split along columns at TP 2):
1. Move rank 0's value piece onto its key columns.
2. validate() and validate_coverage() both pass.
3. rebuild(extract(F)) differs from F in 8 of 48 elements.
4. Two columns of rank 0's shard are never written by extract, so they hold uninitialised memory.

Changes

  • validate() now also checks strided pieces, still from metadata only, without walking elements.

  • - Bounds: each strided piece's lowest and highest shard address must lie inside the shard.
    - Overlap: a column-split piece is a box in its shard's row-major grid, so overlap between such pieces follows from their corners. A strided view that wraps past the end of a shard row is valid but is not a box; the full check below covers it.
    - The box pass runs only on ranks that hold a strided piece. Ranks with only dense pieces cost the same as before.
  • validate_coverage(), the full O(n) check, now walks every shard address and requires each one to be written exactly once. Together with the element-count check, that makes "every shard address is written by exactly one element" a complete check, for any stride, including strided pieces that are not boxes.
  • Tests

    tests/unit/checkpoint/test_affine_shard_map.py:

    | Test | Contract | Fails on master |
    |---|---|---|
    | test_strided_destination_overlap_is_refused | column-split pieces that collide are refused | yes (did not raise) |
    | test_strided_destination_outside_the_shard_is_refused | a column-split piece past the shard's width is refused | yes (did not raise) |
    | test_full_check_refuses_a_destination_collision_of_any_stride | validate_coverage() refuses a collision that no box can describe | yes (did not raise) |
    | test_strided_destination_validation_does_not_enumerate_elements | validate() stays metadata-only for a 10^9 × 8 column split | no; it guards cost |
    | test_strided_destination_that_wraps_a_shard_row_round_trips | a strided view that wraps a shard row but stays inside the shard is accepted and round-trips | no; it guards against refusing a valid map |

    Validation

    macOS 26.5 (arm64, CPU), Python 3.9.6, torch 2.8.0, DS_ACCELERATOR=cpu LOCAL_SIZE=4.

  • test_affine_shard_map.py: 76 passed.

  • test_affine_shard_map.py, test_affine_transfer_plan.py, test_autoep_affine.py, test_autoep_affine_universal.py and test_autotp_uc_checkpoint.py: 276 passed, 5 failed. The failures are identical on master. The 5 tests build the CPU Adam op, which fails on macOS arm64 (cpuinfo reports no flags). They were not run here.

  • In those suites the new box pass checks 28 strided pieces from the existing tests' layouts and rejects none of them.

  • End to end, to confirm the converter path is unaffected: AutoTP training, save, ds_to_universal, then a universal load at another TP degree. Runs: TP 2→4 under ZeRO 1 and 2, including an uneven split at TP 4; TP 4→2 under ZeRO 1. Parameters, exp_avg and exp_avg_sq are restored bit for bit, and the resumed losses match the uninterrupted run to within 1.2e-7.

  • yapf 0.43.0 and flake8 are clean on both files.
  • Refs #8252, #8624.

    @delock

    Diff: 454 lines (+340 / -114) across 5 files Reviewer: jinyouzhi Review duration: 3452m
    All Vouch review confidence checks passed
    Residual risk 0.20 = 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 · 454 lines diff across 5 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.366
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #8922"
    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: 45.5% (MEDIUM) · Higher = larger blast radius
    45.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.7% · Safe to merge
    19.7%