← Back to Pull requests

[AffineIR] Affine storage maps for live ZeRO parameters and optimizer states #8885

Closed
unknown closed this pull request without merging on Oct 28, 2026 16:16 UTC
View on GitHub
unknown unknown commented on Oct 22, 2026 10:59 UTC
Author

Summary

Describes, as affine maps in global ranks, where a live ZeRO engine stores each element of a parameter and its optimizer states, so plan_transfer can read from or write into training storage directly (e.g. training → rollout weight sync) without gathering full parameters first.

  • zero_affine.py

  • - zero_param_storage_affine_map: low-precision replicas under ZeRO-0/1/2 (DP or expert-DP group), ds_tensor partitions under ZeRO-3, padding excluded.
    - zero_optimizer_storage_affine_maps: fp32 master + optimizer states (ZeRO-1/2, bf16 optimizer, ZeRO-3).
    - zero_param_storage_shard / zero_optimizer_storage_shard: flat views of ZeRO's own buffers matching the maps.
    - autotp_storage_affine_maps: AutoTP layout × ZeRO storage, one all-gather over the TP group.
  • affine.py: nest_affine_maps composes a layout map (TP/EP shard placement) with per-shard storage maps. A process's stored run of an N-D shard is described as at most 2·ndim−1 N-D boxes in the parameter's own shape, so plans stay small (row-parallel shards are not cut per row).

  • affine_transfer.py: plan_transfer accepts an N-D piece in a 1-D (flat) shard only when the piece is dense there; every other rank mismatch is still refused.

  • affine_ir_spec.md: phase-2 section on layout vs storage maps.

  • Fix test_convert_checkpoint stat().size → st_size (from #8515).
  • No change to ZeRO, AutoTP or the executor. Offloaded optimizer states raise NotImplementedError; MiCS / hpZ are not covered.

    Tests

  • tests/unit/checkpoint/test_zero_affine.py, test_affine_transfer_plan.py: ZeRO-0/1/2/3 param + optimizer maps checked against ZeRO's own buffers (bitwise rebuild), AutoTP nest, N-D box count, flat-shard acceptance/refusal.

  • - ≤2 ranks: Intel Arc B70 (XPU) ×2, pass. >2 ranks: CPU (gloo), pass.
  • End-to-end (deepspeedai/DeepSpeedExamples#1021): Qwen3-8B, 8× NVIDIA L20, AutoTP-2 training engine → AutoTP-4 rollout engine via autotp_storage_affine_maps + plan_transfer + executor (#8809), ZeRO-2 and ZeRO-3, weights bitwise equal after every sync. Plans are built once and reused.
  • | Qwen3-8B, 8×L20 | ZeRO-2 gather | ZeRO-2 affine lowest | ZeRO-2 affine balanced | ZeRO-3 gather | ZeRO-3 affine |
    |---|---|---|---|---|---|
    | maps + plan (once) | - | 0.63 + 0.57 s | 0.70 + 0.70 s | - | 0.82 + 0.60 s |
    | first sync | 1.01 s | 1.16 s | 0.48 s | 1.71 s | 1.18 s |
    | repeated syncs | 0.78-0.82 s | 1.05-1.35 s | 0.49-0.55 s | 1.22-1.28 s | 0.45-0.74 s |
    | device memory added | 3.48 GB | 0.30 GB | 0.16 GB | 3.48 GB | 0.66 GB |
    | sent / local copy | - | 35.2 / 5.0 GB | 15.1 / 25.1 GB | - | 34.0 / 6.3 GB |
    | executor rounds | - | 96 | 41 | - | 32 |

    Each map has 3,192 pieces on both sides; before N-D boxes (one piece per stored row) the same ZeRO-3 maps had 592k source / 2.36M target pieces and planning took 207 s. Under ZeRO-2 every DP rank holds a replica: lowest is the planner's default holder choice, balanced is a replica_selector in the example (local copy first, else the least-loaded holder).

    Diff: 380 lines (+285 / -95) across 4 files Reviewer: jinyouzhi Review duration: 8957m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 380 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%
    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.356
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #8885"
    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: 42.9% (MEDIUM) · Higher = larger blast radius
    42.9%
    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: 17.0% · Safe to merge
    17.0%