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.
@@ -1,14 +1,170 @@
1
- import type { ThemeMode } from 'vizmatic'
2
- import { createNcclAnimation, createNcclFrame } from './_shared/nccl-collective'
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 { height, width } from './_shared/nccl-collective'
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, size = 34 }: { x: number; y: number; label: string; color: string; textColor: string; opacity?: number; size?: number }) {
22
+ return (
23
+ <div style={{
24
+ display: 'flex',
25
+ position: 'absolute',
26
+ left: x - size / 2,
27
+ top: y - size / 2,
28
+ width: size,
29
+ height: size,
30
+ alignItems: 'center',
31
+ justifyContent: 'center',
32
+ borderRadius: size > 32 ? 10 : 7,
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('green', c)
81
+ const semanticColor = getReadableToneColor('green', c, c.bgCard)
82
+ const p = clamp(progress)
83
+ const reduce = clamp(p / 0.5)
84
+ const scatter = clamp((p - 0.5) / 0.5)
85
+ const inputOpacity = 1 - clamp((p - 0.46) / 0.12)
86
+ const resultOpacity = clamp((p - 0.42) / 0.12)
87
+ const centerX = 548
88
+ const centerY = 181
89
+ const outputX = 850
90
+ const chunkColors = [c.info, c.primaryLight, c.secondaryLight, c.positiveLight]
91
+ const phase = p < 0.46 ? 'reduce matching chunk indices' : p < 0.92 ? 'scatter one completed chunk per rank' : 'partitioned reduced result'
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 · ReduceScatter</div>
97
+ <div style={{ display: 'flex', position: 'absolute', top: 62, width: '100%', justifyContent: 'center', color: c.textSecondary, fontFamily: c.fontMono, fontSize: 14 }}>Reduce corresponding chunks, then assign one completed shard to each 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 }}>ReduceScatter</span>
103
+ <span style={{ color: c.textMuted, fontFamily: c.fontMono, fontSize: 11 }}>color identifies final owner</span>
104
+ </div>
105
+ <div style={{ display: 'flex', position: 'absolute', right: 22, top: 24, color: semanticColor, fontFamily: c.fontMono, fontSize: 12, fontWeight: 900 }}>ALL → ONE SHARD / RANK</div>
106
+
107
+ <RankLanes c={c} />
108
+ <div style={{ display: 'flex', position: 'absolute', left: centerX - 60, top: centerY - 49, width: 120, height: 98, alignItems: 'center', justifyContent: 'center', borderRadius: 12, backgroundColor: c.bgCardAlt, border: `2px dashed ${color}`, opacity: 0.82 }} />
109
+ <div style={{ display: 'flex', position: 'absolute', left: centerX - 48, top: centerY - 66, color: c.textMuted, fontFamily: c.fontMono, fontSize: 11, fontWeight: 900 }}>REDUCE BY INDEX</div>
110
+
111
+ {inputOpacity > 0.01 && [0, 1, 2, 3].flatMap((source) => [0, 1, 2, 3].map((destination) => {
112
+ const startX = 208 + destination * 36
113
+ const slotX = centerX - 36 + destination * 24
114
+ const chunkColor = chunkColors[destination]
115
+ return (
116
+ <Token
117
+ key={`input-${source}-${destination}`}
118
+ x={startX + (slotX - startX) * reduce}
119
+ y={rankY(source) + (centerY - rankY(source)) * reduce}
120
+ label={`${source}:${destination}`}
121
+ color={chunkColor}
122
+ textColor={getReadableTextColor(chunkColor, c)}
123
+ opacity={inputOpacity}
124
+ />
125
+ )
126
+ }))}
127
+ {[0, 1, 2, 3].map((destination) => {
128
+ const slotX = centerX - 36 + destination * 24
129
+ const chunkColor = chunkColors[destination]
130
+ return (
131
+ <Token
132
+ key={`output-${destination}`}
133
+ x={slotX + (outputX - slotX) * scatter}
134
+ y={centerY + (rankY(destination) - centerY) * scatter}
135
+ label={`R${destination}`}
136
+ color={chunkColor}
137
+ textColor={getReadableTextColor(chunkColor, c)}
138
+ opacity={resultOpacity}
139
+ size={38}
140
+ />
141
+ )
142
+ })}
143
+
144
+ <div style={{ display: 'flex', position: 'absolute', left: 22, top: 326, color: c.textMuted, fontFamily: c.fontMono, fontSize: 11 }}>{phase}</div>
145
+ <div style={{ display: 'flex', position: 'absolute', left: 170, top: 332, width: 780, height: 6, borderRadius: 6, backgroundColor: c.borderSubtle }}>
146
+ <div style={{ display: 'flex', width: `${Math.round(p * 100)}%`, height: 6, borderRadius: 6, backgroundColor: color }} />
147
+ </div>
148
+ </div>
149
+ </div>
150
+ )
151
+ }
5
152
 
6
153
  export function createAnimation(theme: ThemeMode) {
7
- return createNcclAnimation(theme, 'reduce-scatter')
154
+ return defineAnimation<State>({
155
+ initial: { progress: 0 },
156
+ timeline: [
157
+ hold(800, 'rank-local chunks'),
158
+ tween<Partial<State>>({ progress: 1 }, { duration: 3000, easing: 'ease-in-out', label: 'reduce and scatter' }),
159
+ hold(1000, 'one shard per rank'),
160
+ ],
161
+ fps: 20,
162
+ render: (state) => <Frame theme={theme} progress={state.progress} />,
163
+ })
8
164
  }
9
165
 
10
166
  export function create(theme: ThemeMode = 'dark') {
11
- return createNcclFrame(theme, 'reduce-scatter')
167
+ return <Frame theme={theme} progress={1} />
12
168
  }
13
169
 
14
170
  export default create('dark')
@@ -0,0 +1,61 @@
1
+ import {
2
+ ParetoChart,
3
+ Scene,
4
+ getThemeColors,
5
+ type ThemeMode,
6
+ } from 'vizmatic'
7
+
8
+ export const width = 1040
9
+ export const height = 570
10
+
11
+ // Brumark v10 max-effort snapshots, post-regrade July 23, 2026.
12
+ // Cost per task is each run's recorded/estimated total cost divided by 306 tasks.
13
+ const results = [
14
+ { x: 0.008280, y: 56.9015, label: 'Luna · max', color: 'info', size: 7 },
15
+ { x: 0.086881, y: 71.3691, label: 'Terra · max', color: 'positive', size: 7 },
16
+ { x: 0.216884, y: 88.3919, label: 'Sol · max', color: 'primary', size: 8 },
17
+ { x: 0.314285, y: 79.7092, label: 'Opus 5 · max', color: 'warning', size: 7 },
18
+ ]
19
+
20
+ const formatCost = (value: number) => value < 0.01
21
+ ? `$${value.toFixed(3)}`
22
+ : `$${value.toFixed(2)}`
23
+
24
+ export function create(theme: ThemeMode = 'dark') {
25
+ const c = getThemeColors(theme)
26
+
27
+ return (
28
+ <Scene
29
+ c={c}
30
+ title="Cost × score Pareto frontier"
31
+ subtitle="Use dominance, not one-dimensional ranking, to compare model tradeoffs"
32
+ background={c.bg}
33
+ padding={20}
34
+ gap={14}
35
+ align="center"
36
+ >
37
+ <ParetoChart
38
+ c={c}
39
+ width={960}
40
+ height={300}
41
+ title="Brumark v10 · max reasoning effort"
42
+ subtitle="A run is efficient when no cheaper run scores at least as high"
43
+ points={results}
44
+ xScale="log"
45
+ xMin={0.006}
46
+ xMax={0.4}
47
+ yMin={50}
48
+ yMax={92}
49
+ xAxisLabel="recorded cost per task · log scale"
50
+ yAxisLabel="score"
51
+ formatX={formatCost}
52
+ formatY={(value) => `${Math.round(value)}%`}
53
+ frontierColor="positive"
54
+ goalLabel="more efficient ↖"
55
+ footer="306 tasks · post-regrade snapshot · estimated costs"
56
+ />
57
+ </Scene>
58
+ )
59
+ }
60
+
61
+ export default create('dark')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vizmatic",
3
- "version": "0.1.37",
3
+ "version": "0.1.39",
4
4
  "description": "Theme-aware visual primitives and a headless renderer for diagrams, figures, and presentation frames.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,420 +0,0 @@
1
- import {
2
- defineAnimation,
3
- getThemeColors,
4
- getReadableToneColor,
5
- getReadableTextColor,
6
- getToneColor,
7
- hold,
8
- tween,
9
- type ThemeMode,
10
- type ToneName,
11
- } from 'vizmatic'
12
-
13
- export const width = 1040
14
- export const height = 600
15
-
16
- type State = {
17
- progress: number
18
- }
19
-
20
- export type NcclCollective = 'broadcast' | 'all-reduce' | 'all-gather' | 'reduce-scatter' | 'all-to-all'
21
-
22
- type Operation = {
23
- name: string
24
- description: string
25
- semantic: string
26
- tone: ToneName
27
- }
28
-
29
- // Collective directions follow NVIDIA NCCL's operation definitions:
30
- // https://docs.nvidia.com/deeplearning/nccl/user-guide/docs/usage/collectives.html
31
- const operations: Record<NcclCollective, Operation> = {
32
- broadcast: {
33
- name: 'Broadcast',
34
- description: 'Copy root rank buffer to every rank.',
35
- semantic: 'one → all',
36
- tone: 'cyan',
37
- },
38
- 'all-reduce': {
39
- name: 'AllReduce',
40
- description: 'Reduce values, then return result to every rank.',
41
- semantic: 'all → all',
42
- tone: 'purple',
43
- },
44
- 'all-gather': {
45
- name: 'AllGather',
46
- description: 'Gather every rank tensor on every rank.',
47
- semantic: 'all → all · concat',
48
- tone: 'blue',
49
- },
50
- 'reduce-scatter': {
51
- name: 'ReduceScatter',
52
- description: 'Reduce by chunk, then scatter one result per rank.',
53
- semantic: 'all → one chunk',
54
- tone: 'green',
55
- },
56
- 'all-to-all': {
57
- name: 'AlltoAll',
58
- description: 'Exchange rank-addressed chunks among every rank.',
59
- semantic: 'all ↔ all',
60
- tone: 'warm',
61
- },
62
- }
63
-
64
- const rankY = (rank: number) => 68 + rank * 43
65
- const clamp = (value: number) => Math.max(0, Math.min(1, value))
66
- const absoluteFill = {
67
- display: 'flex',
68
- position: 'absolute' as const,
69
- left: 0,
70
- top: 0,
71
- width: '100%',
72
- height: '100%',
73
- }
74
-
75
- function phaseLabel(operation: NcclCollective, progress: number): string {
76
- const p = clamp(progress)
77
- if (operation === 'broadcast') return p < 0.12 ? 'root buffer' : p < 0.86 ? 'fan-out' : 'replicated'
78
- if (operation === 'all-reduce') return p < 0.48 ? 'reduce' : p < 0.88 ? 'broadcast sum' : 'complete'
79
- if (operation === 'all-gather') return p < 0.48 ? 'gather' : p < 0.88 ? 'replicate list' : 'complete'
80
- if (operation === 'reduce-scatter') return p < 0.48 ? 'reduce by index' : p < 0.88 ? 'scatter outputs' : 'complete'
81
- return p < 0.12 ? 'rank-addressed chunks' : p < 0.88 ? 'exchange' : 'rank-ordered output'
82
- }
83
-
84
- interface DataTokenProps {
85
- x: number
86
- y: number
87
- label: string
88
- color: string
89
- textColor: string
90
- opacity?: number
91
- width?: number
92
- }
93
-
94
- function DataToken({
95
- x,
96
- y,
97
- label,
98
- color,
99
- textColor,
100
- opacity = 1,
101
- width: tokenWidth = 34,
102
- }: DataTokenProps) {
103
- const tokenHeight = 24
104
- return (
105
- <div style={{
106
- display: 'flex',
107
- position: 'absolute',
108
- left: x - tokenWidth / 2,
109
- top: y - tokenHeight / 2,
110
- width: tokenWidth,
111
- height: tokenHeight,
112
- alignItems: 'center',
113
- justifyContent: 'center',
114
- borderRadius: 7,
115
- backgroundColor: color,
116
- color: textColor,
117
- fontSize: 11,
118
- fontWeight: 800,
119
- fontFamily: 'JetBrains Mono',
120
- opacity,
121
- }}>
122
- {label}
123
- </div>
124
- )
125
- }
126
-
127
- function RankLanes({ c }: { c: ReturnType<typeof getThemeColors> }) {
128
- return (
129
- <div style={absoluteFill}>
130
- <div style={{ display: 'flex', position: 'absolute', left: 24, top: 14, color: c.textMuted, fontSize: 11, fontWeight: 800, fontFamily: c.fontMono, letterSpacing: 1.2 }}>RANKS</div>
131
- <div style={{ display: 'flex', position: 'absolute', left: 222, top: 14, color: c.textMuted, fontSize: 11, fontWeight: 800, fontFamily: c.fontMono, letterSpacing: 1.2 }}>COLLECTIVE PATH</div>
132
- {[0, 1, 2, 3].map((rank) => {
133
- const y = rankY(rank)
134
- return (
135
- <div key={`rank-${rank}`} style={absoluteFill}>
136
- <div style={{ display: 'flex', position: 'absolute', left: 22, top: y - 15, width: 128, height: 30, alignItems: 'center', gap: 9, paddingLeft: 12, borderRadius: 9, backgroundColor: c.bgCardAlt, border: `1px solid ${c.borderSubtle}` }}>
137
- <span style={{ width: 10, height: 10, borderRadius: 10, backgroundColor: rank === 0 ? c.info : c.neutralLight }} />
138
- <span style={{ color: c.textPrimary, fontSize: 12, fontWeight: 700, fontFamily: c.fontMono }}>rank {rank}</span>
139
- </div>
140
- <div style={{ display: 'flex', position: 'absolute', left: 178, top: y - 1, width: 757, height: 2, backgroundColor: c.borderSubtle }} />
141
- <span style={{ position: 'absolute', left: 175, top: y - 3, width: 6, height: 6, borderRadius: 6, backgroundColor: c.borderLight }} />
142
- <span style={{ position: 'absolute', left: 932, top: y - 3, width: 6, height: 6, borderRadius: 6, backgroundColor: c.borderLight }} />
143
- </div>
144
- )
145
- })}
146
- </div>
147
- )
148
- }
149
-
150
- function BroadcastView({ c, progress, color }: { c: ReturnType<typeof getThemeColors>; progress: number; color: string }) {
151
- const p = clamp(progress)
152
- const sourceX = 248
153
- const targetX = 858
154
- const tokenText = getReadableTextColor(color, c)
155
- return (
156
- <div style={absoluteFill}>
157
- {[1, 2, 3].map((rank) => {
158
- const y = rankY(rank)
159
- return (
160
- <div key={`broadcast-path-${rank}`} style={absoluteFill}>
161
- {DataToken({ x: targetX, y, label: 'X', color, textColor: tokenText, opacity: 0.15 + p * 0.2 })}
162
- {DataToken({
163
- x: sourceX + (targetX - sourceX) * p,
164
- y: rankY(0) + (y - rankY(0)) * p,
165
- label: 'X',
166
- color,
167
- textColor: tokenText,
168
- opacity: 0.98,
169
- })}
170
- </div>
171
- )
172
- })}
173
- {DataToken({ x: sourceX, y: rankY(0), label: 'X', color, textColor: tokenText })}
174
- <div style={{ display: 'flex', position: 'absolute', left: sourceX - 18, top: rankY(0) - 34, color: c.textPrimary, fontSize: 11, fontWeight: 800, fontFamily: c.fontMono }}>ROOT</div>
175
- <div style={{ display: 'flex', position: 'absolute', left: targetX + 26, top: rankY(3) - 8, color: c.textMuted, fontSize: 11, fontFamily: c.fontMono }}>same buffer</div>
176
- </div>
177
- )
178
- }
179
-
180
- function AllReduceView({ c, progress, color }: { c: ReturnType<typeof getThemeColors>; progress: number; color: string }) {
181
- const p = clamp(progress)
182
- const centerX = 550
183
- const centerY = 143
184
- const outputX = 858
185
- const reduceP = Math.min(1, p * 2)
186
- const scatterP = clamp((p - 0.42) / 0.58)
187
- const tokenText = getReadableTextColor(color, c)
188
- return (
189
- <div style={absoluteFill}>
190
- <div style={{ display: 'flex', position: 'absolute', left: centerX - 26, top: centerY - 26, width: 52, height: 52, alignItems: 'center', justifyContent: 'center', borderRadius: 52, backgroundColor: c.bgCardAlt, border: `2px solid ${color}`, color, fontSize: 20, fontWeight: 800, fontFamily: c.fontMono }}>Σ</div>
191
- {[0, 1, 2, 3].map((rank) => {
192
- const y = rankY(rank)
193
- const sourceX = 248 + (centerX - 248) * reduceP
194
- return (
195
- <div key={`allreduce-${rank}`} style={absoluteFill}>
196
- {p < 0.75 && DataToken({ x: sourceX, y: y + (centerY - y) * reduceP, label: String(rank + 1), color, textColor: tokenText, opacity: 1 - Math.min(1, p * 1.35) })}
197
- {DataToken({ x: centerX + (outputX - centerX) * scatterP, y: centerY + (y - centerY) * scatterP, label: '10', color, textColor: tokenText, opacity: scatterP })}
198
- </div>
199
- )
200
- })}
201
- <div style={{ display: 'flex', position: 'absolute', left: centerX - 42, top: centerY + 31, color: c.textMuted, fontSize: 11, fontFamily: c.fontMono }}>1 + 2 + 3 + 4</div>
202
- </div>
203
- )
204
- }
205
-
206
- function AllGatherView({ c, progress, color }: { c: ReturnType<typeof getThemeColors>; progress: number; color: string }) {
207
- const p = clamp(progress)
208
- const gatherP = Math.min(1, p * 2)
209
- const replicateP = clamp((p - 0.43) / 0.57)
210
- const centerX = 548
211
- const centerY = 143
212
- const sourceX = 248
213
- const outputX = 736
214
- const labels = ['A', 'B', 'C', 'D']
215
- const tokenText = getReadableTextColor(color, c)
216
-
217
- return (
218
- <div style={absoluteFill}>
219
- <div style={{ display: 'flex', position: 'absolute', left: centerX - 52, top: centerY - 45, width: 104, height: 90, alignItems: 'center', justifyContent: 'center', borderRadius: 12, backgroundColor: c.bgCardAlt, border: `2px dashed ${color}`, opacity: 0.8 }} />
220
- <div style={{ display: 'flex', position: 'absolute', left: centerX - 26, top: centerY - 64, color: c.textMuted, fontSize: 11, fontWeight: 800, fontFamily: c.fontMono }}>CONCAT</div>
221
- {[0, 1, 2, 3].map((rank) => {
222
- const y = rankY(rank)
223
- const centerSlotX = centerX - 30 + rank * 20
224
- return (
225
- <div key={`allgather-${rank}`} style={absoluteFill}>
226
- {DataToken({
227
- x: sourceX + (centerSlotX - sourceX) * gatherP,
228
- y: y + (centerY + (rank - 1.5) * 2 - y) * gatherP,
229
- label: labels[rank],
230
- color,
231
- textColor: tokenText,
232
- opacity: 1 - Math.min(1, p * 1.4),
233
- width: 28,
234
- })}
235
- </div>
236
- )
237
- })}
238
- {[0, 1, 2, 3].flatMap((target) => labels.map((label, source) => {
239
- const centerSlotX = centerX - 30 + source * 20
240
- return DataToken({
241
- x: centerSlotX + (outputX + source * 34 - centerSlotX) * replicateP,
242
- y: centerY + (rankY(target) - centerY) * replicateP,
243
- label,
244
- color,
245
- textColor: tokenText,
246
- opacity: replicateP,
247
- width: 28,
248
- })
249
- }))}
250
- <div style={{ display: 'flex', position: 'absolute', left: 884, top: rankY(3) - 14, width: 102, height: 28, alignItems: 'center', justifyContent: 'center', borderRadius: 6, backgroundColor: c.bgCard, color: c.textMuted, fontSize: 11, fontFamily: c.fontMono, opacity: 0.94 }}>A · B · C · D</div>
251
- </div>
252
- )
253
- }
254
-
255
- function ReduceScatterView({ c, progress, color }: { c: ReturnType<typeof getThemeColors>; progress: number; color: string }) {
256
- const p = clamp(progress)
257
- const reduceP = Math.min(1, p * 2)
258
- const scatterP = clamp((p - 0.42) / 0.58)
259
- const centerX = 548
260
- const centerY = 143
261
- const outputX = 858
262
- const chunkColors = [c.info, c.primaryLight, c.secondaryLight, c.positiveLight]
263
- return (
264
- <div style={absoluteFill}>
265
- <div style={{ display: 'flex', position: 'absolute', left: centerX - 56, top: centerY - 47, width: 112, height: 94, borderRadius: 12, backgroundColor: c.bgCardAlt, border: `2px dashed ${color}`, opacity: 0.7 }} />
266
- <div style={{ display: 'flex', position: 'absolute', left: centerX - 48, top: centerY - 65, color: c.textMuted, fontSize: 11, fontWeight: 800, fontFamily: c.fontMono }}>REDUCE CHUNKS</div>
267
- {[0, 1, 2, 3].map((destination) => {
268
- const y = rankY(destination)
269
- const centerSlotX = centerX - 30 + destination * 20
270
- return (
271
- <div key={`reducescatter-destination-${destination}`} style={absoluteFill}>
272
- <div style={{ display: 'flex', position: 'absolute', left: centerSlotX - 13, top: centerY - 13, width: 26, height: 26, alignItems: 'center', justifyContent: 'center', borderRadius: 26, backgroundColor: c.bgCardAlt, border: `2px solid ${chunkColors[destination]}`, color: c.textPrimary, fontSize: 11, fontWeight: 800, fontFamily: c.fontMono }}>R{destination}</div>
273
- {DataToken({
274
- x: centerSlotX + (outputX - centerSlotX) * scatterP,
275
- y: centerY + (y - centerY) * scatterP,
276
- label: `R${destination}`,
277
- color: chunkColors[destination],
278
- textColor: getReadableTextColor(chunkColors[destination], c),
279
- opacity: scatterP,
280
- width: 38,
281
- })}
282
- </div>
283
- )
284
- })}
285
- {p < 0.75 && [0, 1, 2, 3].flatMap((source) => [0, 1, 2, 3].map((destination) => {
286
- const sourceX = 236 + destination * 26
287
- const sourceY = rankY(source)
288
- const centerSlotX = centerX - 30 + destination * 20
289
- return (
290
- <div key={`reducescatter-${source}-${destination}`} style={absoluteFill}>
291
- {DataToken({
292
- x: sourceX + (centerSlotX - sourceX) * reduceP,
293
- y: sourceY + (centerY - sourceY) * reduceP,
294
- label: `${source},${destination}`,
295
- color: chunkColors[destination],
296
- textColor: getReadableTextColor(chunkColors[destination], c),
297
- opacity: 1 - Math.min(1, p * 1.4),
298
- width: 24,
299
- })}
300
- </div>
301
- )
302
- }))}
303
- <div style={{ display: 'flex', position: 'absolute', left: 884, top: rankY(3) - 14, width: 102, height: 28, alignItems: 'center', justifyContent: 'center', borderRadius: 6, backgroundColor: c.bgCard, color: c.textMuted, fontSize: 11, fontFamily: c.fontMono, opacity: 0.94 }}>one chunk / rank</div>
304
- </div>
305
- )
306
- }
307
-
308
- function AllToAllView({ c, progress, color }: { c: ReturnType<typeof getThemeColors>; progress: number; color: string }) {
309
- const p = clamp(progress)
310
- const destinationColors = [c.info, c.primaryLight, c.secondaryLight, c.warningLight]
311
- const sourceStartX = 240
312
- const outputStartX = 730
313
- const tokenGap = 44
314
-
315
- return (
316
- <div style={absoluteFill}>
317
- <div style={{ display: 'flex', position: 'absolute', left: 492, top: 96, width: 112, height: 94, alignItems: 'center', justifyContent: 'center', borderRadius: 12, backgroundColor: c.bgCardAlt, border: `2px dashed ${color}`, color: c.textMuted, fontSize: 11, fontWeight: 800, fontFamily: c.fontMono }}>EXCHANGE</div>
318
- {[0, 1, 2, 3].flatMap((source) => [0, 1, 2, 3].map((destination) => {
319
- const tokenColor = destinationColors[destination]
320
- const startX = sourceStartX + destination * tokenGap
321
- const endX = outputStartX + source * tokenGap
322
- const startY = rankY(source)
323
- const endY = rankY(destination)
324
- return (
325
- <div key={`alltoall-${source}-${destination}`} style={absoluteFill}>
326
- {DataToken({
327
- x: startX + (endX - startX) * p,
328
- y: startY + (endY - startY) * p,
329
- label: `${source}→${destination}`,
330
- color: tokenColor,
331
- textColor: getReadableTextColor(tokenColor, c),
332
- width: 40,
333
- })}
334
- </div>
335
- )
336
- }))}
337
- <div style={{ display: 'flex', position: 'absolute', left: 224, top: 240, color: c.textMuted, fontSize: 11, fontFamily: c.fontMono }}>color = destination</div>
338
- <div style={{ display: 'flex', position: 'absolute', left: 882, top: 240, color: c.textMuted, fontSize: 11, fontFamily: c.fontMono }}>source order</div>
339
- </div>
340
- )
341
- }
342
-
343
- function renderFrame(theme: ThemeMode, collective: NcclCollective, state: Readonly<State>) {
344
- const c = getThemeColors(theme)
345
- const operation = operations[collective]
346
- const color = getToneColor(operation.tone, c)
347
- const semanticColor = getReadableToneColor(operation.tone, c, c.bgCardAlt)
348
- const p = clamp(state.progress)
349
-
350
- return (
351
- <div style={{
352
- display: 'flex',
353
- position: 'relative',
354
- flexGrow: 0,
355
- flexShrink: 0,
356
- width,
357
- minWidth: width,
358
- maxWidth: width,
359
- height,
360
- minHeight: height,
361
- maxHeight: height,
362
- backgroundColor: c.bg,
363
- fontFamily: c.fontSans,
364
- }}>
365
- <div style={{ display: 'flex', flexGrow: 0, flexShrink: 0, width, height, opacity: 0 }} />
366
- <div style={{ display: 'flex', position: 'absolute', left: 0, top: 20, width: '100%', justifyContent: 'center', color: c.textPrimary, fontFamily: c.fontSans, fontSize: 40, fontWeight: 700 }}>NCCL · {operation.name}</div>
367
- <div style={{ display: 'flex', position: 'absolute', left: 0, top: 72, width: '100%', justifyContent: 'center', color: c.textSecondary, fontFamily: c.fontMono, fontSize: 16 }}>Rank-local chunks, collective paths, and final ownership across four GPUs</div>
368
-
369
- <div style={{ display: 'flex', position: 'absolute', left: 26, top: 110, width: 988, height: 70, alignItems: 'stretch', justifyContent: 'space-between', gap: 14 }}>
370
- <div style={{ display: 'flex', flex: 1, alignItems: 'center', gap: 12, padding: '12px 16px', border: `1px solid ${c.borderSubtle}`, borderRadius: 12, backgroundColor: c.bgCard }}>
371
- <div style={{ display: 'flex', width: 6, height: 42, borderRadius: 6, backgroundColor: color }} />
372
- <div style={{ display: 'flex', flexDirection: 'column', gap: 3 }}>
373
- <div style={{ display: 'flex', color: c.textPrimary, fontFamily: c.fontSans, fontSize: 22, fontWeight: 800 }}>{operation.name}</div>
374
- <div style={{ display: 'flex', color: c.textSecondary, fontFamily: c.fontMono, fontSize: 11 }}>{operation.description}</div>
375
- </div>
376
- </div>
377
- <div style={{ display: 'flex', width: 236, flexDirection: 'column', justifyContent: 'center', gap: 7, padding: '11px 15px', border: `1px solid ${c.borderSubtle}`, borderRadius: 12, backgroundColor: c.bgCardAlt }}>
378
- <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
379
- <span style={{ color: c.textMuted, fontFamily: c.fontMono, fontSize: 11, fontWeight: 800 }}>COLLECTIVE</span>
380
- <span style={{ color: semanticColor, fontFamily: c.fontMono, fontSize: 11, fontWeight: 800 }}>{operation.semantic}</span>
381
- </div>
382
- <div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
383
- <div style={{ display: 'flex', flex: 1, height: 5, borderRadius: 8, backgroundColor: c.borderSubtle }}>
384
- <div style={{ display: 'flex', width: `${Math.round(p * 100)}%`, height: 5, borderRadius: 8, backgroundColor: color }} />
385
- </div>
386
- <span style={{ color: c.textSecondary, fontFamily: c.fontMono, fontSize: 11 }}>{phaseLabel(collective, p)}</span>
387
- </div>
388
- </div>
389
- </div>
390
-
391
- <div style={{ display: 'flex', position: 'absolute', left: 26, top: 194, width: 988, height: 286, overflow: 'hidden', borderRadius: 14, backgroundColor: c.bgCard, border: `1px solid ${c.borderSubtle}` }}>
392
- {RankLanes({ c })}
393
- {collective === 'broadcast' && BroadcastView({ c, progress: p, color })}
394
- {collective === 'all-reduce' && AllReduceView({ c, progress: p, color })}
395
- {collective === 'all-gather' && AllGatherView({ c, progress: p, color })}
396
- {collective === 'reduce-scatter' && ReduceScatterView({ c, progress: p, color })}
397
- {collective === 'all-to-all' && AllToAllView({ c, progress: p, color })}
398
- </div>
399
-
400
- </div>
401
- )
402
- }
403
-
404
- export function createNcclAnimation(theme: ThemeMode, collective: NcclCollective) {
405
- const operation = operations[collective]
406
- return defineAnimation<State>({
407
- initial: { progress: 0 },
408
- timeline: [
409
- hold(700, `${operation.name} · input`),
410
- tween<Partial<State>>({ progress: 1 }, { duration: 2200, easing: 'ease-in-out', label: `${operation.name} · transfer` }),
411
- hold(700, `${operation.name} · output`),
412
- ],
413
- fps: 15,
414
- render: (state) => renderFrame(theme, collective, state),
415
- })
416
- }
417
-
418
- export function createNcclFrame(theme: ThemeMode, collective: NcclCollective, progress = 1) {
419
- return renderFrame(theme, collective, { progress })
420
- }