Skip to content

0.16.0

Latest

Choose a tag to compare

@decitre decitre released this 30 Nov 00:41
· 2 commits to main since this release

The demos and the apps now run on an iPad, the camera app is about three times faster on a phone, and pipeline() takes an image_size for image tasks.

New

  • pipeline(..., image_size=480) resizes the shorter side of an image to that many pixels before inference, instead of the model's own size. DETR's is 800, so a 640 x 480 camera photo was scaled up to about 1067 x 800 first. On WASM, with the same objects found: 5.6 s to 2.1 s on the two-cats photo, and 5.3 s to 1.2 s on smaller photos; 320 took about a tenth of the time with slightly lower scores. Only models whose image processor resizes by the shorter side take it (DETR does; ViT, with a fixed height and width, raises an error naming image_size). It must be a positive integer. It reaches into Transformers.js's processor object, checked against 4.3.2 only. See #126 and #131.

Fixed

  • onnxruntime-web could not start on an iPad. It asks for a shared WebAssembly memory with a 4 GB maximum. On an iPad (A16, Safari) 1 GB was accepted and 2 GB refused, so every model failed with RangeError: Out of memory, whatever its size and whichever backend. The site builds (the demo and the apps) now patch the runtime to try 4, 2, 1 GB and 512 MB, and stop if onnxruntime-web changes the line. A package install that loads onnxruntime-web from jsDelivr is not patched. See #45 and #127.
  • A model that needs more than 1 GB to create its session failed with std::bad_alloc in that heap. DistilGPT-2 q8 (85 MB) needs more than 1 GB of heap with weight packing on and about 0.8 to 1 GB with it off, at the same speed. When the browser refuses a 2 GB shared memory, pipelines, Embedder, Classifier and OnnxModel now load with weight packing off. This applies to the jsDelivr copy too. A memory error no longer moves on to the next, larger dtype, which hid the first error. See #128.
  • Changed runtime files could be served from the browser cache for a long time. A browser kept the old onnxruntime-web for about an hour after a fix. The site build writes a hash of the vendored files, and lmlite.js puts it in every file's URL (?rev=...), with one small revalidating request per page load. It covers the files a site serves itself, not the jsDelivr copy. See #130.

Changed (the camera app, on the site, not in the package)

  • camera-objects loads DETR with image_size=480. On a Galaxy S20 FE on WASM, one photo took about 25.7 s at the default and 8.9 s in Chrome (9.4 s in Firefox) with it, on different scenes, one photo each, so that ratio is approximate. See #133.

What fits on an iPad

DistilGPT-2 on an iPad (A16, Safari): q8 on WASM, and fp16 and q4f16 (165 MB each) on WebGPU, load and generate; q4 (329 MB, as large as fp32) and fp32 (330 MB) fail with std::bad_alloc. A model file of about 300 MB does not fit in a 1 GB heap on either backend, so pass a dtype chosen by file size. This is one device and one Safari version, and the limit is reported to vary between devices, versions and reloads. Details in docs/MODELS.md.

Build and docs

  • A Hugging Face Static Space for the camera app (pilot, #86). VOICI_APPS=camera-objects builds the apps site with only the listed apps, and scripts/make-space.sh writes a Space folder with the COOP and COEP headers, which Hugging Face sends. On the live Space, in headless Chromium on a 12-core Mac, the camera app was cross-origin isolated and took 0.6 s per photo against about 1.9 s without the headers. The speech app is left out: its voice is non-commercial. The gain on a phone is not measured. See docs/DEVELOPMENT.md.
  • docs/RUNTIME.md has a section of what was seen on real devices and browsers (an iPad, a Galaxy S20 FE in Chrome and in Firefox, a Galaxy Tab S10 Lite, a Mac with Firefox, Chrome and Safari), from one owner's hand runs and mostly single runs. The swap to WASM when WebGPU fails to run was confirmed on Firefox 161 for macOS.

Notes

  • Not measured: other models and other iPads, fp16 and q4f16 on WASM, whether more memory raises the iPad's limit, image_size on a phone beyond the one photo above, and threaded WASM on a phone.
  • Still true: in Chrome on the S20 FE the first photo of each page load also tries WebGPU, which returns nothing, before falling back to WASM (about 28 s earlier). A run-time fallback in the library, and WebGPU as the default, are #114.
  • A phone is slow on WASM for large inputs: about 9 s per photo for DETR at 480.