Files
rustytorch/docs/archive/legacy/phase3.md
T
2026-03-04 00:08:42 +00:00

7.2 KiB
Raw Blame History

RustyTorch++ — Phase 3 Plan (Distributed Training & MultiGPU Execution)

Objective (45 months): Enable scalable training across multiple GPUs and nodes with topologyaware communication, hybrid parallelism (data/tensor/pipeline/sequence), elastic recovery, and sharded states (FSDP/ZeROstyle). Maintain determinism where declared and ship CI gates, benchmarks, and observability tailored to distributed runs.

Reference paths

RUSTYTORCH_ROOT: /home/osobh/projects/rustytorch

RUSTG_COMPILER: /home/osobh/projects/rust/rustg (RTX 5090, sm_120)

STRATOSWARM_ROOT: /home/osobh/projects/stratoswarm (deployment in later phases)

Darwin apps remain deferred. Phase 3 focuses on RustyTorch++ core scaling.

  1. Scope & NonGoals

In scope

Communication backend: NCCL (CUDA) / RCCL (ROCm) integration and process group API

Topology discovery & hints (PCIe, NVLink, NVSwitch, InfiniBand)

Parallelism: data parallel (DP), tensor parallel (TP), pipeline parallel (PP), sequence parallel (SP); autohybrid partitioner

Sharded training: FSDP/ZeROstyle (gradients, optimizer, and parameters)

Elastic engine: membership changes (join/leave), preemptionsafe checkpoints (WAL), retry/backoff

Overlap: comm/compute scheduling; bucketization; gradient accumulation

Determinism surface for distributed runs (documented limits)

Benchmarks & CI at 1, 2, 4, 8 GPUs (singlenode) and 24 nodes (where available)

Out of scope (Phase 4+)

Advanced autokernel synthesis & compiler autotuning (beyond basic sweeps)

Inference serving/scheduling stack (separate track)

  1. Success Criteria (Exit / PhaseGate)

Functional DP/TP/PP/SP with a simple configuration API; hybrids validated on reference models.

Sharded training reduces perGPU memory by ≥40% versus DP baseline at equal global batch.

Throughput scaling: ≥0.8× efficiency from 1→8 GPUs (single node); ≥0.7× to multinode on IB/NVLink.

Elasticity: midrun failure of one rank recovers automatically; preemption resumes from latest durable checkpoint.

Determinism: declared deterministic mode yields repeatable results within tolerance across identical hardware and seeds; nondeterministic surfaces are documented.

Observability: perrank and aggregated timelines/metrics; bottleneck attribution (compute vs. network) with actionable hints.

  1. Architecture Work

A. Process Group & Collectives

Process group abstraction (rtx-dist) with pluggable backends (NCCL/RCCL; CPU fallback)

Collectives: allreduce, reducescatter, allgather, broadcast; async handles with stream selection

Fault detection (timeout/health) and retry/backoff policies

B. Topology & Placement

Discover PCIe/NVLink/NVSwitch/IB; build bandwidth/latency matrix

Rank mapping strategies (ring, mesh, tree) selected by topology and model parallel mode

Affinity & NUMA pinning policies

C. Parallelism Implementations

DP with gradient bucketing & overlap

TP (tensorslicing of large layers) with fused allreduce/allgather epilogues

PP with microbatching & 1F1B schedule; activation checkpointing integration

SP for attention/sequencelength scaling

Autohybrid planner chooses DP/TP/PP mix from model graph & hardware profile

D. Sharded Training (FSDP/ZeROstyle)

Partition parameters/gradients/optimizer states

State prefetch & offload hooks (CPU/NVMe) with backpressure

Checkpoint format with shard metadata; streaming save/restore

E. Elasticity & Reliability

Rendezvous service; rank reconfiguration without restart

WAL checkpoints + periodic durable snapshots

Deterministic resume: resume graph/seed/capture hashes; verify parity

  1. APIs & Configuration

dist.init(backend, devices, env); returns process group

parallel.configure({dp, tp, pp, sp, micro_batch, bucket_bytes})

fsdp.configure({shard_strategy, offload={'cpu'|'nvme'|none}, auto_wrap=true})

elastic.configure({rendezvous, preempt_policy, checkpoint_interval})

Minimal user code to switch from singleGPU to distributed (≤ 10 LOC)

  1. Benchmarks & Baselines

Models

LLMblock (attention + MLP) and GPTstyle stack; ViT block for CV parity

Scales

Single node: 1, 2, 4, 8 GPUs (RTX 5090)

Multinode (if available): 24 nodes with IB

Metrics

Tokens/sec (or images/sec), step time, p50/p95/p99, allreduce time %, overlap %, network BW utilization, peak memory, frag%

  1. CI Gates (Phase 3)

Scaling Gate: efficiency thresholds (≥0.8× 1→8 GPUs single node)

Memory Gate: FSDP/ZeRO memory reduction ≥40% vs DP

Reliability Gate: injected rank failure recovers; determinism resume parity

Security Gate: dependency pinning; SBOM/sign; secrets hygiene

  1. Observability & Telemetry

Perrank Nsight/rocprof traces; aggregated timeline

Prometheus: step_time_ms, tokens_per_s, allreduce_pct, overlap_pct, net_bw_gbps, alloc_frag_pct, oom_count

Bottleneck classifier (computebound vs. networkbound) with suggestions

  1. Deliverables

rtx-dist crate (process group, collectives, rendezvous)

Parallelism modules (DP/TP/PP/SP) + autohybrid planner

rtx-fsdp (or integrated) sharding with offload hooks & checkpoint format

Elastic runtime with WAL checkpoints and preemption support

Benchmarks & dashboards for scaling curves; CI gates

Documentation: docs/distributed.md, docs/fsdp.md, examples

  1. RACI — Phase 3 Agent Ownership

Conductor (Orchestrator) — Accountable: crossagent plan, gate readiness

Distributed Strategy Agent — Responsible: topology discovery, planner, overlap scheduling

Rust Engineer — Responsible: runtime hooks, stream/collective integration, checkpoint I/O

Kernel Synthesizer Agent — Consulted: fused epilogues for collectiveadjacent ops

Memory Planner Agent — Responsible: sharding integration; offload/backpressure policies

Performance Engineer — Accountable: scaling benches, overlap tuning, efficiency gates

Security Engineer & Auditor — Accountable: dependency/secret policies; SBOM/sign

DevOps Engineer — Responsible: multiGPU runners; optional multinode staging; artifact storage

Governance & Provenance Agent — Responsible: checkpoint provenance; reproducible resumes

Agent Organizer — Accountable: routing, tool allowlists, freeze switch on gate failures

  1. Risks & Mitigations

Allreduce bottlenecks → bucket tuning; overlap; topologyaware rings/trees

Elasticity edge cases → chaos tests; forced rank drops; partial shard recovery

Determinism drift → documented nondet surfaces; seed discipline; stable reductions; resume checks

Network variance → pin NIC/drivers; IB tuning; retry/backoff

Memory pressure → shard/offload thresholds; activation checkpointing; streaming checkpoints

  1. Timeline (suggested)

Weeks 12: Process group, collectives, rendezvous prototype; singlenode DP

Weeks 34: TP/PP/SP implementations; overlap scheduling; hybrid planner

Weeks 56: FSDP/ZeRO sharding & checkpoint format; offload hooks

Weeks 78: Elastic runtime; chaos tests; multiGPU scaling benches; CI gates; docs; phasegate review

  1. Phase4 Handover Seeds

Compiler autotuning & autokernel synthesis plan (hardware profile DB, caches)

Inference scheduler design seeds (continuous batching, KV paging)

Governance extension for distributed reproducibility across clusters

— End of Phase 3 Plan —