vizmatic 0.3.2 → 0.5.0

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.
Files changed (150) hide show
  1. package/PROMPT.md +75 -525
  2. package/README.md +87 -578
  3. package/ROADMAP.md +49 -67
  4. package/SCIENCE.md +250 -0
  5. package/assets/THIRD_PARTY_LICENSES.md +40 -1
  6. package/assets/fonts/InstrumentSerif-Italic.ttf +0 -0
  7. package/assets/fonts/InstrumentSerif-Regular.ttf +0 -0
  8. package/assets/licenses/raster-codecs-MIT.txt +74 -0
  9. package/dist/chunk-3F2VQ7NW.js +1 -0
  10. package/dist/chunk-4XE64I2U.js +755 -0
  11. package/dist/chunk-JHHPLALU.js +79 -0
  12. package/dist/chunk-LTX44BAE.js +112 -0
  13. package/dist/chunk-MLKGABMK.js +9 -0
  14. package/dist/chunk-PSBF4TEK.js +1 -0
  15. package/dist/chunk-RPAHMKAR.js +605 -0
  16. package/dist/chunk-RWF4VBUL.js +3617 -0
  17. package/dist/chunk-WHT6HRMX.js +4201 -0
  18. package/dist/cli.js +371 -10
  19. package/dist/index.cjs +11129 -2922
  20. package/dist/index.d.cts +1225 -369
  21. package/dist/index.d.ts +1225 -369
  22. package/dist/index.js +6220 -3015
  23. package/dist/math-LXB4FH4E.js +7 -0
  24. package/dist/math-QVCETQDQ.js +1 -0
  25. package/dist/scene-browser-assets.d.ts +38 -0
  26. package/dist/scene-browser-assets.js +53 -0
  27. package/dist/scene-browser-chunks/chunk-5MVLYGXM.js +70 -0
  28. package/dist/scene-browser-chunks/chunk-ASXKN3NU.js +1 -0
  29. package/dist/scene-browser-chunks/chunk-CM5Y5LZP.js +1 -0
  30. package/dist/scene-browser-chunks/chunk-DP7NB4EW.js +6 -0
  31. package/dist/scene-browser-chunks/emscripten-module.browser-M5AEKJGE.js +1 -0
  32. package/dist/scene-browser-chunks/ffi-FL6ORJU3.js +1 -0
  33. package/dist/scene-browser-chunks/module-ES6BEMUI-JD5S5VKR.js +1 -0
  34. package/dist/scene-browser-chunks/module-asyncify-2EFITU5U-HWPFJFJC.js +1 -0
  35. package/dist/scene-browser-chunks/scene-browser-layout-M3XSXMV4.js +27 -0
  36. package/dist/scene-browser.d.ts +117 -0
  37. package/dist/scene-browser.js +220 -0
  38. package/dist/scene-cli.d.ts +1 -0
  39. package/dist/scene-cli.js +4 -0
  40. package/dist/scene-runtime.cjs +995 -0
  41. package/dist/scene-runtime.d.cts +81 -0
  42. package/dist/scene-runtime.d.ts +81 -0
  43. package/dist/scene-runtime.js +22 -0
  44. package/dist/server-2FYHZ4UO.js +331 -0
  45. package/dist/stage-browser/browser.d.ts +2482 -0
  46. package/dist/stage-browser/chunk-SQE76S5B.js +1 -0
  47. package/dist/stage-browser/chunk-VZNL6JY2.js +59 -0
  48. package/dist/stage-browser/dagre.esm-N2NIVIAZ.js +6 -0
  49. package/dist/stage-browser/math-4WFNHVV2.js +18 -0
  50. package/dist/stage-browser/stage.js +19 -0
  51. package/dist/stage-export.cjs +4950 -0
  52. package/dist/stage-export.d.cts +112 -0
  53. package/dist/stage-export.d.ts +112 -0
  54. package/dist/stage-export.js +544 -0
  55. package/dist/stage.cjs +9745 -0
  56. package/dist/stage.d.cts +1678 -0
  57. package/dist/stage.d.ts +1678 -0
  58. package/dist/stage.js +5404 -0
  59. package/dist/svg-import-Djj2q7Pc.d.cts +742 -0
  60. package/dist/svg-import-Djj2q7Pc.d.ts +742 -0
  61. package/dist/video-CcHW1qhV.d.cts +532 -0
  62. package/dist/video-CcHW1qhV.d.ts +532 -0
  63. package/examples/README.md +18 -0
  64. package/examples/agent-pipeline.tsx +4 -4
  65. package/examples/animated-pipeline.tsx +1 -5
  66. package/examples/attention-head.tsx +12 -12
  67. package/examples/aurora-incident.tsx +4 -3
  68. package/examples/building-blocks.tsx +8 -9
  69. package/examples/catalog-charts.tsx +4 -4
  70. package/examples/catalog-content.tsx +7 -9
  71. package/examples/catalog-convolution-kernel.tsx +116 -0
  72. package/examples/catalog-data.tsx +2 -8
  73. package/examples/catalog-dataflow.tsx +5 -9
  74. package/examples/catalog-dense.tsx +80 -0
  75. package/examples/catalog-deployment.tsx +5 -11
  76. package/examples/catalog-diagrams.tsx +13 -16
  77. package/examples/catalog-drawing.tsx +7 -7
  78. package/examples/catalog-flows.tsx +4 -4
  79. package/examples/catalog-foundations.tsx +11 -11
  80. package/examples/catalog-gaussian-blur.tsx +146 -0
  81. package/examples/catalog-image-tensors.tsx +115 -0
  82. package/examples/catalog-ml.tsx +36 -31
  83. package/examples/catalog-numeric-matrices.tsx +93 -0
  84. package/examples/catalog-photo-blur.tsx +209 -0
  85. package/examples/catalog-science-ai.tsx +130 -0
  86. package/examples/catalog-science-chemistry.tsx +103 -0
  87. package/examples/catalog-science-math.tsx +93 -0
  88. package/examples/catalog-science-physics.tsx +84 -0
  89. package/examples/catalog-sequence.tsx +59 -38
  90. package/examples/data-pipeline-lineage-presentation.tsx +5 -0
  91. package/examples/data-pipeline-lineage.tsx +85 -0
  92. package/examples/daybreak-launch.tsx +1 -0
  93. package/examples/desired-quadrant.tsx +7 -8
  94. package/examples/engineering-dashboard-presentation.tsx +13 -0
  95. package/examples/engineering-dashboard.tsx +160 -0
  96. package/examples/engineering-flow.tsx +2 -4
  97. package/examples/eval-dashboard.tsx +6 -6
  98. package/examples/films/attention.ts +278 -0
  99. package/examples/films/cache-miss.ts +431 -0
  100. package/examples/films/catalog.json +132 -0
  101. package/examples/films/central-limit.ts +269 -0
  102. package/examples/films/complex-maps.ts +273 -0
  103. package/examples/films/deck-example.ts +224 -0
  104. package/examples/films/euler-circle.ts +179 -0
  105. package/examples/films/fourier-epicycles.ts +265 -0
  106. package/examples/films/gradient-descent.ts +345 -0
  107. package/examples/films/linear-maps.ts +175 -0
  108. package/examples/films/lorenz.ts +207 -0
  109. package/examples/films/pythagoras.ts +185 -0
  110. package/examples/films/taylor-series.ts +159 -0
  111. package/examples/films/vizmatic-title.ts +117 -0
  112. package/examples/llm-serving-stack-presentation.tsx +5 -0
  113. package/examples/llm-serving-stack.tsx +94 -0
  114. package/examples/model-garden.tsx +1 -0
  115. package/examples/model-router.tsx +6 -6
  116. package/examples/nccl-all-gather.tsx +3 -3
  117. package/examples/nccl-all-reduce.tsx +3 -3
  118. package/examples/nccl-all-to-all.tsx +1 -1
  119. package/examples/nccl-broadcast.tsx +1 -1
  120. package/examples/nccl-reduce-scatter.tsx +5 -5
  121. package/examples/orthogonal-routing.tsx +4 -4
  122. package/examples/pareto-frontier.tsx +9 -10
  123. package/examples/presentation-frame.tsx +6 -6
  124. package/examples/pressure-mechanism.scene.json +14 -0
  125. package/examples/production-system-map-presentation.tsx +5 -0
  126. package/examples/production-system-map.tsx +130 -0
  127. package/examples/rag-graph.tsx +7 -7
  128. package/examples/release-card.tsx +5 -5
  129. package/examples/spec-anatomy.tsx +5 -5
  130. package/examples/system-architecture.tsx +19 -32
  131. package/examples/theme-system.tsx +1 -1
  132. package/examples/token-matrix.tsx +4 -2
  133. package/examples/transparent-badge.tsx +1 -2
  134. package/examples/videos/README.md +62 -0
  135. package/examples/videos/calculus-tangent.tsx +101 -0
  136. package/examples/videos/catalyst-pathway.tsx +56 -0
  137. package/examples/videos/causal-attention.tsx +91 -0
  138. package/examples/videos/convolution-kernel.tsx +34 -0
  139. package/examples/videos/gaussian-blur.tsx +32 -0
  140. package/examples/videos/image-to-matrix.tsx +22 -0
  141. package/examples/videos/matrix-multiplication.tsx +128 -0
  142. package/examples/videos/photo-gaussian-blur.tsx +39 -0
  143. package/examples/videos/request-lifecycle.tsx +99 -0
  144. package/examples/videos/signal-to-story.tsx +126 -0
  145. package/examples/videos/wave-interference.tsx +80 -0
  146. package/examples/vizmatic-bare.d.ts +1 -0
  147. package/examples/vizmatic-hero.tsx +9 -18
  148. package/examples/website-workflow.tsx +7 -7
  149. package/examples/weekend-field-notes.tsx +3 -2
  150. package/package.json +77 -12
@@ -16,38 +16,36 @@ export function create(theme: ThemeMode = 'dark') {
16
16
  <Scene
17
17
  c={c}
18
18
  title="ML topology catalog"
19
- subtitle="tensor shapes, repeated blocks, residual paths, KV state, and collective communication"
19
+ subtitle="tensor shapes, residual updates, and key-value state in a decoder block"
20
20
  background={c.bg}
21
21
  padding={24}
22
22
  gap={12}
23
23
  >
24
24
  <Panel
25
25
  c={c}
26
- title="Decoder-only transformer"
27
- subtitle="one compact block stands for ×24 layers; typed routes expose data, state, residual, and rank-level paths"
28
- tone="purple"
26
+ title="One pre-norm decoder block"
27
+ subtitle="Attention and MLP each have an explicit residual update"
29
28
  width="100%"
30
- minHeight={560}
31
29
  padding={14}
32
30
  align="center"
33
- footer="Shapes use B=batch, T=tokens, H=heads, and d=model width. Dashed routes are residual or collective; dotted routes persist KV state."
31
+ footer="Repeat this complete attention + MLP block 24 times. Shapes use B=batch, T=tokens, and d=model width; residual routes add each sublayer output to its input, and KV routes persist keys and values."
34
32
  >
35
33
  <TransformerTopology
36
34
  c={c}
37
- width={1666}
35
+ width={1400}
38
36
  height={432}
39
37
  sizing="content"
40
38
  direction="LR"
41
- nodeWidth={174}
42
- nodeHeight={82}
43
- nodeGap={30}
44
- rankGap={52}
39
+ nodeWidth={150}
40
+ nodeHeight={78}
41
+ nodeGap={26}
42
+ rankGap={38}
45
43
  edgeGap={12}
46
- padding={26}
44
+ padding={24}
47
45
  labelFontSize={13}
48
46
  detailFontSize={11}
49
47
  iconSize={18}
50
- ariaLabel="Decoder transformer topology from token embeddings through normalized attention and repeated MLP blocks to logits, including residual, KV-cache, and all-reduce routes"
48
+ ariaLabel="One pre-norm decoder block repeated 24 times, with attention and MLP residual additions, a key-value cache, and logits"
51
49
  blocks={[
52
50
  {
53
51
  id: 'tokens',
@@ -57,27 +55,33 @@ export function create(theme: ThemeMode = 'dark') {
57
55
  inputShape: { dims: ['B', 'T'], dtype: 'int32' },
58
56
  outputShape: { dims: ['B', 'T', 'd'], dtype: 'bf16' },
59
57
  },
60
- {
61
- id: 'norm',
62
- label: 'RMSNorm',
63
- kind: 'norm',
64
- shape: { dims: ['B', 'T', 'd'], dtype: 'bf16' },
65
- tone: 'neutral',
66
- },
67
58
  {
68
59
  id: 'attention',
69
- label: 'GQA attention',
60
+ label: 'Norm → GQA',
70
61
  kind: 'attention',
71
62
  detail: '32Q / 8KV heads',
72
63
  shape: { dims: ['B', 'T', 'd'], dtype: 'bf16' },
73
64
  },
65
+ {
66
+ id: 'attention-residual',
67
+ label: 'Add attention',
68
+ kind: 'residual',
69
+ detail: 'x + attn(norm(x))',
70
+ shape: { dims: ['B', 'T', 'd'], dtype: 'bf16' },
71
+ },
74
72
  {
75
73
  id: 'mlp',
76
- label: 'SwiGLU MLP',
74
+ label: 'Norm → SwiGLU',
77
75
  kind: 'mlp',
78
- detail: 'expert width 11k',
76
+ detail: 'width 11k',
77
+ shape: { dims: ['B', 'T', 'd'], dtype: 'bf16' },
78
+ },
79
+ {
80
+ id: 'mlp-residual',
81
+ label: 'Add MLP',
82
+ kind: 'residual',
83
+ detail: 'x′ + MLP(norm(x′))',
79
84
  shape: { dims: ['B', 'T', 'd'], dtype: 'bf16' },
80
- repeat: 24,
81
85
  },
82
86
  {
83
87
  id: 'kv',
@@ -85,7 +89,6 @@ export function create(theme: ThemeMode = 'dark') {
85
89
  kind: 'custom',
86
90
  detail: 'paged state',
87
91
  shape: { dims: ['B', '8', 'T', '128'], dtype: 'bf16' },
88
- tone: 'cyan',
89
92
  },
90
93
  {
91
94
  id: 'logits',
@@ -96,12 +99,14 @@ export function create(theme: ThemeMode = 'dark') {
96
99
  },
97
100
  ]}
98
101
  routes={[
99
- { id: 'embed-norm', from: 'tokens', to: 'norm', kind: 'activation', label: 'hidden · [B×T×d]', shape: ['B', 'T', 'd'] },
100
- { id: 'norm-attn', from: 'norm', to: 'attention', kind: 'activation', label: 'QKV · [B×T×d]', shape: ['B', 'T', 'd'] },
101
- { id: 'attn-mlp', from: 'attention', to: 'mlp', kind: 'activation', label: 'context · [B×T×d]', shape: ['B', 'T', 'd'] },
102
- { id: 'attn-kv', from: 'attention', to: 'kv', kind: 'kv-cache', label: 'persist K/V', shape: ['B', '8', 'T', '128'] },
103
- { id: 'norm-residual', from: 'norm', to: 'mlp', kind: 'residual', label: 'residual · x + f(x)', arrow: 'both' },
104
- { id: 'mlp-collective', from: 'mlp', to: 'logits', kind: 'collective', label: 'all-reduce · 8 ranks', collective: 'all-reduce', arrow: 'both' },
102
+ { id: 'embed-attn', from: 'tokens', to: 'attention', kind: 'activation', label: 'input x' },
103
+ { id: 'attn-output', from: 'attention', to: 'attention-residual', kind: 'activation' },
104
+ { id: 'attention-skip', from: 'tokens', to: 'attention-residual', kind: 'residual', arrow: 'forward' },
105
+ { id: 'attn-kv', from: 'attention', to: 'kv', kind: 'kv-cache', label: 'cache K/V' },
106
+ { id: 'attention-mlp', from: 'attention-residual', to: 'mlp', kind: 'activation' },
107
+ { id: 'mlp-output', from: 'mlp', to: 'mlp-residual', kind: 'activation' },
108
+ { id: 'mlp-skip', from: 'attention-residual', to: 'mlp-residual', kind: 'residual', arrow: 'forward' },
109
+ { id: 'to-logits', from: 'mlp-residual', to: 'logits', kind: 'activation', label: 'after 24 layers' },
105
110
  ]}
106
111
  />
107
112
  </Panel>
@@ -0,0 +1,93 @@
1
+ import {
2
+ getThemeColors,
3
+ Matrix,
4
+ multiplyMatrices,
5
+ transposeMatrix,
6
+ type ThemeMode,
7
+ } from 'vizmatic'
8
+
9
+ export const width = 1280
10
+ export const height = 720
11
+
12
+ const matrixA = [
13
+ [1, 2, 0],
14
+ [-1, 3, 2],
15
+ ]
16
+ const matrixB = [
17
+ [2, 1],
18
+ [0, 4],
19
+ [3, -2],
20
+ ]
21
+ const product = multiplyMatrices(matrixA, matrixB)
22
+ const transposedA = transposeMatrix(matrixA)
23
+ const integerLabels = (values: number[][]) => values.map(row => row.map(String))
24
+
25
+ export function create(theme: ThemeMode = 'dark') {
26
+ const c = getThemeColors(theme)
27
+ const accent = theme === 'dark' ? c.warningLight : c.warningDark
28
+ const output = product[1][1]
29
+
30
+ return (
31
+ <div style={{ position: 'relative', display: 'flex', width, height, overflow: 'hidden', backgroundColor: c.bg, color: c.textPrimary, fontFamily: c.fontSans }}>
32
+ <div style={{ position: 'absolute', left: 54, top: 38, display: 'flex', flexDirection: 'column', gap: 7 }}>
33
+ <span style={{ color: c.textSecondary, fontFamily: c.fontMono, fontSize: 14, fontWeight: 700, letterSpacing: 2 }}>LINEAR ALGEBRA / NUMERIC MATRICES</span>
34
+ <span style={{ fontSize: 42, fontWeight: 760, letterSpacing: -1.3 }}>Multiply a row by a column.</span>
35
+ <span style={{ color: c.textSecondary, fontSize: 19 }}>Every output cell is one dot product. Follow the highlighted pair to C₂₂.</span>
36
+ </div>
37
+
38
+ <div style={{ position: 'absolute', left: 42, top: 168, display: 'flex', width: 340, height: 286, flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: 14, backgroundColor: c.bgCard, border: `1px solid ${c.borderSubtle}`, borderRadius: 16 }}>
39
+ <div style={{ display: 'flex', width: 286, flexDirection: 'column', gap: 4 }}>
40
+ <span style={{ color: c.textPrimary, fontSize: 25, fontWeight: 750 }}>A <span style={{ color: c.textMuted, fontSize: 16, fontWeight: 500 }}>2 × 3</span></span>
41
+ <span style={{ color: c.textSecondary, fontSize: 15 }}>Select row 2</span>
42
+ </div>
43
+ <Matrix data={matrixA} c={c} rowLabels={['A₁', 'A₂']} colLabels={['k₁', 'k₂', 'k₃']} labels={integerLabels(matrixA)} format="integer" cellWidth={66} cellHeight={56} rowLabelWidth={45} fontSize={21} highlightRow={1} highlightColor={accent} colorDomain={[-2, 9]} />
44
+ </div>
45
+
46
+ <span style={{ position: 'absolute', left: 397, top: 274, color: c.textMuted, fontSize: 46, fontWeight: 500 }}>×</span>
47
+
48
+ <div style={{ position: 'absolute', left: 466, top: 168, display: 'flex', width: 340, height: 286, flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: 14, backgroundColor: c.bgCard, border: `1px solid ${c.borderSubtle}`, borderRadius: 16 }}>
49
+ <div style={{ display: 'flex', width: 286, flexDirection: 'column', gap: 4 }}>
50
+ <span style={{ color: c.textPrimary, fontSize: 25, fontWeight: 750 }}>B <span style={{ color: c.textMuted, fontSize: 16, fontWeight: 500 }}>3 × 2</span></span>
51
+ <span style={{ color: c.textSecondary, fontSize: 15 }}>Select column 2</span>
52
+ </div>
53
+ <Matrix data={matrixB} c={c} rowLabels={['k₁', 'k₂', 'k₃']} colLabels={['B₁', 'B₂']} labels={integerLabels(matrixB)} format="integer" cellWidth={72} cellHeight={42} rowLabelWidth={45} fontSize={20} highlightCol={1} highlightColor={accent} colorDomain={[-2, 9]} />
54
+ </div>
55
+
56
+ <span style={{ position: 'absolute', left: 821, top: 274, color: c.textMuted, fontSize: 43, fontWeight: 500 }}>=</span>
57
+
58
+ <div style={{ position: 'absolute', left: 874, top: 168, display: 'flex', width: 364, height: 286, flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: 14, backgroundColor: c.bgCard, border: `1px solid ${c.borderSubtle}`, borderRadius: 16 }}>
59
+ <div style={{ display: 'flex', width: 300, flexDirection: 'column', gap: 4 }}>
60
+ <span style={{ color: c.textPrimary, fontSize: 25, fontWeight: 750 }}>C = AB <span style={{ color: c.textMuted, fontSize: 16, fontWeight: 500 }}>2 × 2</span></span>
61
+ <span style={{ color: c.textSecondary, fontSize: 15 }}>The selected output is {output}</span>
62
+ </div>
63
+ <Matrix data={product} c={c} rowLabels={['A₁', 'A₂']} colLabels={['B₁', 'B₂']} labels={integerLabels(product)} format="integer" cellWidth={76} cellHeight={62} rowLabelWidth={45} fontSize={23} highlightCell={{ row: 1, col: 1 }} highlightColor={accent} colorDomain={[-2, 9]} />
64
+ </div>
65
+
66
+ <div style={{ position: 'absolute', left: 42, top: 486, display: 'flex', width: 748, height: 192, flexDirection: 'column', justifyContent: 'center', gap: 14, padding: '20px 26px', boxSizing: 'border-box', backgroundColor: c.bgCard, border: `1px solid ${c.borderSubtle}`, borderRadius: 16 }}>
67
+ <span style={{ color: accent, fontFamily: c.fontMono, fontSize: 14, fontWeight: 700, letterSpacing: 1.5 }}>ONE OUTPUT, THREE MULTIPLICATIONS</span>
68
+ <span style={{ fontSize: 24, fontWeight: 700 }}>C₂₂ = A₂ · B₂</span>
69
+ <div style={{ display: 'flex', alignItems: 'center', gap: 12, color: c.textPrimary, fontFamily: c.fontMono, fontSize: 21, fontWeight: 650 }}>
70
+ <span style={{ color: accent }}>−1 × 1</span>
71
+ <span style={{ color: c.textMuted }}>+</span>
72
+ <span>3 × 4</span>
73
+ <span style={{ color: c.textMuted }}>+</span>
74
+ <span>2 × −2</span>
75
+ <span style={{ color: c.textMuted }}>=</span>
76
+ <span style={{ color: accent, fontSize: 27 }}>{output}</span>
77
+ </div>
78
+ <span style={{ color: c.textSecondary, fontSize: 15 }}>The inner dimensions match: 3 columns in A and 3 rows in B.</span>
79
+ </div>
80
+
81
+ <div style={{ position: 'absolute', left: 812, top: 486, display: 'flex', width: 426, height: 192, alignItems: 'center', justifyContent: 'space-between', padding: '20px 24px', boxSizing: 'border-box', backgroundColor: c.bgCard, border: `1px solid ${c.borderSubtle}`, borderRadius: 16 }}>
82
+ <div style={{ display: 'flex', width: 150, flexDirection: 'column', gap: 8 }}>
83
+ <span style={{ color: c.textSecondary, fontFamily: c.fontMono, fontSize: 13, fontWeight: 700, letterSpacing: 1 }}>TRANSPOSE</span>
84
+ <span style={{ fontSize: 21, fontWeight: 700 }}>Rows become columns.</span>
85
+ <span style={{ color: c.textSecondary, fontSize: 14 }}>A is 2 × 3; Aᵀ is 3 × 2.</span>
86
+ </div>
87
+ <Matrix data={transposedA} c={c} labels={integerLabels(transposedA)} format="integer" cellWidth={48} cellHeight={38} fontSize={17} colorize={false} />
88
+ </div>
89
+ </div>
90
+ )
91
+ }
92
+
93
+ export default create('dark')