Closed Bug 2075818 Opened 22 hours ago Closed 19 hours ago

Support Cross-Origin Storage for reuse of Transformers.js model files across sites

Categories

(Core :: Storage: StorageManager, enhancement)

enhancement

Tracking

()

RESOLVED DUPLICATE of bug 2071521

People

(Reporter: nicolas.martin, Unassigned)

Details

I'm filing this on behalf of Hugging Face, as a maintainer of Transformers.js (https://github.com/huggingface/transformers.js). We would like to ask the Firefox team to consider implementing the proposed Cross-Origin Storage (COS) API (https://wicg.github.io/cross-origin-storage/).

Transformers.js lets web developers run machine learning models directly in the browser, using WebGPU and WebAssembly. By default, models are loaded from the Hugging Face Hub, but developers can host them on any origin, for example their own server, a CDN or a mirror. Model files (ONNX and safetensors) typically range from about 10 MB to several GB. Our WebAssembly runtime adds about 21 MB uncompressed.

The problem is that browser storage is scoped to each origin. Many independent sites load the exact same model files, for example the same speech recognition, embedding or small language model. A user who has already downloaded a 1 GB model on one site has to download and store it again on every other site that uses it. That wastes bandwidth and disk space. It also makes on-device AI much harder to use on mobile and metered connections, where these downloads matter most.

COS fits this well because it identifies files by content hash, not by URL or origin. The same model file is identical whether it comes from the Hugging Face Hub, a CDN or a developer's own server. With COS, sites could ask the browser for a file by its hash. If the browser already has it, the download is skipped. If not, the site downloads the file as usual. The Hub already provides the SHA-256 hash of every large model file (Git LFS), so the default path works without extra effort for developers. Developers hosting models elsewhere can compute the hash at build time. The files we want to share are public model weights and runtime binaries, not user data.

Transformers.js already includes experimental COS support. Developers turn it on with a single setting (env.experimental_useCrossOriginStorage = true). Once enabled, Transformers.js uses COS where the browser provides it and falls back to regular downloads and the Cache API everywhere else. No other code changes are needed: as soon as COS ships in a browser, users of those sites benefit right away. Because Transformers.js is used by a large number of sites, native support would have an immediate effect for many users.

We support designing this with privacy and security protections that hold under normal browser settings. We're happy to give feedback, test builds, or answer questions about how models are used in practice.

References:

Status: UNCONFIRMED → RESOLVED
Closed: 19 hours ago
Duplicate of bug: 2071521
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.