Spaces:
Running
Running
Add static deep-link benchmark route and release audit fixes
Browse files- .gitattributes +0 -2
- README.md +6 -3
- bench/index.html +0 -18
- src/app/styles.css +1 -1
- src/bench/route.test.ts +17 -0
- src/bench/route.ts +18 -0
- src/main.tsx +2 -6
- vite.config.ts +0 -8
.gitattributes
CHANGED
|
@@ -1,3 +1 @@
|
|
| 1 |
public/wasm/*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 2 |
-
dist/wasm/wllama-compat.wasm filter=lfs diff=lfs merge=lfs -text
|
| 3 |
-
dist/wasm/wllama.wasm filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 1 |
public/wasm/*.wasm filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
README.md
CHANGED
|
@@ -64,9 +64,12 @@ cross-origin-isolated WASM features.
|
|
| 64 |
|
| 65 |
## Growth benchmark
|
| 66 |
|
| 67 |
-
[`
|
| 68 |
-
separate, shareable benchmark surface
|
| 69 |
-
|
|
|
|
|
|
|
|
|
|
| 70 |
prefill/decode throughput, graph placement, device limits, engine revisions,
|
| 71 |
the exact runtime artifact hash, and a fixed temperature-0 prompt. The report
|
| 72 |
exports as JSON; generated model text is deliberately excluded.
|
|
|
|
| 64 |
|
| 65 |
## Growth benchmark
|
| 66 |
|
| 67 |
+
[`?view=bench`](https://wavecut-bonsai-webgpu-chat.static.hf.space/?view=bench)
|
| 68 |
+
is a separate, shareable benchmark surface rendered by the root static app.
|
| 69 |
+
Hugging Face Static Spaces serve one configured `app_file`, so the query
|
| 70 |
+
deep-link keeps the benchmark executable under the same COOP/COEP headers. It
|
| 71 |
+
loads nothing until **Run benchmark** is pressed, then records first-load and
|
| 72 |
+
verified-cache reload wall time, TTFT,
|
| 73 |
prefill/decode throughput, graph placement, device limits, engine revisions,
|
| 74 |
the exact runtime artifact hash, and a fixed temperature-0 prompt. The report
|
| 75 |
exports as JSON; generated model text is deliberately excluded.
|
bench/index.html
DELETED
|
@@ -1,18 +0,0 @@
|
|
| 1 |
-
<!doctype html>
|
| 2 |
-
<html lang="en">
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="UTF-8" />
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 6 |
-
<meta name="theme-color" content="#111512" />
|
| 7 |
-
<link rel="icon" href="data:," />
|
| 8 |
-
<meta
|
| 9 |
-
name="description"
|
| 10 |
-
content="Bonsai browser-local benchmark — repeatable cold load, warm load, prefill, and decode evidence."
|
| 11 |
-
/>
|
| 12 |
-
<title>Bonsai Growth Bench</title>
|
| 13 |
-
</head>
|
| 14 |
-
<body>
|
| 15 |
-
<div id="root"></div>
|
| 16 |
-
<script type="module" src="/src/main.tsx"></script>
|
| 17 |
-
</body>
|
| 18 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/app/styles.css
CHANGED
|
@@ -2156,7 +2156,7 @@ button:disabled {
|
|
| 2156 |
}
|
| 2157 |
}
|
| 2158 |
|
| 2159 |
-
/* Growth bench: a companion field instrument
|
| 2160 |
.bench-page {
|
| 2161 |
min-height: 100dvh;
|
| 2162 |
color: var(--ink);
|
|
|
|
| 2156 |
}
|
| 2157 |
}
|
| 2158 |
|
| 2159 |
+
/* Growth bench: a companion field instrument selected by the static Space deep-link. */
|
| 2160 |
.bench-page {
|
| 2161 |
min-height: 100dvh;
|
| 2162 |
color: var(--ink);
|
src/bench/route.test.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { describe, expect, it } from 'vitest';
|
| 2 |
+
import { isBenchRoute } from './route';
|
| 3 |
+
|
| 4 |
+
describe('isBenchRoute', () => {
|
| 5 |
+
it('uses the root app query deep-link required by static Spaces', () => {
|
| 6 |
+
expect(isBenchRoute({ pathname: '/', search: '?view=bench', hash: '' })).toBe(true);
|
| 7 |
+
});
|
| 8 |
+
|
| 9 |
+
it('keeps path and hash routes usable on hosts that support them', () => {
|
| 10 |
+
expect(isBenchRoute({ pathname: '/bench', search: '', hash: '' })).toBe(true);
|
| 11 |
+
expect(isBenchRoute({ pathname: '/', search: '', hash: '#/bench' })).toBe(true);
|
| 12 |
+
});
|
| 13 |
+
|
| 14 |
+
it('leaves the field station on the default root route', () => {
|
| 15 |
+
expect(isBenchRoute({ pathname: '/', search: '', hash: '' })).toBe(false);
|
| 16 |
+
});
|
| 17 |
+
});
|
src/bench/route.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export interface BenchRouteLocation {
|
| 2 |
+
pathname: string;
|
| 3 |
+
search: string;
|
| 4 |
+
hash: string;
|
| 5 |
+
}
|
| 6 |
+
|
| 7 |
+
export function isBenchRoute(location: BenchRouteLocation): boolean {
|
| 8 |
+
const pathname = location.pathname.replace(/\/+$/, '');
|
| 9 |
+
if (/(?:^|\/)bench(?:\/index\.html|\.html)?$/.test(pathname)) {
|
| 10 |
+
return true;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
if (new URLSearchParams(location.search).get('view') === 'bench') {
|
| 14 |
+
return true;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
return /^#\/?bench\/?$/.test(location.hash);
|
| 18 |
+
}
|
src/main.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import { StrictMode } from 'react';
|
|
| 2 |
import { createRoot } from 'react-dom/client';
|
| 3 |
import { App } from './app/App';
|
| 4 |
import { BenchApp } from './bench/BenchApp';
|
|
|
|
| 5 |
import './app/styles.css';
|
| 6 |
|
| 7 |
const root = document.getElementById('root');
|
|
@@ -10,13 +11,8 @@ if (!root) {
|
|
| 10 |
throw new Error('Bonsai shell root element is missing');
|
| 11 |
}
|
| 12 |
|
| 13 |
-
export function isBenchPath(pathname: string): boolean {
|
| 14 |
-
const normalized = pathname.replace(/\/+$/, '');
|
| 15 |
-
return /(?:^|\/)bench(?:\/index\.html|\.html)?$/.test(normalized);
|
| 16 |
-
}
|
| 17 |
-
|
| 18 |
createRoot(root).render(
|
| 19 |
<StrictMode>
|
| 20 |
-
{
|
| 21 |
</StrictMode>,
|
| 22 |
);
|
|
|
|
| 2 |
import { createRoot } from 'react-dom/client';
|
| 3 |
import { App } from './app/App';
|
| 4 |
import { BenchApp } from './bench/BenchApp';
|
| 5 |
+
import { isBenchRoute } from './bench/route';
|
| 6 |
import './app/styles.css';
|
| 7 |
|
| 8 |
const root = document.getElementById('root');
|
|
|
|
| 11 |
throw new Error('Bonsai shell root element is missing');
|
| 12 |
}
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
createRoot(root).render(
|
| 15 |
<StrictMode>
|
| 16 |
+
{isBenchRoute(window.location) ? <BenchApp /> : <App />}
|
| 17 |
</StrictMode>,
|
| 18 |
);
|
vite.config.ts
CHANGED
|
@@ -3,14 +3,6 @@ import react from '@vitejs/plugin-react';
|
|
| 3 |
|
| 4 |
export default defineConfig({
|
| 5 |
plugins: [react()],
|
| 6 |
-
build: {
|
| 7 |
-
rollupOptions: {
|
| 8 |
-
input: {
|
| 9 |
-
main: 'index.html',
|
| 10 |
-
bench: 'bench/index.html',
|
| 11 |
-
},
|
| 12 |
-
},
|
| 13 |
-
},
|
| 14 |
server: {
|
| 15 |
headers: {
|
| 16 |
'Cross-Origin-Embedder-Policy': 'require-corp',
|
|
|
|
| 3 |
|
| 4 |
export default defineConfig({
|
| 5 |
plugins: [react()],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
server: {
|
| 7 |
headers: {
|
| 8 |
'Cross-Origin-Embedder-Policy': 'require-corp',
|