-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
750 lines (706 loc) · 49 KB
/
Copy pathindex.html
File metadata and controls
750 lines (706 loc) · 49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
<!-- Copyright (c) Alexander Kurtz 2026 -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Quantization Visualizer</title>
<!-- Prevent Theme Flash -->
<script>
(function () {
const saved = localStorage.getItem('theme');
if (saved === 'dark' || (!saved && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
document.documentElement.setAttribute('data-theme', 'dark');
}
})();
</script>
<link rel="stylesheet" href="style.css">
</head>
<body id="body">
<div class="container">
<main>
<div class="panel-wrapper" id="panel-left-wrapper">
<div class="panel">
<div class="panel-header">Data Controls</div>
<div class="settings-group">
<label>Generate Floats</label>
<select id="gen-dist">
<option value="normal" selected>Normal Dist. (Gaussian)</option>
<option value="laplace">Laplace (NN Weights)</option>
<option value="bimodal">Bimodal (Grouped)</option>
<option value="outliers">Normal + Outliers</option>
<option value="uniform">Uniform Random</option>
</select>
<div class="gen-advanced-wrapper">
<button id="gen-adv-toggle" class="adv-toggle-btn">
<span>Advanced Parameters</span>
<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor">
<path d="M7 10l5 5 5-5z" />
</svg>
</button>
<div id="gen-adv-panel" class="adv-panel" style="display: none;">
<div id="param-normal" class="dist-params" style="display:flex; flex-direction:column;">
<label>Standard Deviation</label>
<input type="number" id="gen-std" value="1.0" step="0.1" min="0.1">
</div>
<div id="param-laplace" class="dist-params"
style="display:none; flex-direction:column;">
<label>Scale (Diversity)</label>
<input type="number" id="gen-scale" value="1.0" step="0.1" min="0.1">
</div>
<div id="param-bimodal" class="dist-params"
style="display:none; flex-direction:column;">
<label>Peak Distance</label>
<input type="number" id="gen-bimodal-dist" value="4.0" step="0.5">
<label style="margin-top:4px;">Spread (Std Dev)</label>
<input type="number" id="gen-bimodal-spread" value="1.2" step="0.1" min="0.1">
</div>
<div id="param-outliers" class="dist-params"
style="display:none; flex-direction:column;">
<label>Outlier Probability</label>
<input type="number" id="gen-outlier-prob" value="0.02" step="0.01" min="0" max="1">
<label style="margin-top:4px;">Outlier Scale Multiplier</label>
<input type="number" id="gen-outlier-mult" value="5.0" step="0.5" min="1.0">
</div>
<div id="param-uniform" class="dist-params"
style="display:none; flex-direction:column;">
<label>Range (Spread)</label>
<input type="number" id="gen-uni-range" value="10.0" step="1.0" min="0.1">
</div>
</div>
</div>
<div style="display: flex; gap: 8px; margin-top: 4px;">
<input type="number" id="gen-count" value="256" min="1" max="131072" style="flex: 1;"
title="Count">
<button id="gen-btn" class="action-btn secondary" style="flex: 1;">Generate</button>
</div>
</div>
<div class="settings-group" style="margin-top: 10px;">
<label>Load Data from File</label>
<div id="file-drop-zone" class="file-drop-zone">
Click or drop (.txt, .json, .csv)
</div>
<input type="file" id="file-input" accept=".txt,.json,.csv,.xml" style="display: none;">
</div>
<div class="raw-floats-wrapper settings-group" style="margin-top: 10px;">
<button id="raw-adv-toggle" class="adv-toggle-btn">
<span>Raw Floats Block</span>
<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor">
<path d="M7 10l5 5 5-5z" />
</svg>
</button>
<div id="raw-adv-panel" class="adv-panel" style="display: none;">
<textarea id="float-input" placeholder="e.g. 1.2, -0.5, 3.14, -2.2, 0.1"></textarea>
</div>
</div>
<div class="raw-floats-wrapper settings-group" style="margin-top: 10px;">
<button id="raw-importance-adv-toggle" class="adv-toggle-btn">
<span>Importance Weights</span>
<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor">
<path d="M7 10l5 5 5-5z" />
</svg>
</button>
<div id="raw-importance-adv-panel" class="adv-panel" style="display: none;">
<div style="display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px;">
<div style="display: flex; align-items: center; gap: 6px;" id="use-importance-wrapper">
<input type="checkbox" id="use-importance"
style="width: auto; margin: 0; cursor: pointer;">
<label for="use-importance"
style="margin: 0; cursor: pointer; font-weight: bold;">Use Importance</label>
</div>
<div id="importance-warning"
style="color: var(--negative-color); font-size: 0.75rem; display: none;">Mismatch
length</div>
<div id="importance-negative-warning"
style="color: #eab308; font-size: 0.75rem; display: none;">Negative values were
clipped to 0</div>
</div>
<div class="settings-group" style="margin-bottom: 8px;">
<label style="font-size: 0.8rem;">Load Importance from File</label>
<div id="imp-file-drop-zone" class="file-drop-zone"
style="padding: 12px; font-size: 0.8em;">
Click or drop (.txt, .csv)
</div>
<input type="file" id="imp-file-input" accept=".txt,.json,.csv,.xml"
style="display: none;">
</div>
<button id="imp-raw-toggle" class="adv-toggle-btn"
style="margin-bottom: 4px; padding: 4px 0;">
<span>Raw Importance Floats</span>
<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor">
<path d="M7 10l5 5 5-5z" />
</svg>
</button>
<div id="imp-raw-panel" class="adv-panel"
style="display: none; padding: 0; border: none; background: transparent; margin-top: 0;">
<textarea id="float-input-importance"
placeholder="e.g. 0.1, 0.05, 0.3, 0.55"></textarea>
</div>
<div class="settings-group" style="margin-top: 8px;">
<label style="font-size: 0.8rem;">Generate Synthetic Importance</label>
<select id="imp-gen-dist">
<option value="uniform" selected>Uniform Random</option>
<option value="normal">Normal Dist. (Gaussian)</option>
<option value="laplace">Laplace</option>
<option value="bimodal">Bimodal</option>
<option value="outliers">Normal + Outliers</option>
</select>
<div class="gen-advanced-wrapper">
<button id="imp-gen-adv-toggle" class="adv-toggle-btn">
<span>Advanced Parameters</span>
<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor">
<path d="M7 10l5 5 5-5z" />
</svg>
</button>
<div id="imp-gen-adv-panel" class="adv-panel" style="display: none;">
<div id="imp-param-normal" class="dist-params imp-dist-params"
style="display:none; flex-direction:column;">
<label>Standard Deviation</label>
<input type="number" id="imp-gen-std" value="1.0" step="0.1" min="0.1">
</div>
<div id="imp-param-laplace" class="dist-params imp-dist-params"
style="display:none; flex-direction:column;">
<label>Scale (Diversity)</label>
<input type="number" id="imp-gen-scale" value="1.0" step="0.1" min="0.1">
</div>
<div id="imp-param-bimodal" class="dist-params imp-dist-params"
style="display:none; flex-direction:column;">
<label>Peak Distance</label>
<input type="number" id="imp-gen-bimodal-dist" value="4.0" step="0.5">
<label style="margin-top:4px;">Spread (Std Dev)</label>
<input type="number" id="imp-gen-bimodal-spread" value="1.2" step="0.1"
min="0.1">
</div>
<div id="imp-param-outliers" class="dist-params imp-dist-params"
style="display:none; flex-direction:column;">
<label>Outlier Probability</label>
<input type="number" id="imp-gen-outlier-prob" value="0.02" step="0.01"
min="0" max="1">
<label style="margin-top:4px;">Outlier Scale Multiplier</label>
<input type="number" id="imp-gen-outlier-mult" value="5.0" step="0.5"
min="1.0">
</div>
<div id="imp-param-uniform" class="dist-params imp-dist-params"
style="display:flex; flex-direction:column;">
<label>Range (Spread)</label>
<input type="number" id="imp-gen-uni-range" value="10.0" step="1.0"
min="0.1">
</div>
</div>
</div>
<button id="imp-gen-btn" class="action-btn secondary" style="margin-top: 4px;">Generate
to Match</button>
</div>
</div>
</div>
<div class="settings-group" style="margin-top: 10px;">
<button id="data-transform-toggle" class="adv-toggle-btn">
<span>Data Scaling & Offset</span>
<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor">
<path d="M7 10l5 5 5-5z" />
</svg>
</button>
<div id="data-transform-panel" class="adv-panel" style="display: none;">
<div style="display: flex; flex-direction: row; gap: 8px; width: 100%;">
<div style="flex: 1; display: flex; flex-direction: column; gap: 4px;">
<label for="data-scale" style="font-size: 0.8rem; font-weight:normal;">Scale
Data</label>
<input type="number" id="data-scale" value="1.0" step="0.1">
</div>
<div style="flex: 1; display: flex; flex-direction: column; gap: 4px;">
<label for="data-offset" style="font-size: 0.8rem; font-weight:normal;">Offset
Data</label>
<input type="number" id="data-offset" value="0.0" step="0.1">
</div>
</div>
</div>
</div>
<div class="settings-group" style="margin-top: 10px;">
<button id="btn-dataset-bar" class="adv-toggle-btn">
<span>Overview Minimap & Tools</span>
<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor">
<path d="M7 10l5 5 5-5z" />
</svg>
</button>
<div id="db-tools-panel" class="adv-panel" style="display: none;">
<div class="settings-group" style="flex-direction: column; gap: 4px;">
<div style="display: flex; flex-direction: row; align-items: center; gap: 8px;">
<input type="checkbox" id="db-mode-clip"
style="width: auto; margin: 0; cursor: pointer;">
<label for="db-mode-clip" style="margin: 0; cursor: pointer;">Weight Clip</label>
</div>
<div id="db-clip-params" class="dist-params"
style="display:flex; flex-direction: row; gap: 8px; margin-top: 2px;">
<div style="flex: 1; display: flex; flex-direction: column; gap: 4px;">
<label for="db-clip-start" style="font-size: 0.8rem; font-weight:normal;">Start
Index</label>
<input type="number" id="db-clip-start" value="0" min="0">
</div>
<div style="flex: 1; display: flex; flex-direction: column; gap: 4px;">
<label for="db-clip-width"
style="font-size: 0.8rem; font-weight:normal;">Width</label>
<input type="number" id="db-clip-width" value="1048576" min="1">
</div>
</div>
</div>
<div class="settings-group" style="flex-direction: row; align-items: center; gap: 8px;">
<input type="checkbox" id="db-mode-minmax"
style="width: auto; margin: 0; cursor: pointer;">
<label for="db-mode-minmax" style="margin: 0; cursor: pointer;">Min / Max
Indicators</label>
</div>
<div class="settings-group" style="flex-direction: row; align-items: center; gap: 8px;">
<input type="checkbox" id="db-mode-hotspots"
style="width: auto; margin: 0; cursor: pointer;">
<label for="db-mode-hotspots" style="margin: 0; cursor: pointer;">Error Hotspots</label>
</div>
</div>
</div>
<div class="settings-group" style="margin-top: 10px;">
<button id="chart-axis-toggle" class="adv-toggle-btn">
<span>Chart Y-Axis</span>
<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor">
<path d="M7 10l5 5 5-5z" />
</svg>
</button>
<div id="chart-axis-panel" class="adv-panel" style="display: none;">
<div class="settings-group" style="flex-direction: column; gap: 4px;">
<label for="centering-mode">Centering</label>
<select id="centering-mode">
<option value="data" selected>Data Range</option>
<option value="zero">Zero Centered</option>
<option value="manual">Manual</option>
</select>
</div>
<div id="axis-outliers-wrap" class="settings-group"
style="flex-direction: column; gap: 4px; display: flex;">
<div style="display: flex; flex-direction: row; align-items: center; gap: 8px;">
<input type="checkbox" id="axis-ignore-outliers"
style="width: auto; margin: 0; cursor: pointer;">
<label for="axis-ignore-outliers" style="margin: 0; cursor: pointer;">Ignore
Outliers</label>
</div>
<div id="axis-outlier-pct-wrap"
style="display: none; flex-direction: column; gap: 4px; margin-top: 4px;">
<label for="axis-outlier-pct" style="font-size: 0.8rem; font-weight:normal;">Ignore
Top/Bottom %</label>
<input type="number" id="axis-outlier-pct" value="1.0" min="0.0" max="49.9"
step="0.1">
</div>
</div>
<div id="axis-manual-wrap" class="settings-group"
style="display: none; flex-direction: row; gap: 8px;">
<div style="flex: 1; display: flex; flex-direction: column; gap: 4px;">
<label for="axis-manual-min"
style="font-size: 0.8rem; font-weight:normal;">Min</label>
<input type="number" id="axis-manual-min" value="-10.0" step="0.1">
</div>
<div style="flex: 1; display: flex; flex-direction: column; gap: 4px;">
<label for="axis-manual-max"
style="font-size: 0.8rem; font-weight:normal;">Max</label>
<input type="number" id="axis-manual-max" value="10.0" step="0.1">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="viz-wrapper">
<button class="toggle-btn left-toggle" id="toggle-left"><svg viewBox="0 0 24 24">
<path d="M15.41 16.59L10.83 12l4.58-4.59L14 6l-6 6 6 6 1.41-1.41z" />
</svg></button>
<button class="toggle-btn right-toggle" id="toggle-right"><svg viewBox="0 0 24 24">
<path d="M8.59 16.59L13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.41z" />
</svg></button>
<div class="viz-container" id="viz-container">
<div class="axis-label top"><span id="chart-max-lbl">Max: 0</span></div>
<div style="position: relative; width: 100%; flex: 1 1 0%; display: flex; min-height: 250px;">
<button id="btn-reset-zoom" class="icon-btn top-left" title="Reset Zoom" style="display: none;">
<svg viewBox="0 0 24 24" fill="currentColor">
<path
d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" />
<path d="M7 9h5v1H7z" />
</svg>
</button>
<button id="btn-toggle-srht" class="icon-btn top-right" title="SRHT transformed display"
style="display: none;">
<svg viewBox="0 0 24 24" fill="currentColor">
<path
d="M19 8l-4 4h3c0 3.31-2.69 6-6 6-1.01 0-1.97-.25-2.8-.7l-1.46 1.46C8.97 19.54 10.43 20 12 20c4.42 0 8-3.58 8-8h3l-4-4zM6 12c0-3.31 2.69-6 6-6 1.01 0 1.97.25 2.8.7l1.46-1.46C15.03 4.46 13.57 4 12 4c-4.42 0-8 3.58-8 8H1l4 4 4-4H6z" />
</svg>
</button>
<div class="chart-area" id="chart-area">
<div class="baseline" id="baseline"></div>
<div class="zoom-box" id="zoom-box" style="display: none;"></div>
</div>
</div>
<div class="axis-label bottom"><span id="chart-min-lbl">Min: 0</span></div>
<div class="legend">
<div class="legend-item">
<div class="legend-color" style="background: var(--accent-color);"></div> Pos. Quantized
</div>
<div class="legend-item">
<div class="legend-color" style="background: var(--negative-color);"></div> Neg. Quantized
</div>
<div class="legend-item">
<div class="legend-color"
style="background: repeating-linear-gradient(45deg, var(--error-color), var(--error-color) 3px, transparent 3px, transparent 6px);">
</div> Quantization Error
</div>
</div>
<div class="dataset-bar-wrapper" id="dataset-bar-wrapper" style="display:none;">
<div id="dataset-bar" class="dataset-bar">
<canvas id="db-canvas"
style="position:absolute; width:100%; height:100%; left:0; top:0; pointer-events:none;"></canvas>
<div id="db-min-arrow"
style="display:none; position:absolute; top:0; bottom:0; width:2px; background:var(--negative-color); z-index:5;">
<div
style="position:absolute; top:-12px; left:-5px; font-size:10px; color:var(--negativeColor);">
Min</div>
</div>
<div id="db-max-arrow"
style="display:none; position:absolute; top:0; bottom:0; width:2px; background:var(--accent-color); z-index:5;">
<div
style="position:absolute; top:-12px; left:-5px; font-size:10px; color:var(--accent-color);">
Max</div>
</div>
<div id="db-active-region"
style="position:absolute; height:100%; background:rgba(79, 70, 229, 0.15); border-left:1px solid var(--primary-color); border-right:1px solid var(--primary-color); box-sizing:border-box;">
<div id="db-handle-left" class="db-handle"></div>
<div id="db-handle-right" class="db-handle"></div>
</div>
</div>
</div>
<div class="equation-box" id="equation-box"></div>
<div class="inspector-panel" id="inspector-panel">
<div class="inspector-card">
<h4>Weight Inspector <span id="ins-w-idx">[-]</span></h4>
<div class="inspector-data" id="ins-w-data">
<div class="empty-state">Hover over a bar to inspect</div>
</div>
</div>
<div class="inspector-card" id="card-block">
<h4>Sub-Block stats <span id="ins-b-idx">[-]</span></h4>
<div class="inspector-data" id="ins-b-data">
<div class="empty-state">Hover over a block to inspect</div>
</div>
</div>
<div class="inspector-card" id="card-super">
<h4>Super-Block stats <span id="ins-sb-idx">[-]</span></h4>
<div class="inspector-data" id="ins-sb-data">
<div class="empty-state">Hover over a superblock</div>
</div>
</div>
</div>
</div>
</div>
<div class="panel-wrapper" id="panel-right-wrapper">
<div class="panel">
<div class="panel-header">Quant Engine</div>
<div class="settings-group">
<label for="preset-select">Presets</label>
<select id="preset-select">
<option value="custom">-- Custom --</option>
</select>
</div>
<div class="settings-group">
<label for="quant-type">Quantization Scheme</label>
<select id="quant-type">
</select>
</div>
<div class="settings-group">
<label for="quant-bits">Weight Resolution (Bits)</label>
<input type="number" id="quant-bits" value="4" min="1" max="8">
</div>
<div id="primitive-settings"
style="display: none; flex-direction: column; gap: 12px; margin-top: 6px;">
<div class="settings-group">
<label for="primitive-format">Floating Point Format</label>
<select id="primitive-format">
<option value="fp32" selected>FP32 (Baseline)</option>
<option value="fp16">FP16</option>
<option value="bf16">BF16</option>
<option value="fp8_e4m3">FP8 (E4M3)</option>
<option value="fp8_e5m2">FP8 (E5M2)</option>
</select>
</div>
</div>
<div id="block-settings" class="settings-group" style="display: flex;">
<label for="block-size">Block Size</label>
<select id="block-size">
<option value="16">16</option>
<option value="32" selected>32</option>
<option value="64">64</option>
</select>
</div>
<div id="nvfp4-settings" style="display: none;"></div>
<div id="mxfp-settings" style="display: none; flex-direction: column; gap: 12px; margin-top: 6px;">
<div class="settings-group">
<label for="mxfp-format"
title="OCP Microscaling Formats. Blocks of 32 share an E8M0 scale.">MX Format
Precision</label>
<select id="mxfp-format">
<option value="mxfp4_e2m1" selected>MXFP4 (E2M1)</option>
<option value="mxfp6_e2m3">MXFP6 (E2M3)</option>
<option value="mxfp6_e3m2">MXFP6 (E3M2)</option>
<option value="mxfp8_e4m3">MXFP8 (E4M3)</option>
<option value="mxfp8_e5m2">MXFP8 (E5M2)</option>
</select>
</div>
</div>
<div id="turbo-settings" style="display: none; flex-direction: column; gap: 12px; margin-top: 6px;">
<div class="settings-group">
<label for="turbo-bits">Lloyd-Max Centroids (Bits)</label>
<input type="number" id="turbo-bits" value="4" min="1" max="8">
</div>
<div class="settings-group">
<label for="turbo-block-size">WHT Block Size</label>
<select id="turbo-block-size">
<option value="32">32</option>
<option value="64">64</option>
<option value="128" selected>128</option>
<option value="256">256</option>
<option value="512">512</option>
<option value="1024">1024</option>
<option value="2048">2048</option>
</select>
</div>
<div class="settings-group" style="flex-direction: row; align-items: center; gap: 8px;"
title="Subsampled Randomized Hadamard Transform. Applies a diagonal random sign flip followed by a Walsh-Hadamard Transform to mathematically guarantee a Gaussian-like distribution, eliminating outlier impact.">
<input type="checkbox" id="turbo-wht" checked
style="width: auto; margin: 0; cursor: pointer;">
<label for="turbo-wht" style="margin: 0; cursor: pointer;">Enable SRHT</label>
</div>
<div class="settings-group" style="flex-direction: row; align-items: center; gap: 8px;"
title="Quantized Johnson-Lindenstrauss. Adds a 1-bit symmetric error correction (+/- MAE) to neutralize inner-product bias and reduce the aggregate quantization error.">
<input type="checkbox" id="turbo-qjl" checked
style="width: auto; margin: 0; cursor: pointer;">
<label for="turbo-qjl" style="margin: 0; cursor: pointer;">Enable QJL</label>
</div>
<!-- Advanced Turbo Settings Wrapper -->
<div class="turbo-advanced-wrapper" style="margin-top: 4px;">
<button id="turbo-adv-toggle" class="adv-toggle-btn">
<span>Advanced Parameters</span>
<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor">
<path d="M7 10l5 5 5-5z" />
</svg>
</button>
<div id="turbo-adv-panel" class="adv-panel" style="display: none; padding-top: 8px;">
<div class="settings-group">
<label for="turbo-sign-seed"
title="Seed for the deterministic pseudo-random sign flips (the diagonal matrix 'D' in SRHT). Used to ensure the transform is identically reversible.">SRHT
Sign Seed</label>
<input type="number" id="turbo-sign-seed" value="42">
</div>
</div>
</div>
</div>
<div id="trellis-settings"
style="display: none; flex-direction: column; gap: 12px; margin-top: 6px;">
<div class="settings-group">
<label for="trellis-bits"
title="Nominal bits per weight before scale overhead. TCQ uses path constraints, so the effective quality can beat plain scalar quantization at the same rate.">
Trellis Rate (Bits/Weight)
</label>
<input type="number" id="trellis-bits" value="4" min="1" max="8">
</div>
<div class="settings-group">
<label for="trellis-block-size"
title="How many weights share one RMS scale and one trellis traceback. Bigger blocks usually compress better but adapt more slowly.">
Viterbi Block Size
</label>
<select id="trellis-block-size">
<option value="16">16</option>
<option value="32">32</option>
<option value="64">64</option>
<option value="128" selected>128</option>
<option value="256">256</option>
<option value="512">512</option>
<option value="1024">1024</option>
<option value="2048">2048</option>
</select>
</div>
<div class="settings-group">
<label for="trellis-states"
title="How much path memory the search keeps. More states means more candidate paths and usually lower error, but more compute.">
Trellis Complexity
</label>
<select id="trellis-states">
<option value="1">1-State (Scalar)</option>
<option value="4" selected>4-State (Baseline TCQ)</option>
<option value="8">8-State (Better)</option>
<option value="16">16-State (High)</option>
<option value="64">64-State (Very High)</option>
<option value="256">256-State (Research)</option>
</select>
</div>
<div class="settings-group">
<label for="trellis-cb-type"
title="How the codebook levels are spaced. Uniform is evenly spaced; Lloyd-Max matches underlying values better.">
Codebook Distribution
</label>
<select id="trellis-cb-type">
<option value="lloyd" selected>Lloyd-Max (Gaussian)</option>
<option value="laplace">Lloyd-Max (Laplacian)</option>
<option value="uniform">Uniform (Linear)</option>
</select>
</div>
<div class="settings-group" style="flex-direction: row; align-items: center; gap: 8px;"
title="Subsampled Randomized Hadamard Transform to suppress outliers.">
<input type="checkbox" id="trellis-wht" style="width: auto; margin: 0; cursor: pointer;">
<label for="trellis-wht" style="margin: 0; cursor: pointer;">Enable SRHT</label>
</div>
<!-- Advanced Trellis Settings Wrapper -->
<div class="trellis-advanced-wrapper" style="margin-top: 4px;">
<button id="trellis-adv-toggle" class="adv-toggle-btn">
<span>Advanced Parameters</span>
<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor">
<path d="M7 10l5 5 5-5z" />
</svg>
</button>
<div id="trellis-adv-panel" class="adv-panel" style="display: none; padding-top: 8px;">
<div class="settings-group">
<label for="trellis-wht-scope"
title="Global applies FWHT across the entire dataset, perfectly smearing outlier energy so a single Global Scale can be used. Local applies FWHT per-block, which allows fine-tuned scales but forces local scales to spike if an outlier is trapped in that block, destroying precision for surrounding weights.">SRHT
Transform & Scale Scope</label>
<select id="trellis-wht-scope">
<option value="global" selected>Global (Global Tensor Transform + Scale)
</option>
<option value="local">Local (Per-Block Transform + Scale)</option>
</select>
</div>
<div class="settings-group">
<label for="trellis-opt-iters"
title="Uses Golden-Section Search to find the mathematically optimal scale by simulating the Viterbi TCQ path. Set > 0 to enable. Higher values reduce quantization error (MSE).">Scale
Optimization Iters</label>
<input type="number" id="trellis-opt-iters" value="0" min="0" max="25">
</div>
<div class="settings-group">
<label for="trellis-sign-seed"
title="Seed for the deterministic pseudo-random sign flips (the diagonal matrix 'D' in SRHT). Used to ensure the transform is identically reversible.">SRHT
Sign Seed</label>
<input type="number" id="trellis-sign-seed" value="42">
</div>
</div>
</div>
</div>
<div id="iq-settings" style="display: none; flex-direction: column; gap: 12px; margin-top: 6px;">
<div class="settings-group">
<label for="iq-type">IQ Quantization Format</label>
<select id="iq-type">
<option value="iq1_s">IQ1_S (1.56 BPW)</option>
<option value="iq1_m">IQ1_M (1.75 BPW)</option>
<option value="iq2_xxs" selected>IQ2_XXS (2.06 BPW)</option>
<option value="iq2_xs">IQ2_XS (2.31 BPW)</option>
<option value="iq2_s">IQ2_S (2.50 BPW)</option>
<option value="iq3_xxs">IQ3_XXS (3.06 BPW)</option>
<option value="iq3_s">IQ3_S (3.44 BPW)</option>
<option value="iq4_xs">IQ4_XS (4.25 BPW)</option>
<option value="iq4_nl">IQ4_NL (4.50 BPW)</option>
</select>
</div>
<div class="settings-group">
<label for="iq-scale-iters">Scale Search Iterations</label>
<input type="number" id="iq-scale-iters" value="6" min="0" max="30">
</div>
</div>
<div id="kquant-settings"
style="display: none; flex-direction: column; gap: 12px; margin-top: 6px;">
<div class="settings-group">
<label for="superblock-size">Superblock Size</label>
<select id="superblock-size">
<option value="64">64</option>
<option value="128">128</option>
<option value="256" selected>256</option>
<option value="512">512</option>
<option value="1024">1024</option>
<option value="2048">2048</option>
</select>
</div>
<div class="settings-group">
<label for="subblock-size">Sub-block Size</label>
<select id="subblock-size">
<option value="8">8</option>
<option value="16">16</option>
<option value="32" selected>32</option>
</select>
</div>
<div class="settings-group">
<label for="subblock-bits">Sub-block Scaler/Min (Bits)</label>
<input type="number" id="subblock-bits" value="6" min="1" max="8">
</div>
<div class="settings-group" style="flex-direction: row; align-items: center; gap: 8px;">
<input type="checkbox" id="subblock-offset" checked
style="width: auto; margin: 0; cursor: pointer;">
<label for="subblock-offset" style="margin: 0; cursor: pointer;">Include Min/Offset
(Asym)</label>
</div>
</div>
<div class="settings-group" id="importance-stats-group" style="display: none; margin-top: auto;">
<label>Importance Stats</label>
<div class="stats-box" id="importance-stats">Waiting...</div>
</div>
<div class="settings-group" id="global-stats-group" style="margin-top: auto;">
<label>Global Stats</label>
<div class="stats-box" id="quant-stats">Waiting...</div>
</div>
</div>
</div>
</main>
<footer class="app-footer">
<button id="btn-about" class="about-link">About Quantization Visualizer</button>
</footer>
</div>
<!-- Modals -->
<div id="about-modal" class="modal-overlay">
<div class="panel modal-panel" style="max-width: 500px; text-align: left; position: relative;">
<div
style="display:flex; justify-content:space-between; align-items:center; border-bottom: 1px solid var(--border-color); padding-bottom: 10px; margin-bottom: 15px;">
<h2 style="margin:0; font-size: 1.25rem;">Quantization Visualizer</h2>
<button id="theme-toggle" class="theme-toggle" aria-label="Toggle Dark Mode">
<svg id="theme-icon-moon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
style="display: none;">
<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path>
</svg>
<svg id="theme-icon-sun" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
style="display: none;">
<circle cx="12" cy="12" r="5"></circle>
<line x1="12" y1="1" x2="12" y2="3"></line>
<line x1="12" y1="21" x2="12" y2="23"></line>
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line>
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line>
<line x1="1" y1="12" x2="3" y2="12"></line>
<line x1="21" y1="12" x2="23" y2="12"></line>
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line>
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line>
</svg>
</button>
</div>
<p style="margin: 8px 0; font-size: 0.95rem;"><strong>Source Code:</strong> <a
href="https://github.com/LifesLight/Quantization-Visualizer" target="_blank"
style="color: var(--primary-color); text-decoration: none;">github.com/LifesLight/Quantization-Visualizer</a>
</p>
<p style="margin: 8px 0; font-size: 0.95rem;"><strong>Copyright:</strong> © Alexander Kurtz 2026</p>
<p style="margin: 8px 0; font-size: 0.95rem;"><strong>License:</strong> MIT License</p>
<div style="display:flex; justify-content:center; margin-top:20px;">
<button id="btn-about-close" class="action-btn secondary">Close</button>
</div>
</div>
</div>
<div id="large-data-modal" class="modal-overlay">
<div class="panel modal-panel">
<h3 style="margin-top:0;">Performance Warning</h3>
<p style="font-size: 0.95rem; line-height: 1.4; color: var(--text-muted);">Selecting more than 1.048.576
active weights might make complex quantization algorithms very slow or non-functional. Do you wish to
continue?</p>
<div style="display:flex; gap:10px; justify-content:center; margin-top:20px;">
<button id="btn-modal-back" class="action-btn secondary">Go Back</button>
<button id="btn-modal-okay" class="action-btn">Okay</button>
</div>
</div>
</div>
<script type="module" src="js/main.js"></script>
</body>
</html>