Spaces:
Runtime error
Runtime error
Improve WebGPU setting
Browse files- bench/README.md +14 -0
- bench/src/web/cli.ts +22 -3
bench/README.md
CHANGED
|
@@ -105,6 +105,20 @@ bench/
|
|
| 105 |
βββ vite.config.ts
|
| 106 |
```
|
| 107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
## Output Format
|
| 109 |
|
| 110 |
All benchmarks output JSON with the following structure:
|
|
|
|
| 105 |
βββ vite.config.ts
|
| 106 |
```
|
| 107 |
|
| 108 |
+
## β οΈ Important: WebGPU Headless Limitations
|
| 109 |
+
|
| 110 |
+
**WebGPU performance in headless mode is significantly degraded** (~25Γ slower than headed mode on macOS). This is a known limitation of headless browsers:
|
| 111 |
+
|
| 112 |
+
- **Headless mode**: Uses software rendering, giving misleading results
|
| 113 |
+
- **Headed mode** (`--headed=true`): Uses actual GPU, reflects real performance
|
| 114 |
+
- **Interactive UI** (`npm run dev`): Best for accurate WebGPU benchmarks
|
| 115 |
+
|
| 116 |
+
**Recommendation**: For WebGPU benchmarks, always use `--headed=true` or test interactively in a browser.
|
| 117 |
+
|
| 118 |
+
See: [Chrome WebGPU Testing Guide](https://developer.chrome.com/blog/supercharge-web-ai-testing#enable-webgpu) | [Playwright GPU Issues](https://github.com/microsoft/playwright/issues/11627)
|
| 119 |
+
|
| 120 |
+
---
|
| 121 |
+
|
| 122 |
## Output Format
|
| 123 |
|
| 124 |
All benchmarks output JSON with the following structure:
|
bench/src/web/cli.ts
CHANGED
|
@@ -43,11 +43,30 @@ async function main() {
|
|
| 43 |
console.log(`Vite server started at ${url}`);
|
| 44 |
|
| 45 |
let browser: Browser;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
const launchOptions = {
|
| 47 |
headless: !headed,
|
| 48 |
-
args
|
| 49 |
-
? ["--disable-gpu", "--disable-software-rasterizer"]
|
| 50 |
-
: ["--enable-unsafe-webgpu", "--enable-features=Vulkan"]
|
| 51 |
};
|
| 52 |
|
| 53 |
switch (browserType) {
|
|
|
|
| 43 |
console.log(`Vite server started at ${url}`);
|
| 44 |
|
| 45 |
let browser: Browser;
|
| 46 |
+
|
| 47 |
+
// Build args based on mode
|
| 48 |
+
const args = device === "wasm"
|
| 49 |
+
? ["--disable-gpu", "--disable-software-rasterizer"]
|
| 50 |
+
: [
|
| 51 |
+
// Official WebGPU flags from Chrome team
|
| 52 |
+
// https://developer.chrome.com/blog/supercharge-web-ai-testing#enable-webgpu
|
| 53 |
+
"--enable-unsafe-webgpu",
|
| 54 |
+
"--enable-features=Vulkan",
|
| 55 |
+
];
|
| 56 |
+
|
| 57 |
+
// Add headless-specific flags only in headless mode
|
| 58 |
+
if (!headed && device !== "wasm") {
|
| 59 |
+
args.push(
|
| 60 |
+
"--no-sandbox",
|
| 61 |
+
"--headless=new",
|
| 62 |
+
"--use-angle=vulkan",
|
| 63 |
+
"--disable-vulkan-surface"
|
| 64 |
+
);
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
const launchOptions = {
|
| 68 |
headless: !headed,
|
| 69 |
+
args,
|
|
|
|
|
|
|
| 70 |
};
|
| 71 |
|
| 72 |
switch (browserType) {
|