vizmatic 0.1.37 → 0.1.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PROMPT.md +2 -1
- package/README.md +4 -1
- package/dist/cli.js +330 -25
- package/dist/index.cjs +331 -25
- package/dist/index.d.cts +44 -2
- package/dist/index.d.ts +44 -2
- package/dist/index.js +330 -25
- package/examples/README.md +2 -0
- package/examples/catalog-charts.tsx +24 -2
- package/examples/desired-quadrant.tsx +80 -0
- package/examples/nccl-all-gather.tsx +157 -5
- package/examples/nccl-all-reduce.tsx +150 -5
- package/examples/nccl-all-to-all.tsx +137 -5
- package/examples/nccl-broadcast.tsx +131 -5
- package/examples/nccl-reduce-scatter.tsx +161 -5
- package/examples/pareto-frontier.tsx +61 -0
- package/package.json +1 -1
- package/examples/_shared/nccl-collective.tsx +0 -420
|
@@ -1,14 +1,166 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
defineAnimation,
|
|
3
|
+
getReadableToneColor,
|
|
4
|
+
getReadableTextColor,
|
|
5
|
+
getThemeColors,
|
|
6
|
+
getToneColor,
|
|
7
|
+
hold,
|
|
8
|
+
tween,
|
|
9
|
+
type ThemeMode,
|
|
10
|
+
} from 'vizmatic'
|
|
3
11
|
|
|
4
|
-
export
|
|
12
|
+
export const width = 1040
|
|
13
|
+
export const height = 500
|
|
14
|
+
|
|
15
|
+
type State = { progress: number }
|
|
16
|
+
type Colors = ReturnType<typeof getThemeColors>
|
|
17
|
+
|
|
18
|
+
const clamp = (value: number) => Math.max(0, Math.min(1, value))
|
|
19
|
+
const rankY = (rank: number) => 100 + rank * 54
|
|
20
|
+
|
|
21
|
+
function Token({ x, y, label, color, textColor, opacity = 1 }: { x: number; y: number; label: string; color: string; textColor: string; opacity?: number }) {
|
|
22
|
+
return (
|
|
23
|
+
<div style={{
|
|
24
|
+
display: 'flex',
|
|
25
|
+
position: 'absolute',
|
|
26
|
+
left: x - 15,
|
|
27
|
+
top: y - 15,
|
|
28
|
+
width: 30,
|
|
29
|
+
height: 30,
|
|
30
|
+
alignItems: 'center',
|
|
31
|
+
justifyContent: 'center',
|
|
32
|
+
borderRadius: 8,
|
|
33
|
+
backgroundColor: color,
|
|
34
|
+
color: textColor,
|
|
35
|
+
fontFamily: 'JetBrains Mono',
|
|
36
|
+
fontSize: 11,
|
|
37
|
+
fontWeight: 900,
|
|
38
|
+
opacity,
|
|
39
|
+
}}>
|
|
40
|
+
{label}
|
|
41
|
+
</div>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function RankLanes({ c }: { c: Colors }) {
|
|
46
|
+
return (
|
|
47
|
+
<div style={{ display: 'flex', position: 'absolute', inset: 0 }}>
|
|
48
|
+
{[0, 1, 2, 3].map((rank) => (
|
|
49
|
+
<div key={rank} style={{ display: 'flex', position: 'absolute', inset: 0 }}>
|
|
50
|
+
<div style={{
|
|
51
|
+
display: 'flex',
|
|
52
|
+
position: 'absolute',
|
|
53
|
+
left: 22,
|
|
54
|
+
top: rankY(rank) - 16,
|
|
55
|
+
width: 122,
|
|
56
|
+
height: 32,
|
|
57
|
+
alignItems: 'center',
|
|
58
|
+
gap: 10,
|
|
59
|
+
paddingLeft: 12,
|
|
60
|
+
borderRadius: 9,
|
|
61
|
+
backgroundColor: c.bgCardAlt,
|
|
62
|
+
border: `1px solid ${c.borderSubtle}`,
|
|
63
|
+
color: c.textPrimary,
|
|
64
|
+
fontFamily: c.fontMono,
|
|
65
|
+
fontSize: 12,
|
|
66
|
+
fontWeight: 800,
|
|
67
|
+
}}>
|
|
68
|
+
<span style={{ width: 10, height: 10, borderRadius: 10, backgroundColor: c.neutralLight }} />
|
|
69
|
+
rank {rank}
|
|
70
|
+
</div>
|
|
71
|
+
<div style={{ display: 'flex', position: 'absolute', left: 170, top: rankY(rank) - 1, width: 780, height: 2, backgroundColor: c.borderSubtle }} />
|
|
72
|
+
</div>
|
|
73
|
+
))}
|
|
74
|
+
</div>
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function Frame({ theme, progress }: { theme: ThemeMode; progress: number }) {
|
|
79
|
+
const c = getThemeColors(theme)
|
|
80
|
+
const color = getToneColor('blue', c)
|
|
81
|
+
const semanticColor = getReadableToneColor('blue', c, c.bgCard)
|
|
82
|
+
const textColor = getReadableTextColor(color, c)
|
|
83
|
+
const p = clamp(progress)
|
|
84
|
+
const gather = clamp(p / 0.5)
|
|
85
|
+
const replicate = clamp((p - 0.44) / 0.56)
|
|
86
|
+
const inputOpacity = 1 - clamp((p - 0.46) / 0.12)
|
|
87
|
+
const centerX = 548
|
|
88
|
+
const centerY = 181
|
|
89
|
+
const sourceX = 226
|
|
90
|
+
const outputX = 730
|
|
91
|
+
const labels = ['A', 'B', 'C', 'D']
|
|
92
|
+
const phase = p < 0.46 ? 'gather rank-owned shards' : p < 0.92 ? 'replicate ordered tensor' : 'A · B · C · D on every rank'
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<div style={{ display: 'flex', position: 'relative', width, height, backgroundColor: c.bg, fontFamily: c.fontSans }}>
|
|
96
|
+
<div style={{ display: 'flex', width, height, opacity: 0 }} />
|
|
97
|
+
<div style={{ display: 'flex', position: 'absolute', top: 18, width: '100%', justifyContent: 'center', color: c.textPrimary, fontSize: 36, fontWeight: 800 }}>NCCL · AllGather</div>
|
|
98
|
+
<div style={{ display: 'flex', position: 'absolute', top: 62, width: '100%', justifyContent: 'center', color: c.textSecondary, fontFamily: c.fontMono, fontSize: 14 }}>Every GPU contributes one shard and receives complete ordered tensor</div>
|
|
99
|
+
|
|
100
|
+
<div style={{ display: 'flex', position: 'absolute', left: 26, top: 100, width: 988, height: 374, overflow: 'hidden', borderRadius: 14, backgroundColor: c.bgCard, border: `1px solid ${c.borderSubtle}` }}>
|
|
101
|
+
<div style={{ display: 'flex', position: 'absolute', left: 22, top: 18, alignItems: 'center', gap: 10 }}>
|
|
102
|
+
<span style={{ width: 6, height: 28, borderRadius: 6, backgroundColor: color }} />
|
|
103
|
+
<span style={{ color: c.textPrimary, fontSize: 20, fontWeight: 800 }}>AllGather</span>
|
|
104
|
+
<span style={{ color: c.textMuted, fontFamily: c.fontMono, fontSize: 11 }}>collect shards in rank order</span>
|
|
105
|
+
</div>
|
|
106
|
+
<div style={{ display: 'flex', position: 'absolute', right: 22, top: 24, color: semanticColor, fontFamily: c.fontMono, fontSize: 12, fontWeight: 900 }}>ALL → ALL · CONCAT</div>
|
|
107
|
+
|
|
108
|
+
<RankLanes c={c} />
|
|
109
|
+
<div style={{ display: 'flex', position: 'absolute', left: centerX - 58, top: centerY - 48, width: 116, height: 96, alignItems: 'center', justifyContent: 'center', borderRadius: 12, backgroundColor: c.bgCardAlt, border: `2px dashed ${color}`, opacity: 0.82 }} />
|
|
110
|
+
<div style={{ display: 'flex', position: 'absolute', left: centerX - 25, top: centerY - 65, color: c.textMuted, fontFamily: c.fontMono, fontSize: 11, fontWeight: 900 }}>CONCAT</div>
|
|
111
|
+
{inputOpacity > 0.01 && labels.map((label, rank) => {
|
|
112
|
+
const slotX = centerX - 36 + rank * 24
|
|
113
|
+
return (
|
|
114
|
+
<Token
|
|
115
|
+
key={`input-${rank}`}
|
|
116
|
+
x={sourceX + (slotX - sourceX) * gather}
|
|
117
|
+
y={rankY(rank) + (centerY - rankY(rank)) * gather}
|
|
118
|
+
label={label}
|
|
119
|
+
color={color}
|
|
120
|
+
textColor={textColor}
|
|
121
|
+
opacity={inputOpacity}
|
|
122
|
+
/>
|
|
123
|
+
)
|
|
124
|
+
})}
|
|
125
|
+
{[0, 1, 2, 3].flatMap((target) => labels.map((label, source) => {
|
|
126
|
+
const slotX = centerX - 36 + source * 24
|
|
127
|
+
return (
|
|
128
|
+
<Token
|
|
129
|
+
key={`output-${target}-${source}`}
|
|
130
|
+
x={slotX + (outputX + source * 40 - slotX) * replicate}
|
|
131
|
+
y={centerY + (rankY(target) - centerY) * replicate}
|
|
132
|
+
label={label}
|
|
133
|
+
color={color}
|
|
134
|
+
textColor={textColor}
|
|
135
|
+
opacity={replicate}
|
|
136
|
+
/>
|
|
137
|
+
)
|
|
138
|
+
}))}
|
|
139
|
+
|
|
140
|
+
<div style={{ display: 'flex', position: 'absolute', left: 22, top: 326, color: c.textMuted, fontFamily: c.fontMono, fontSize: 11 }}>{phase}</div>
|
|
141
|
+
<div style={{ display: 'flex', position: 'absolute', left: 170, top: 332, width: 780, height: 6, borderRadius: 6, backgroundColor: c.borderSubtle }}>
|
|
142
|
+
<div style={{ display: 'flex', width: `${Math.round(p * 100)}%`, height: 6, borderRadius: 6, backgroundColor: color }} />
|
|
143
|
+
</div>
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
)
|
|
147
|
+
}
|
|
5
148
|
|
|
6
149
|
export function createAnimation(theme: ThemeMode) {
|
|
7
|
-
return
|
|
150
|
+
return defineAnimation<State>({
|
|
151
|
+
initial: { progress: 0 },
|
|
152
|
+
timeline: [
|
|
153
|
+
hold(800, 'one shard per rank'),
|
|
154
|
+
tween<Partial<State>>({ progress: 1 }, { duration: 3000, easing: 'ease-in-out', label: 'gather and replicate' }),
|
|
155
|
+
hold(1000, 'complete tensors'),
|
|
156
|
+
],
|
|
157
|
+
fps: 20,
|
|
158
|
+
render: (state) => <Frame theme={theme} progress={state.progress} />,
|
|
159
|
+
})
|
|
8
160
|
}
|
|
9
161
|
|
|
10
162
|
export function create(theme: ThemeMode = 'dark') {
|
|
11
|
-
return
|
|
163
|
+
return <Frame theme={theme} progress={1} />
|
|
12
164
|
}
|
|
13
165
|
|
|
14
166
|
export default create('dark')
|
|
@@ -1,14 +1,159 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
defineAnimation,
|
|
3
|
+
getReadableToneColor,
|
|
4
|
+
getReadableTextColor,
|
|
5
|
+
getThemeColors,
|
|
6
|
+
getToneColor,
|
|
7
|
+
hold,
|
|
8
|
+
tween,
|
|
9
|
+
type ThemeMode,
|
|
10
|
+
} from 'vizmatic'
|
|
3
11
|
|
|
4
|
-
export
|
|
12
|
+
export const width = 1040
|
|
13
|
+
export const height = 500
|
|
14
|
+
|
|
15
|
+
type State = { progress: number }
|
|
16
|
+
type Colors = ReturnType<typeof getThemeColors>
|
|
17
|
+
|
|
18
|
+
const clamp = (value: number) => Math.max(0, Math.min(1, value))
|
|
19
|
+
const rankY = (rank: number) => 100 + rank * 54
|
|
20
|
+
|
|
21
|
+
function Token({ x, y, label, color, textColor, opacity = 1 }: { x: number; y: number; label: string; color: string; textColor: string; opacity?: number }) {
|
|
22
|
+
return (
|
|
23
|
+
<div style={{
|
|
24
|
+
display: 'flex',
|
|
25
|
+
position: 'absolute',
|
|
26
|
+
left: x - 18,
|
|
27
|
+
top: y - 16,
|
|
28
|
+
width: 36,
|
|
29
|
+
height: 32,
|
|
30
|
+
alignItems: 'center',
|
|
31
|
+
justifyContent: 'center',
|
|
32
|
+
borderRadius: 16,
|
|
33
|
+
backgroundColor: color,
|
|
34
|
+
color: textColor,
|
|
35
|
+
fontFamily: 'JetBrains Mono',
|
|
36
|
+
fontSize: 11,
|
|
37
|
+
fontWeight: 900,
|
|
38
|
+
opacity,
|
|
39
|
+
}}>
|
|
40
|
+
{label}
|
|
41
|
+
</div>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function RankLanes({ c }: { c: Colors }) {
|
|
46
|
+
return (
|
|
47
|
+
<div style={{ display: 'flex', position: 'absolute', inset: 0 }}>
|
|
48
|
+
{[0, 1, 2, 3].map((rank) => (
|
|
49
|
+
<div key={rank} style={{ display: 'flex', position: 'absolute', inset: 0 }}>
|
|
50
|
+
<div style={{
|
|
51
|
+
display: 'flex',
|
|
52
|
+
position: 'absolute',
|
|
53
|
+
left: 22,
|
|
54
|
+
top: rankY(rank) - 16,
|
|
55
|
+
width: 122,
|
|
56
|
+
height: 32,
|
|
57
|
+
alignItems: 'center',
|
|
58
|
+
gap: 10,
|
|
59
|
+
paddingLeft: 12,
|
|
60
|
+
borderRadius: 9,
|
|
61
|
+
backgroundColor: c.bgCardAlt,
|
|
62
|
+
border: `1px solid ${c.borderSubtle}`,
|
|
63
|
+
color: c.textPrimary,
|
|
64
|
+
fontFamily: c.fontMono,
|
|
65
|
+
fontSize: 12,
|
|
66
|
+
fontWeight: 800,
|
|
67
|
+
}}>
|
|
68
|
+
<span style={{ width: 10, height: 10, borderRadius: 10, backgroundColor: c.neutralLight }} />
|
|
69
|
+
rank {rank}
|
|
70
|
+
</div>
|
|
71
|
+
<div style={{ display: 'flex', position: 'absolute', left: 170, top: rankY(rank) - 1, width: 780, height: 2, backgroundColor: c.borderSubtle }} />
|
|
72
|
+
</div>
|
|
73
|
+
))}
|
|
74
|
+
</div>
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function Frame({ theme, progress }: { theme: ThemeMode; progress: number }) {
|
|
79
|
+
const c = getThemeColors(theme)
|
|
80
|
+
const color = getToneColor('purple', c)
|
|
81
|
+
const semanticColor = getReadableToneColor('purple', c, c.bgCard)
|
|
82
|
+
const textColor = getReadableTextColor(color, c)
|
|
83
|
+
const p = clamp(progress)
|
|
84
|
+
const reduce = clamp(p / 0.5)
|
|
85
|
+
const broadcast = clamp((p - 0.46) / 0.54)
|
|
86
|
+
const inputOpacity = 1 - clamp((p - 0.46) / 0.12)
|
|
87
|
+
const centerX = 548
|
|
88
|
+
const centerY = 181
|
|
89
|
+
const sourceX = 226
|
|
90
|
+
const targetX = 850
|
|
91
|
+
const phase = p < 0.46 ? 'reduce matching values' : p < 0.92 ? 'broadcast completed sum' : 'same sum on every rank'
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<div style={{ display: 'flex', position: 'relative', width, height, backgroundColor: c.bg, fontFamily: c.fontSans }}>
|
|
95
|
+
<div style={{ display: 'flex', width, height, opacity: 0 }} />
|
|
96
|
+
<div style={{ display: 'flex', position: 'absolute', top: 18, width: '100%', justifyContent: 'center', color: c.textPrimary, fontSize: 36, fontWeight: 800 }}>NCCL · AllReduce</div>
|
|
97
|
+
<div style={{ display: 'flex', position: 'absolute', top: 62, width: '100%', justifyContent: 'center', color: c.textSecondary, fontFamily: c.fontMono, fontSize: 14 }}>Reduce rank-local values, then return completed sum to every GPU</div>
|
|
98
|
+
|
|
99
|
+
<div style={{ display: 'flex', position: 'absolute', left: 26, top: 100, width: 988, height: 374, overflow: 'hidden', borderRadius: 14, backgroundColor: c.bgCard, border: `1px solid ${c.borderSubtle}` }}>
|
|
100
|
+
<div style={{ display: 'flex', position: 'absolute', left: 22, top: 18, alignItems: 'center', gap: 10 }}>
|
|
101
|
+
<span style={{ width: 6, height: 28, borderRadius: 6, backgroundColor: color }} />
|
|
102
|
+
<span style={{ color: c.textPrimary, fontSize: 20, fontWeight: 800 }}>AllReduce</span>
|
|
103
|
+
<span style={{ color: c.textMuted, fontFamily: c.fontMono, fontSize: 11 }}>sum first; replicate second</span>
|
|
104
|
+
</div>
|
|
105
|
+
<div style={{ display: 'flex', position: 'absolute', right: 22, top: 24, color: semanticColor, fontFamily: c.fontMono, fontSize: 12, fontWeight: 900 }}>ALL → ALL</div>
|
|
106
|
+
|
|
107
|
+
<RankLanes c={c} />
|
|
108
|
+
<div style={{ display: 'flex', position: 'absolute', left: centerX - 27, top: centerY - 27, width: 54, height: 54, alignItems: 'center', justifyContent: 'center', borderRadius: 54, backgroundColor: c.bgCardAlt, border: `2px solid ${color}`, color, fontFamily: c.fontMono, fontSize: 20, fontWeight: 900 }}>Σ</div>
|
|
109
|
+
{inputOpacity > 0.01 && [0, 1, 2, 3].map((rank) => (
|
|
110
|
+
<Token
|
|
111
|
+
key={`input-${rank}`}
|
|
112
|
+
x={sourceX + (centerX - sourceX) * reduce}
|
|
113
|
+
y={rankY(rank) + (centerY - rankY(rank)) * reduce}
|
|
114
|
+
label={String(rank + 1)}
|
|
115
|
+
color={color}
|
|
116
|
+
textColor={textColor}
|
|
117
|
+
opacity={inputOpacity}
|
|
118
|
+
/>
|
|
119
|
+
))}
|
|
120
|
+
{[0, 1, 2, 3].map((rank) => (
|
|
121
|
+
<Token
|
|
122
|
+
key={`output-${rank}`}
|
|
123
|
+
x={centerX + (targetX - centerX) * broadcast}
|
|
124
|
+
y={centerY + (rankY(rank) - centerY) * broadcast}
|
|
125
|
+
label="10"
|
|
126
|
+
color={color}
|
|
127
|
+
textColor={textColor}
|
|
128
|
+
opacity={broadcast}
|
|
129
|
+
/>
|
|
130
|
+
))}
|
|
131
|
+
<div style={{ display: 'flex', position: 'absolute', left: centerX - 42, top: centerY + 34, color: c.textMuted, fontFamily: c.fontMono, fontSize: 11 }}>1 + 2 + 3 + 4</div>
|
|
132
|
+
|
|
133
|
+
<div style={{ display: 'flex', position: 'absolute', left: 22, top: 326, color: c.textMuted, fontFamily: c.fontMono, fontSize: 11 }}>{phase}</div>
|
|
134
|
+
<div style={{ display: 'flex', position: 'absolute', left: 170, top: 332, width: 780, height: 6, borderRadius: 6, backgroundColor: c.borderSubtle }}>
|
|
135
|
+
<div style={{ display: 'flex', width: `${Math.round(p * 100)}%`, height: 6, borderRadius: 6, backgroundColor: color }} />
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
138
|
+
</div>
|
|
139
|
+
)
|
|
140
|
+
}
|
|
5
141
|
|
|
6
142
|
export function createAnimation(theme: ThemeMode) {
|
|
7
|
-
return
|
|
143
|
+
return defineAnimation<State>({
|
|
144
|
+
initial: { progress: 0 },
|
|
145
|
+
timeline: [
|
|
146
|
+
hold(800, 'rank-local values'),
|
|
147
|
+
tween<Partial<State>>({ progress: 1 }, { duration: 3000, easing: 'ease-in-out', label: 'reduce and broadcast' }),
|
|
148
|
+
hold(1000, 'replicated sum'),
|
|
149
|
+
],
|
|
150
|
+
fps: 20,
|
|
151
|
+
render: (state) => <Frame theme={theme} progress={state.progress} />,
|
|
152
|
+
})
|
|
8
153
|
}
|
|
9
154
|
|
|
10
155
|
export function create(theme: ThemeMode = 'dark') {
|
|
11
|
-
return
|
|
156
|
+
return <Frame theme={theme} progress={1} />
|
|
12
157
|
}
|
|
13
158
|
|
|
14
159
|
export default create('dark')
|
|
@@ -1,14 +1,146 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
defineAnimation,
|
|
3
|
+
getReadableToneColor,
|
|
4
|
+
getReadableTextColor,
|
|
5
|
+
getThemeColors,
|
|
6
|
+
getToneColor,
|
|
7
|
+
hold,
|
|
8
|
+
tween,
|
|
9
|
+
type ThemeMode,
|
|
10
|
+
} from 'vizmatic'
|
|
3
11
|
|
|
4
|
-
export
|
|
12
|
+
export const width = 1040
|
|
13
|
+
export const height = 500
|
|
14
|
+
|
|
15
|
+
type State = { progress: number }
|
|
16
|
+
type Colors = ReturnType<typeof getThemeColors>
|
|
17
|
+
|
|
18
|
+
const clamp = (value: number) => Math.max(0, Math.min(1, value))
|
|
19
|
+
const rankY = (rank: number) => 100 + rank * 54
|
|
20
|
+
|
|
21
|
+
function Token({ x, y, label, color, textColor }: { x: number; y: number; label: string; color: string; textColor: string }) {
|
|
22
|
+
return (
|
|
23
|
+
<div style={{
|
|
24
|
+
display: 'flex',
|
|
25
|
+
position: 'absolute',
|
|
26
|
+
left: x - 20,
|
|
27
|
+
top: y - 15,
|
|
28
|
+
width: 40,
|
|
29
|
+
height: 30,
|
|
30
|
+
alignItems: 'center',
|
|
31
|
+
justifyContent: 'center',
|
|
32
|
+
borderRadius: 8,
|
|
33
|
+
backgroundColor: color,
|
|
34
|
+
color: textColor,
|
|
35
|
+
fontFamily: 'JetBrains Mono',
|
|
36
|
+
fontSize: 11,
|
|
37
|
+
fontWeight: 900,
|
|
38
|
+
}}>
|
|
39
|
+
{label}
|
|
40
|
+
</div>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function RankLanes({ c }: { c: Colors }) {
|
|
45
|
+
return (
|
|
46
|
+
<div style={{ display: 'flex', position: 'absolute', inset: 0 }}>
|
|
47
|
+
{[0, 1, 2, 3].map((rank) => (
|
|
48
|
+
<div key={rank} style={{ display: 'flex', position: 'absolute', inset: 0 }}>
|
|
49
|
+
<div style={{
|
|
50
|
+
display: 'flex',
|
|
51
|
+
position: 'absolute',
|
|
52
|
+
left: 22,
|
|
53
|
+
top: rankY(rank) - 16,
|
|
54
|
+
width: 122,
|
|
55
|
+
height: 32,
|
|
56
|
+
alignItems: 'center',
|
|
57
|
+
gap: 10,
|
|
58
|
+
paddingLeft: 12,
|
|
59
|
+
borderRadius: 9,
|
|
60
|
+
backgroundColor: c.bgCardAlt,
|
|
61
|
+
border: `1px solid ${c.borderSubtle}`,
|
|
62
|
+
color: c.textPrimary,
|
|
63
|
+
fontFamily: c.fontMono,
|
|
64
|
+
fontSize: 12,
|
|
65
|
+
fontWeight: 800,
|
|
66
|
+
}}>
|
|
67
|
+
<span style={{ width: 10, height: 10, borderRadius: 10, backgroundColor: c.neutralLight }} />
|
|
68
|
+
rank {rank}
|
|
69
|
+
</div>
|
|
70
|
+
<div style={{ display: 'flex', position: 'absolute', left: 170, top: rankY(rank) - 1, width: 780, height: 2, backgroundColor: c.borderSubtle }} />
|
|
71
|
+
</div>
|
|
72
|
+
))}
|
|
73
|
+
</div>
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function Frame({ theme, progress }: { theme: ThemeMode; progress: number }) {
|
|
78
|
+
const c = getThemeColors(theme)
|
|
79
|
+
const color = getToneColor('warm', c)
|
|
80
|
+
const semanticColor = getReadableToneColor('warm', c, c.bgCard)
|
|
81
|
+
const p = clamp(progress)
|
|
82
|
+
const sourceX = 210
|
|
83
|
+
const outputX = 722
|
|
84
|
+
const gap = 44
|
|
85
|
+
const destinationColors = [c.info, c.primaryLight, c.secondaryLight, c.warningLight]
|
|
86
|
+
const phase = p < 0.08 ? 'grouped by source rank' : p < 0.92 ? 'exchange rank-addressed chunks' : 'grouped by destination rank'
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<div style={{ display: 'flex', position: 'relative', width, height, backgroundColor: c.bg, fontFamily: c.fontSans }}>
|
|
90
|
+
<div style={{ display: 'flex', width, height, opacity: 0 }} />
|
|
91
|
+
<div style={{ display: 'flex', position: 'absolute', top: 18, width: '100%', justifyContent: 'center', color: c.textPrimary, fontSize: 36, fontWeight: 800 }}>NCCL · AllToAll</div>
|
|
92
|
+
<div style={{ display: 'flex', position: 'absolute', top: 62, width: '100%', justifyContent: 'center', color: c.textSecondary, fontFamily: c.fontMono, fontSize: 14 }}>Every GPU sends one addressed chunk to every destination GPU</div>
|
|
93
|
+
|
|
94
|
+
<div style={{ display: 'flex', position: 'absolute', left: 26, top: 100, width: 988, height: 374, overflow: 'hidden', borderRadius: 14, backgroundColor: c.bgCard, border: `1px solid ${c.borderSubtle}` }}>
|
|
95
|
+
<div style={{ display: 'flex', position: 'absolute', left: 22, top: 18, alignItems: 'center', gap: 10 }}>
|
|
96
|
+
<span style={{ width: 6, height: 28, borderRadius: 6, backgroundColor: color }} />
|
|
97
|
+
<span style={{ color: c.textPrimary, fontSize: 20, fontWeight: 800 }}>AllToAll</span>
|
|
98
|
+
<span style={{ color: c.textMuted, fontFamily: c.fontMono, fontSize: 11 }}>label = source→destination; color = destination</span>
|
|
99
|
+
</div>
|
|
100
|
+
<div style={{ display: 'flex', position: 'absolute', right: 22, top: 24, color: semanticColor, fontFamily: c.fontMono, fontSize: 12, fontWeight: 900 }}>ALL ↔ ALL</div>
|
|
101
|
+
|
|
102
|
+
<RankLanes c={c} />
|
|
103
|
+
<div style={{ display: 'flex', position: 'absolute', left: 488, top: 128, width: 116, height: 106, alignItems: 'center', justifyContent: 'center', borderRadius: 12, backgroundColor: c.bgCardAlt, border: `2px dashed ${color}`, color: c.textMuted, fontFamily: c.fontMono, fontSize: 11, fontWeight: 900 }}>EXCHANGE</div>
|
|
104
|
+
{[0, 1, 2, 3].flatMap((source) => [0, 1, 2, 3].map((destination) => {
|
|
105
|
+
const tokenColor = destinationColors[destination]
|
|
106
|
+
const startX = sourceX + destination * gap
|
|
107
|
+
const endX = outputX + source * gap
|
|
108
|
+
return (
|
|
109
|
+
<Token
|
|
110
|
+
key={`${source}-${destination}`}
|
|
111
|
+
x={startX + (endX - startX) * p}
|
|
112
|
+
y={rankY(source) + (rankY(destination) - rankY(source)) * p}
|
|
113
|
+
label={`${source}→${destination}`}
|
|
114
|
+
color={tokenColor}
|
|
115
|
+
textColor={getReadableTextColor(tokenColor, c)}
|
|
116
|
+
/>
|
|
117
|
+
)
|
|
118
|
+
}))}
|
|
119
|
+
|
|
120
|
+
<div style={{ display: 'flex', position: 'absolute', left: 22, top: 326, color: c.textMuted, fontFamily: c.fontMono, fontSize: 11 }}>{phase}</div>
|
|
121
|
+
<div style={{ display: 'flex', position: 'absolute', left: 170, top: 332, width: 780, height: 6, borderRadius: 6, backgroundColor: c.borderSubtle }}>
|
|
122
|
+
<div style={{ display: 'flex', width: `${Math.round(p * 100)}%`, height: 6, borderRadius: 6, backgroundColor: color }} />
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
</div>
|
|
126
|
+
)
|
|
127
|
+
}
|
|
5
128
|
|
|
6
129
|
export function createAnimation(theme: ThemeMode) {
|
|
7
|
-
return
|
|
130
|
+
return defineAnimation<State>({
|
|
131
|
+
initial: { progress: 0 },
|
|
132
|
+
timeline: [
|
|
133
|
+
hold(800, 'source-grouped chunks'),
|
|
134
|
+
tween<Partial<State>>({ progress: 1 }, { duration: 3000, easing: 'ease-in-out', label: 'all-to-all exchange' }),
|
|
135
|
+
hold(1000, 'destination-grouped chunks'),
|
|
136
|
+
],
|
|
137
|
+
fps: 20,
|
|
138
|
+
render: (state) => <Frame theme={theme} progress={state.progress} />,
|
|
139
|
+
})
|
|
8
140
|
}
|
|
9
141
|
|
|
10
142
|
export function create(theme: ThemeMode = 'dark') {
|
|
11
|
-
return
|
|
143
|
+
return <Frame theme={theme} progress={1} />
|
|
12
144
|
}
|
|
13
145
|
|
|
14
146
|
export default create('dark')
|
|
@@ -1,14 +1,140 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
defineAnimation,
|
|
3
|
+
getReadableToneColor,
|
|
4
|
+
getReadableTextColor,
|
|
5
|
+
getThemeColors,
|
|
6
|
+
getToneColor,
|
|
7
|
+
hold,
|
|
8
|
+
tween,
|
|
9
|
+
type ThemeMode,
|
|
10
|
+
} from 'vizmatic'
|
|
3
11
|
|
|
4
|
-
export
|
|
12
|
+
export const width = 1040
|
|
13
|
+
export const height = 500
|
|
14
|
+
|
|
15
|
+
type State = { progress: number }
|
|
16
|
+
type Colors = ReturnType<typeof getThemeColors>
|
|
17
|
+
|
|
18
|
+
const clamp = (value: number) => Math.max(0, Math.min(1, value))
|
|
19
|
+
const rankY = (rank: number) => 100 + rank * 54
|
|
20
|
+
|
|
21
|
+
function Token({ x, y, color, textColor }: { x: number; y: number; color: string; textColor: string }) {
|
|
22
|
+
return (
|
|
23
|
+
<div style={{
|
|
24
|
+
display: 'flex',
|
|
25
|
+
position: 'absolute',
|
|
26
|
+
left: x - 17,
|
|
27
|
+
top: y - 17,
|
|
28
|
+
width: 34,
|
|
29
|
+
height: 34,
|
|
30
|
+
alignItems: 'center',
|
|
31
|
+
justifyContent: 'center',
|
|
32
|
+
borderRadius: 34,
|
|
33
|
+
backgroundColor: color,
|
|
34
|
+
color: textColor,
|
|
35
|
+
fontFamily: 'JetBrains Mono',
|
|
36
|
+
fontSize: 12,
|
|
37
|
+
fontWeight: 900,
|
|
38
|
+
}}>
|
|
39
|
+
X
|
|
40
|
+
</div>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function RankLanes({ c }: { c: Colors }) {
|
|
45
|
+
return (
|
|
46
|
+
<div style={{ display: 'flex', position: 'absolute', inset: 0 }}>
|
|
47
|
+
{[0, 1, 2, 3].map((rank) => (
|
|
48
|
+
<div key={rank} style={{ display: 'flex', position: 'absolute', inset: 0 }}>
|
|
49
|
+
<div style={{
|
|
50
|
+
display: 'flex',
|
|
51
|
+
position: 'absolute',
|
|
52
|
+
left: 22,
|
|
53
|
+
top: rankY(rank) - 16,
|
|
54
|
+
width: 122,
|
|
55
|
+
height: 32,
|
|
56
|
+
alignItems: 'center',
|
|
57
|
+
gap: 10,
|
|
58
|
+
paddingLeft: 12,
|
|
59
|
+
borderRadius: 9,
|
|
60
|
+
backgroundColor: c.bgCardAlt,
|
|
61
|
+
border: `1px solid ${c.borderSubtle}`,
|
|
62
|
+
color: c.textPrimary,
|
|
63
|
+
fontFamily: c.fontMono,
|
|
64
|
+
fontSize: 12,
|
|
65
|
+
fontWeight: 800,
|
|
66
|
+
}}>
|
|
67
|
+
<span style={{ width: 10, height: 10, borderRadius: 10, backgroundColor: rank === 0 ? c.info : c.neutralLight }} />
|
|
68
|
+
rank {rank}
|
|
69
|
+
</div>
|
|
70
|
+
<div style={{ display: 'flex', position: 'absolute', left: 170, top: rankY(rank) - 1, width: 780, height: 2, backgroundColor: c.borderSubtle }} />
|
|
71
|
+
</div>
|
|
72
|
+
))}
|
|
73
|
+
</div>
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function Frame({ theme, progress }: { theme: ThemeMode; progress: number }) {
|
|
78
|
+
const c = getThemeColors(theme)
|
|
79
|
+
const color = getToneColor('cyan', c)
|
|
80
|
+
const semanticColor = getReadableToneColor('cyan', c, c.bgCard)
|
|
81
|
+
const textColor = getReadableTextColor(color, c)
|
|
82
|
+
const p = clamp(progress)
|
|
83
|
+
const sourceX = 226
|
|
84
|
+
const targetX = 850
|
|
85
|
+
const phase = p < 0.08 ? 'root buffer' : p < 0.92 ? 'fan-out copies' : 'replicated on every rank'
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<div style={{ display: 'flex', position: 'relative', width, height, backgroundColor: c.bg, fontFamily: c.fontSans }}>
|
|
89
|
+
<div style={{ display: 'flex', width, height, opacity: 0 }} />
|
|
90
|
+
<div style={{ display: 'flex', position: 'absolute', top: 18, width: '100%', justifyContent: 'center', color: c.textPrimary, fontSize: 36, fontWeight: 800 }}>NCCL · Broadcast</div>
|
|
91
|
+
<div style={{ display: 'flex', position: 'absolute', top: 62, width: '100%', justifyContent: 'center', color: c.textSecondary, fontFamily: c.fontMono, fontSize: 14 }}>One root-owned buffer becomes available on every GPU</div>
|
|
92
|
+
|
|
93
|
+
<div style={{ display: 'flex', position: 'absolute', left: 26, top: 100, width: 988, height: 374, overflow: 'hidden', borderRadius: 14, backgroundColor: c.bgCard, border: `1px solid ${c.borderSubtle}` }}>
|
|
94
|
+
<div style={{ display: 'flex', position: 'absolute', left: 22, top: 18, alignItems: 'center', gap: 10 }}>
|
|
95
|
+
<span style={{ width: 6, height: 28, borderRadius: 6, backgroundColor: color }} />
|
|
96
|
+
<span style={{ color: c.textPrimary, fontSize: 20, fontWeight: 800 }}>Broadcast</span>
|
|
97
|
+
<span style={{ color: c.textMuted, fontFamily: c.fontMono, fontSize: 11 }}>root sends; peers do not contribute</span>
|
|
98
|
+
</div>
|
|
99
|
+
<div style={{ display: 'flex', position: 'absolute', right: 22, top: 24, color: semanticColor, fontFamily: c.fontMono, fontSize: 12, fontWeight: 900 }}>ONE → ALL</div>
|
|
100
|
+
|
|
101
|
+
<RankLanes c={c} />
|
|
102
|
+
{[1, 2, 3].map((rank) => (
|
|
103
|
+
<Token
|
|
104
|
+
key={rank}
|
|
105
|
+
x={sourceX + (targetX - sourceX) * p}
|
|
106
|
+
y={rankY(0) + (rankY(rank) - rankY(0)) * p}
|
|
107
|
+
color={color}
|
|
108
|
+
textColor={textColor}
|
|
109
|
+
/>
|
|
110
|
+
))}
|
|
111
|
+
<Token x={sourceX} y={rankY(0)} color={color} textColor={textColor} />
|
|
112
|
+
<div style={{ display: 'flex', position: 'absolute', left: sourceX - 20, top: rankY(0) - 40, color: c.textPrimary, fontFamily: c.fontMono, fontSize: 11, fontWeight: 900 }}>ROOT</div>
|
|
113
|
+
|
|
114
|
+
<div style={{ display: 'flex', position: 'absolute', left: 22, top: 326, color: c.textMuted, fontFamily: c.fontMono, fontSize: 11 }}>{phase}</div>
|
|
115
|
+
<div style={{ display: 'flex', position: 'absolute', left: 170, top: 332, width: 780, height: 6, borderRadius: 6, backgroundColor: c.borderSubtle }}>
|
|
116
|
+
<div style={{ display: 'flex', width: `${Math.round(p * 100)}%`, height: 6, borderRadius: 6, backgroundColor: color }} />
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
)
|
|
121
|
+
}
|
|
5
122
|
|
|
6
123
|
export function createAnimation(theme: ThemeMode) {
|
|
7
|
-
return
|
|
124
|
+
return defineAnimation<State>({
|
|
125
|
+
initial: { progress: 0 },
|
|
126
|
+
timeline: [
|
|
127
|
+
hold(800, 'root buffer'),
|
|
128
|
+
tween<Partial<State>>({ progress: 1 }, { duration: 2600, easing: 'ease-in-out', label: 'fan out copies' }),
|
|
129
|
+
hold(1000, 'replicated result'),
|
|
130
|
+
],
|
|
131
|
+
fps: 20,
|
|
132
|
+
render: (state) => <Frame theme={theme} progress={state.progress} />,
|
|
133
|
+
})
|
|
8
134
|
}
|
|
9
135
|
|
|
10
136
|
export function create(theme: ThemeMode = 'dark') {
|
|
11
|
-
return
|
|
137
|
+
return <Frame theme={theme} progress={1} />
|
|
12
138
|
}
|
|
13
139
|
|
|
14
140
|
export default create('dark')
|