joelniklaus HF Staff commited on
Commit
e4acf3b
·
1 Parent(s): de4e224

fixed inference throughput plot for mobile

Browse files
app/src/content/embeds/inference-throughput-compare.html CHANGED
@@ -4,7 +4,7 @@
4
  <meta charset="UTF-8">
5
  <title>GPU Throughput Comparison</title>
6
  <style>
7
- :root {
8
  color-scheme: light dark;
9
  --bg: #ffffff;
10
  --surface: #f9fafb;
@@ -28,7 +28,7 @@
28
  }
29
 
30
  @media (prefers-color-scheme: dark) {
31
- :root {
32
  --bg: #020617;
33
  --surface: #0b1324;
34
  --canvas-bg: #f8fafc;
@@ -49,18 +49,27 @@
49
  --slider-end: #facc15;
50
  --slider-rest: #334155;
51
  }
52
- .bottom-strip { color: #e2e8f0; }
53
- .bottom-strip .tps { color: #cbd5e1; }
54
  }
55
 
56
- * { margin: 0; padding: 0; box-sizing: border-box; }
57
- body { background: var(--bg); color: var(--text); font-family: system-ui, sans-serif; display: flex; flex-direction: column; align-items: center; padding: 16px 0; }
 
58
 
59
- .viz { width: 100%; max-width: 1200px; }
 
 
 
 
 
 
 
 
60
 
61
  .control-group { display: flex; flex-direction: column; gap: 4px; }
62
  .control-group label { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.6px; }
63
- select {
64
  -webkit-appearance: none;
65
  appearance: none;
66
  color: var(--text-strong);
@@ -122,36 +131,7 @@
122
  .landmark-row.top .name { color: var(--training); }
123
  .landmark-row.bottom .tick { background: var(--brand); }
124
  .landmark-row.bottom .name { color: var(--brand); }
125
- #row-a1 .landmark, #row-b1 .landmark { z-index: 2; }
126
- #row-a2 .landmark, #row-b2 .landmark { z-index: 1; }
127
- #row-a2 .landmark .tick,
128
- #row-b2 .landmark .tick { position: relative; }
129
- #row-a2 .landmark .tick::after {
130
- content: '';
131
- position: absolute;
132
- left: 50%;
133
- transform: translateX(-50%);
134
- top: 100%;
135
- width: 1px;
136
- height: 18px;
137
- background: var(--training);
138
- opacity: 0.35;
139
- z-index: -1;
140
- }
141
- #row-b2 .landmark .tick::before {
142
- content: '';
143
- position: absolute;
144
- left: 50%;
145
- transform: translateX(-50%);
146
- bottom: 100%;
147
- width: 1px;
148
- height: 18px;
149
- background: var(--brand);
150
- opacity: 0.35;
151
- z-index: -1;
152
- }
153
-
154
- .landmark .tooltip { display: none; position: absolute; left: 50%; transform: translateX(-50%); background: var(--tooltip-bg); color: var(--tooltip-text); font-size: 12px; padding: 10px 14px; border-radius: 8px; width: 300px; white-space: normal; z-index: 2147483647; pointer-events: none; line-height: 1.45; text-align: left; box-shadow: 0 12px 30px rgba(0,0,0,0.35); }
155
  .landmark-row.top .tooltip { top: calc(100% + 4px); }
156
  .landmark-row.bottom .tooltip { top: calc(100% + 4px); }
157
  .landmark .tooltip::after { content: ''; position: absolute; left: 50%; transform: translateX(-50%); border: 5px solid transparent; }
@@ -261,7 +241,7 @@
261
  .speedup-badge .ratio.b-faster { color: var(--brand-b); }
262
 
263
  .datasets { min-width: 180px; display: flex; flex-direction: column; justify-content: center; }
264
- .datasets-title { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 6px; }
265
  .dataset-bars { display: flex; flex-direction: column; gap: 4px; }
266
  .dataset-item { display: flex; align-items: center; gap: 5px; font-size: 12px; position: relative; cursor: pointer; }
267
  .dataset-item .ds-check { font-size: 15px; width: 18px; text-align: center; }
@@ -270,7 +250,7 @@
270
  .dataset-item .ds-size { color: var(--text-faint); font-size: 11px; }
271
  .dataset-item.done .ds-name { color: var(--success); }
272
  .dataset-item.done .ds-time { color: var(--success); }
273
- .dataset-item .ds-tip { display: none; position: absolute; top: calc(100% + 6px); left: 0; background: var(--tooltip-bg); color: var(--tooltip-text); font-size: 12px; padding: 10px 14px; border-radius: 8px; width: 260px; white-space: normal; z-index: 2147483647; pointer-events: none; line-height: 1.45; text-align: left; box-shadow: 0 12px 30px rgba(0,0,0,0.35); }
274
  .dataset-item .ds-tip::after { content: ''; position: absolute; bottom: 100%; left: 20px; border: 5px solid transparent; border-bottom-color: var(--tooltip-bg); }
275
  .dataset-item:hover { z-index: 99999; }
276
  .dataset-item:hover .ds-tip { display: block; }
@@ -279,26 +259,77 @@
279
  .instance-b .ds-time { color: var(--brand-b); }
280
 
281
  @media (max-width: 980px) {
282
- .canvas-row { flex-direction: column; }
283
- .canvas-row .side-panel { align-items: flex-start; }
284
- .landmark .name { font-size: 9px; }
285
- .bottom-strip {
286
  left: 6px;
287
  right: 6px;
288
  font-size: 10px;
289
  }
290
- .output-num { font-size: 10px; }
291
- .output-unit { font-size: 10px; }
292
- .output-unit-emoji { font-size: 12px; }
293
- .output-heading { font-size: 9px; }
294
- .datasets { max-width: 100%; min-width: 0; }
295
- .dataset-bars { flex-direction: row; flex-wrap: wrap; gap: 4px 12px; }
296
- .dataset-item { font-size: 12px; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
297
  }
298
  </style>
299
  </head>
300
  <body>
301
- <div class="viz">
302
  <div class="slider-area">
303
  <div class="gpu-label" data-role="gpuLabel">1 GPU</div>
304
  <div class="landmark-row top" data-role="row-a2"></div>
@@ -553,19 +584,19 @@
553
  applyModelDefault(modelASelect, defaultModelA);
554
  applyModelDefault(modelBSelect, defaultModelB);
555
 
 
 
 
556
  if (isCompareMode) {
557
- datasetsTitleAEl.textContent = 'Time to generate dataset';
558
- datasetsTitleBEl.textContent = 'Time to generate dataset';
559
  booksRateAEl.textContent = '0 pages/sec';
560
  booksRateBEl.textContent = '0 pages/sec';
561
  } else {
562
- datasetsTitleAEl.innerHTML = 'Time to generate dataset<br>at current throughput';
563
  booksRateAEl.textContent = '0 books/sec';
564
  }
565
 
566
  const themeTokens = {};
567
  function refreshThemeTokens() {
568
- const styles = getComputedStyle(document.documentElement);
569
  themeTokens.sliderStart = styles.getPropertyValue('--slider-start').trim();
570
  themeTokens.sliderMid = styles.getPropertyValue('--slider-mid').trim();
571
  themeTokens.sliderEnd = styles.getPropertyValue('--slider-end').trim();
@@ -740,12 +771,20 @@
740
 
741
  function resizeCanvas() {
742
  const w = canvas.clientWidth;
 
 
 
743
  canvas.width = w * 2;
744
- canvas.height = Math.round(w * 0.28) * 2;
745
- canvas.style.height = Math.round(w * 0.28) + 'px';
746
  }
747
  resizeCanvas();
748
- window.addEventListener('resize', resizeCanvas);
 
 
 
 
 
749
 
750
  let floatingItems = [], totalTokens = 0, spawnAccum = 0;
751
  let _fNow = 0, _fPps = 0, _fFanPhase = 0, _fBlinkSpeed = 0;
 
4
  <meta charset="UTF-8">
5
  <title>GPU Throughput Comparison</title>
6
  <style>
7
+ .throughput-compare-viz {
8
  color-scheme: light dark;
9
  --bg: #ffffff;
10
  --surface: #f9fafb;
 
28
  }
29
 
30
  @media (prefers-color-scheme: dark) {
31
+ .throughput-compare-viz {
32
  --bg: #020617;
33
  --surface: #0b1324;
34
  --canvas-bg: #f8fafc;
 
49
  --slider-end: #facc15;
50
  --slider-rest: #334155;
51
  }
52
+ .throughput-compare-viz .bottom-strip { color: #e2e8f0; }
53
+ .throughput-compare-viz .bottom-strip .tps { color: #cbd5e1; }
54
  }
55
 
56
+ .throughput-compare-viz,
57
+ .throughput-compare-viz * { box-sizing: border-box; }
58
+ .throughput-compare-viz * { margin: 0; padding: 0; }
59
 
60
+ .throughput-compare-viz {
61
+ width: 100%;
62
+ max-width: 1200px;
63
+ margin: 0 auto;
64
+ padding: 16px 0;
65
+ background: var(--bg);
66
+ color: var(--text);
67
+ font-family: system-ui, sans-serif;
68
+ }
69
 
70
  .control-group { display: flex; flex-direction: column; gap: 4px; }
71
  .control-group label { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.6px; }
72
+ .throughput-compare-viz select {
73
  -webkit-appearance: none;
74
  appearance: none;
75
  color: var(--text-strong);
 
131
  .landmark-row.top .name { color: var(--training); }
132
  .landmark-row.bottom .tick { background: var(--brand); }
133
  .landmark-row.bottom .name { color: var(--brand); }
134
+ .landmark .tooltip { display: none; position: absolute; left: 50%; transform: translateX(-50%); background: var(--tooltip-bg); color: var(--tooltip-text); font-size: 12px; padding: 10px 14px; border-radius: 8px; width: min(300px, calc(100vw - 32px)); white-space: normal; z-index: 2147483647; pointer-events: none; line-height: 1.45; text-align: left; box-shadow: 0 12px 30px rgba(0,0,0,0.35); }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  .landmark-row.top .tooltip { top: calc(100% + 4px); }
136
  .landmark-row.bottom .tooltip { top: calc(100% + 4px); }
137
  .landmark .tooltip::after { content: ''; position: absolute; left: 50%; transform: translateX(-50%); border: 5px solid transparent; }
 
241
  .speedup-badge .ratio.b-faster { color: var(--brand-b); }
242
 
243
  .datasets { min-width: 180px; display: flex; flex-direction: column; justify-content: center; }
244
+ .datasets-title { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 6px; white-space: nowrap; }
245
  .dataset-bars { display: flex; flex-direction: column; gap: 4px; }
246
  .dataset-item { display: flex; align-items: center; gap: 5px; font-size: 12px; position: relative; cursor: pointer; }
247
  .dataset-item .ds-check { font-size: 15px; width: 18px; text-align: center; }
 
250
  .dataset-item .ds-size { color: var(--text-faint); font-size: 11px; }
251
  .dataset-item.done .ds-name { color: var(--success); }
252
  .dataset-item.done .ds-time { color: var(--success); }
253
+ .dataset-item .ds-tip { display: none; position: absolute; top: calc(100% + 6px); left: 0; background: var(--tooltip-bg); color: var(--tooltip-text); font-size: 12px; padding: 10px 14px; border-radius: 8px; width: min(260px, calc(100vw - 32px)); white-space: normal; z-index: 2147483647; pointer-events: none; line-height: 1.45; text-align: left; box-shadow: 0 12px 30px rgba(0,0,0,0.35); }
254
  .dataset-item .ds-tip::after { content: ''; position: absolute; bottom: 100%; left: 20px; border: 5px solid transparent; border-bottom-color: var(--tooltip-bg); }
255
  .dataset-item:hover { z-index: 99999; }
256
  .dataset-item:hover .ds-tip { display: block; }
 
259
  .instance-b .ds-time { color: var(--brand-b); }
260
 
261
  @media (max-width: 980px) {
262
+ .throughput-compare-viz .canvas-row { flex-direction: column; }
263
+ .throughput-compare-viz .canvas-row .side-panel { align-items: flex-start; }
264
+ .throughput-compare-viz .landmark .name { font-size: 9px; }
265
+ .throughput-compare-viz .bottom-strip {
266
  left: 6px;
267
  right: 6px;
268
  font-size: 10px;
269
  }
270
+ .throughput-compare-viz .output-num { font-size: 10px; }
271
+ .throughput-compare-viz .output-unit { font-size: 10px; }
272
+ .throughput-compare-viz .output-unit-emoji { font-size: 12px; }
273
+ .throughput-compare-viz .output-heading { font-size: 9px; }
274
+ .throughput-compare-viz .datasets { max-width: 100%; min-width: 0; }
275
+ .throughput-compare-viz .dataset-bars { flex-direction: row; flex-wrap: wrap; gap: 4px 12px; }
276
+ .throughput-compare-viz .dataset-item { font-size: 12px; }
277
+ }
278
+
279
+ @media (max-width: 640px) {
280
+ .throughput-compare-viz { overflow-x: hidden; }
281
+ .throughput-compare-viz .slider-area { margin-bottom: 10px; }
282
+ .throughput-compare-viz .datasets-title {
283
+ white-space: nowrap;
284
+ font-size: 9px;
285
+ letter-spacing: 0.35px;
286
+ }
287
+ .throughput-compare-viz .landmark .tick { height: 6px; }
288
+ .throughput-compare-viz .canvas-row .side-panel { width: 100%; }
289
+ .throughput-compare-viz .control-group { width: 100%; }
290
+ .throughput-compare-viz select { width: 100%; }
291
+ .throughput-compare-viz .landmark .name {
292
+ max-width: 68px;
293
+ overflow: hidden;
294
+ text-overflow: ellipsis;
295
+ font-size: 8px;
296
+ }
297
+ .throughput-compare-viz .bottom-strip {
298
+ position: absolute;
299
+ bottom: 4px;
300
+ left: 6px;
301
+ right: 6px;
302
+ margin-top: 0;
303
+ padding: 0;
304
+ justify-content: space-between;
305
+ flex-wrap: nowrap;
306
+ gap: 8px;
307
+ }
308
+ .throughput-compare-viz .throughput-strip {
309
+ flex: 1 1 auto;
310
+ text-align: left;
311
+ white-space: nowrap;
312
+ min-width: 0;
313
+ overflow: hidden;
314
+ text-overflow: ellipsis;
315
+ padding-right: 8px;
316
+ }
317
+ .throughput-compare-viz .output-panel {
318
+ flex: 0 0 auto;
319
+ justify-content: flex-end;
320
+ white-space: nowrap;
321
+ min-width: 0;
322
+ gap: 4px;
323
+ }
324
+ .throughput-compare-viz .output-heading { font-size: 8px; }
325
+ .throughput-compare-viz .output-num,
326
+ .throughput-compare-viz .output-unit { font-size: 9px; }
327
+ .throughput-compare-viz .output-unit-emoji { font-size: 11px; }
328
  }
329
  </style>
330
  </head>
331
  <body>
332
+ <div class="viz throughput-compare-viz">
333
  <div class="slider-area">
334
  <div class="gpu-label" data-role="gpuLabel">1 GPU</div>
335
  <div class="landmark-row top" data-role="row-a2"></div>
 
584
  applyModelDefault(modelASelect, defaultModelA);
585
  applyModelDefault(modelBSelect, defaultModelB);
586
 
587
+ datasetsTitleAEl.textContent = 'Time to generate dataset';
588
+ datasetsTitleBEl.textContent = 'Time to generate dataset';
589
+
590
  if (isCompareMode) {
 
 
591
  booksRateAEl.textContent = '0 pages/sec';
592
  booksRateBEl.textContent = '0 pages/sec';
593
  } else {
 
594
  booksRateAEl.textContent = '0 books/sec';
595
  }
596
 
597
  const themeTokens = {};
598
  function refreshThemeTokens() {
599
+ const styles = getComputedStyle(root);
600
  themeTokens.sliderStart = styles.getPropertyValue('--slider-start').trim();
601
  themeTokens.sliderMid = styles.getPropertyValue('--slider-mid').trim();
602
  themeTokens.sliderEnd = styles.getPropertyValue('--slider-end').trim();
 
771
 
772
  function resizeCanvas() {
773
  const w = canvas.clientWidth;
774
+ if (!w) return;
775
+ const aspectRatio = w <= 640 ? 0.42 : 0.28;
776
+ const h = Math.round(w * aspectRatio);
777
  canvas.width = w * 2;
778
+ canvas.height = h * 2;
779
+ canvas.style.height = h + 'px';
780
  }
781
  resizeCanvas();
782
+ if (window.ResizeObserver) {
783
+ const resizeObserver = new ResizeObserver(() => resizeCanvas());
784
+ if (canvas.parentElement) resizeObserver.observe(canvas.parentElement);
785
+ } else {
786
+ window.addEventListener('resize', resizeCanvas);
787
+ }
788
 
789
  let floatingItems = [], totalTokens = 0, spawnAccum = 0;
790
  let _fNow = 0, _fPps = 0, _fFanPhase = 0, _fBlinkSpeed = 0;