Repository navigation
fix(ai): offer the open model only on a GPU with 16-bit floats - #14
Merged
Merged
Conversation
On a GPU without WebGPU's shader-f16, the app offered the 1 GB download, web-llm downloaded the whole model (881 MB stored in a test browser), then failed to build its shaders, and the app said "The model stopped before it finished. Try again." web-llm 0.2.85's record for Qwen2.5-1.5B leaves out required_features, so web-llm found out only after the weights. - detectLocalAi asks for the GPU web-llm uses (powerPreference "high-performance") and, if it lacks shader-f16, reports the model unavailable with a reason, before any download. - The pinned record adds required_features: ["shader-f16"], so web-llm itself stops before the weights (5 MB stored in the same browser) if it ever gets such a GPU. - localAiError shows that reason for web-llm's ShaderF16SupportError, and returns both unavailable reasons as they are: they name a GPU, so they read as running out of memory. prepareLocalAi throws the reason detection found. - README: the open model needs 16-bit float support. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017cSwEz3Q2o3DpuJ8qSQzY5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
I ran the on-device AI with the pinned model in the cloud, so Behrad could try it without using his own connection. It works. B3Note's own
localAi.tsdownloaded the model (869 MB) from the pinned commit, web-llm's hash checks passed, and Ask and Summarize both answered correctly.The same run found one bug, which this PR fixes. On a GPU without 16-bit float support, the app offered the 1 GB download, downloaded all of it, and then failed.
The bug
Qwen2.5-1.5B-Instruct-q4f16_1-MLChas norequired_features, though its library's shaders use 16-bit floats.shader-f16, web-llm downloads the config, the library, the tokenizer and all 30 weight shards first. Then it fails to build its shaders (GPUPipelineError; WGSL says "extension 'f16' is not allowed").detectLocalAionly checked that a GPU exists, so the app offered "About 1 GB, once".shader-f16, with the production CSP, the app offered the download. The failed load left 881 MB in the browser's storage.Changes
frontend/src/lib/localAi.ts:detectLocalAiasks for the GPU web-llm uses (powerPreference: "high-performance"). If that GPU lacksshader-f16, the status isunavailablewith a new reason,NO_F16_REASON, before any download.required_features: ["shader-f16"]. If web-llm ever gets such a GPU, it now stops before the weights.localAiErrorshowsNO_F16_REASONfor web-llm'sShaderF16SupportError.localAiErroralso returns both unavailable reasons as they are. They name a GPU, so they used to match "ran out of memory".prepareLocalAithrows the reason detection found.README.md: the open model needs a GPU with 16-bit float support.Verification
frontend/,pnpm format:check,pnpm typecheck,pnpm test(9 files, 60 tests) andpnpm buildpass.shader-f16check;required_features;prepareLocalAithrowing the generic reason;ShaderF16SupportErrorwith 5 MB stored, instead of 881 MB;shader-f16, detection still offers the download, and the model still loads with the new record. That GPU was Mesa's software Vulkan driver, through Dawn (Chrome's WebGPU engine), in Node, runninglocalAi.tsitself.us.aws.cdn.hf.co), and web-llm accepted all three hashes;Notes
Generated by Claude Code