Commit 38e5cbd
feat(cuda): add NVLink topology detection (v1.1)
Per spec section 4.3, foundation for multi-GPU runtime.
NvlinkTopology:
- adjacency matrix with per-link bandwidth (GB/s)
- shortest-hop distance matrix (Floyd-Warshall + BFS)
- probe() via cuDeviceCanAccessPeer for P2P detection
- Optional nvml-wrapper for NVLink bandwidth enrichment
(NvLinkState + NvLinkVersion per link)
- Graceful fallback to single_gpu() when CUDA/NVML unavailable
API:
- probe() -> Result<Self>
- bandwidth(from, to) -> u32
- direct_link_exists(from, to) -> bool
- co_located_candidates(gpu, min_bw) -> Vec<u32>
- shortest_path(from, to) -> Option<Vec<u32>>
- hops(from, to) -> Option<u32>
- Test constructors: single_gpu(), disconnected(n), from_adjacency()
Bandwidth table: NVLink 1.0=20, 2.0/3.0/4.0=25, 5.0=50 GB/s.
P2P fallback without NVML info: 25 GB/s (NVLink 2.0 baseline).
Feature gate: new optional `multi-gpu` feature (adds nvml-wrapper).
Basic P2P detection works with just `cuda`; bandwidth info needs `multi-gpu`.
14 unit tests: single-GPU, 2-GPU linear, 4-GPU ring, 8-GPU hypercube,
disconnected pairs, bandwidth queries, matrix symmetry, diagonals,
co-location ordering, multi-hop paths.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent f6f1d6b commit 38e5cbd
4 files changed
Lines changed: 821 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
47 | 51 | | |
48 | 52 | | |
49 | 53 | | |
| |||
60 | 64 | | |
61 | 65 | | |
62 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
| 58 | + | |
57 | 59 | | |
58 | 60 | | |
59 | 61 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
0 commit comments