Docs sites: build, check, publish#
Every family repository publishes its documentation site to its own subdomain of the
FTP host (Apache, one docroot per site) through one reusable workflow,
.github/workflows/build-docs.yml: build the site in the family image, add the hub’s
.htaccess, check every internal link, publish. The upload is
deploy-over-ftp.
The reusable workflow#
# .github/workflows/docs.yml in the repository
name: Docs · build + publish
permissions:
contents: read
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
workflow_dispatch:
jobs:
docs:
uses: Kataglyphis/ANTfrastructure/.github/workflows/build-docs.yml@develop
with:
builder: rustdoc
secrets:
FTP_SERVER: ${{ secrets.SERVER }}
FTP_USERNAME: ${{ secrets.USERNAME }}
FTP_PASSWORD: ${{ secrets.PW }}
The jobs:
sitebuilds the site in the family image (commandorbuilder) and clicks its sidebar toggles, or takes the artifact an earlier job of the run uploaded (artifact).docs-site.sh stagethen adds the.htaccessand 404 page and runs the link gate; the checked tree is uploaded asdocs-site-<site-name>, hidden files included. A newer commit on the same ref cancels this job.publishdownloads that tree and runsdeploy-over-ftp. It runs only on a push todevelopormain, or a dispatch there withpublish-on-dispatch: true; never on a pull request. Its concurrency group isdocs-publish-<site-name>, one per repository and site, withcancel-in-progress: false: a newer run waits, an upload is never cut off. It holds the only FTP secrets; the build never sees them.await-greenruns betweensiteandpublishwhenawait-green: true. The lanes run beside the docs workflow, so without it a red commit still goes live. Its script,linux/scripts/await-green-runs.sh, always comes from the hub’sdevelop; only the hub itself (hub-path: '.') runs its own commit’s copy. The script polls the Actions API once a minute. It waits for every other run that apushstarted atgithub.sha. It passes when each one endssuccess,skippedorneutral. Any other conclusion fails it and names the run. So does the timeout, and so do three failed reads in a row. A run re-run green later does not publish; the next push does. When the branch has moved on, the job passes but marks the commit superseded. Thenpublishskips, and the newer tip’s run publishes. It reads the runs withcontents: read. That works on a public repository only. A lane run only on request has no run when nobody asks for it.await-green-jobsnames jobs that must pass in one of those runs. A called workflow’s job is<caller job> / <job name>. Without one, the job passes withwithheld=true. Thenpublishskips and the site stays as it was. Suite:test-await-green-runs.sh.
There is no continue-on-error anywhere: a red link gate or a failed upload is a red job,
and the site keeps its last good deploy.
Image-backed site builds use the full runner disk cleanup before pulling the family image. The pull is serialized after cleanup so its layers do not consume the space being reclaimed; the caller’s selected submodule checkout, including a pinned theme, is unchanged.
Call it from a docs.yml of its own. A caller workflow with a cancelling
concurrency: (most linux-x64.ymls) cancels a publish half-way on the next push, and a
docs site published from inside a build or test job goes stale when a test is red or a
commit changes only docs. The hub’s own caller is .github/workflows/docs.yml.
Inputs#
Input |
Default |
Meaning |
|---|---|---|
|
|
Builds the site: |
|
|
A hub driver instead: |
|
|
|
|
|
A site an earlier job of the run uploaded; nothing is built |
|
|
The built site, relative to the repository root; required with |
|
|
Names the uploaded site and the publish group; a second site of the same repository needs its own |
|
|
The link gate’s allow file, relative to the repository root |
|
|
Add the hub’s |
|
|
Web apps below the site’s root, space-separated paths relative to it. Each gets the isolated-app |
|
|
The published site’s |
|
|
|
|
|
Also publish a |
|
|
Publish only once the commit’s other push runs are green. See |
|
|
How long |
|
|
With |
|
|
The publish job’s limit. An upload it cuts off saves no sync state, so a file too large to finish in time is retried from scratch on every run: BeschleunigerBallett’s 61 MB demo scene at about 74 kB/s never landed under 30 |
|
|
Remote directory; empty is the FTP login directory, every family site’s docroot |
|
|
|
|
|
Extra |
|
|
A hub checkout to take the drivers, the stager and the gate from; empty checks the hub out at |
|
|
Runner label |
Exactly one of command, builder and artifact; docs-site.sh plan refuses anything
else, and a site-dir or hub-path that is not a plain relative path.
Secrets#
The workflow takes FTP_SERVER, FTP_USERNAME and FTP_PASSWORD, the names
python-ci-linux.yml already used, and no other spelling. A caller maps its repository
secrets onto them in its secrets: block: most repositories store SERVER, USERNAME
and PW, WebDavClient PASSWORD, jotrockenmitlocken’s docs site DOC_WEBSITE_SERVER,
DOC_WEBSITE_USER and DOC_WEBSITE_PW. No repository secret has to be renamed. A publish
without them fails in its first step and names the missing ones. The
SERVER/USERNAME/PW secret inputs of the consumers’ own reusable-*.yml go away
with their deploy steps (below).
Moving a repository onto it#
What each repository changes, read 2026-10-19 from its develop. Each one seeds
link-allow from its first run’s findings (verify_site_links.py <site> --print-keys) or
fixes them.
Repository |
Today |
Change |
|---|---|---|
ANTfrastructure |
|
done: |
OrchestrANT, WebDavClient |
|
nothing: its new |
OxidANT |
|
a |
OmniAccelerANT |
|
a |
AccelerANTgine |
|
artifact mode: the deploy step becomes an |
BeschleunigerBallett |
|
artifact mode as AccelerANTgine: upload |
ANThology |
|
done (c3615ca): a |
jotrockenmitlocken |
|
a |
DocumANTation publishes to GitHub Pages and is not an FTP site.
The built-site link gate#
linux/scripts/verify_site_links.py <site dir> [--allow FILE] [--print-keys] reads a
built HTML tree offline and fails when an internal link or anchor resolves to nothing.
Stdlib only; it runs in the family image or on any Python 3.
SITE_LINK_JOBS (default one per CPU) is how many processes parse the pages; 1 parses in the
gate’s own process. The check then reads them in one fixed order, so the findings do not change.
What it checks, in every HTML document of the tree:
every
href,srcand meta-refresh target inside the site exists. A link to a directory needs that directory’sindex.html; an absolute path (/a.html) is served from the site root, because every family site is served at its domain root; a relative link that climbs above the root fails even when the build host has a file there. External links,mailto:and the like are not checked;every anchor names an
idor<a name>on its target page, as written or decoded (rustdoc writesimpl-From%3CT%3E-for-T).#topalways resolves, and a rustdoc source range (lib.rs.html#22-31) needs both ends;the root has an
index.html;no link is a Rust path (
super::Subscriber,crate::dispatcher#…). An intra-doc link rustdoc could not resolve keeps its text as thehref.urljoinwould readsuper::as a URL scheme and skip it as external. So the gate reports it asunresolved, one key per path. A scheme with one colon (tel:,urn:) is still a URL.
A <base href> moves the links of its page, as in a browser. A root-absolute one (/app/, as
Flutter’s --base-href writes it) names the site’s root, as an absolute link does. A file without
<!DOCTYPE html> or <html> is not a document: dartdoc’s *-sidebar.html
fragments are injected into other pages, so their links are relative to those.
Known exceptions go into an allow file, one key per line, # comments allowed.
The keys are what the gate prints: missing<TAB><path>,
anchor<TAB><page>#<fragment> and unresolved<TAB><link>, paths relative to the site root. It follows the
two-way rule of the allowlist contract:
a finding not frozen fails, and a frozen key that resolves now is STALE and fails.
--print-keys prints the current findings in that shape, to seed the file. A
missing allow file is a usage error (exit 2), not an empty freeze.
Measured 2026-10-19 in :latest:
Site |
Documents |
Findings |
|---|---|---|
this hub (Sphinx, DocumANTation 4866eae) |
94 |
3 dead anchors: two Markdown links to a directory in |
OxidANT rustdoc, all 11 crates ( |
517 |
20 |
ANThology through |
1070 |
0, once the builder copied |
Suite linux/scripts/tests/test-site-links.sh; the site-links.* mutations prove it.
Links into dependencies#
cargo_build_doc.sh documents with the pinned nightly: cargo +${RUST_NIGHTLY_TOOLCHAIN} doc -Zrustdoc-map. It maps crates.io dependencies to docs.rs. A stable cargo doc --no-deps writes
no page for a dependency. Rustdoc then cannot resolve a link into one, and keeps its text as the
href. That text arrives through the blanket impls rustdoc copies onto every type page. tracing’s
WithSubscriber and Instrument link dispatcher#…, super::Subscriber and crate::Span.
burn’s Module links ModuleMapper. With the map, each goes to the dependency’s page on docs.rs.
The pin is
RUST_NIGHTLY_TOOLCHAINinversions.env. The image already carries it for the web lane, and a non-empty environment value wins. A host without it fails with therustup toolchain installline to run.The gate does not check docs.rs links: they are external.
--extern-html-root-urldoes the same per crate. Stable rustdoc refuses it without-Z unstable-options.Documenting a dependency beside the workspace (
-p tracing) does not help. The workspace’s own pages still carry the raw text. Onlycargo docwithout--no-depsresolves it locally. For OxidANT that documents every crate it depends on.
Measured in WSL against OxidANT’s develop, on 18 of its 20 crates. The two that need GTK were left
out. Stable --no-deps gives 69 findings: 63 missing and 6 unresolved. The nightly with the
map gives none of them. The builds took 45 s and 48 s, with no rustdoc warning either way. Suite
linux/scripts/tests/test-cargo-build-doc.sh; the rust.cargo-doc-* mutations prove it.
Proving a WebGPU page#
In the image’s headless Chrome 155 a WebGPU canvas screenshots white even when the page renders it (CON128). Read the frame back instead:
node linux/scripts/webgpu-canvas-readback.js <URL | page.html> [--min-colours N] [--wait-ms N] [--screenshot FILE]
Chrome runs WebGPU on SwiftShader (
--enable-unsafe-webgpu --enable-features=Vulkan --use-angle=swiftshader --use-webgpu-adapter=swiftshader): the image has no GPU. A consumer driving its own page takes them fromrequire('webgpu-canvas-readback.js').WEBGPU_FLAGS(frozen) forcheck-docs-sidebars.js’slaunch(chrome, WEBGPU_FLAGS), withinstallfor the read-back. A traced frame can hold the page past 30 s.An init script (
Page.addScriptToEvaluateOnNewDocument) addsCOPY_SRCto the canvas’sconfigure()usage and keeps the texturegetCurrentTexture()hands out. After--wait-ms(3000) it copies the next frame out after that frame’s lastsubmit()(copyTextureToBuffer, rows padded to 256 bytes, thenmapAsync).It prints size, format and distinct colours and paints the frame into a 2D canvas over the WebGPU one, so
--screenshotshows it. Exit 1 on fewer than--min-colours(2: a cleared canvas has one), no frame in 10 s, or a format other than 8-bit RGBA/BGRA; 2 on a usage error or no Chrome.
BeschleunigerBallett’s published demo (/webgpu-demo/index.html), 2026-10-20: 3575 colours for
the proof of run 39440853860, 3124 from this tool at --wait-ms 8000, both 1280x743 rgba8unorm;
its plain screenshot was white.
Suite linux/scripts/tests/test-webgpu-canvas-readback.sh (the read-back against fakes of the
WebGPU API, the exported flags, a page with no frame in Chrome); the docs-site.webgpu-readback-* mutations prove it.
The site’s .htaccess#
linux/webserver/templates/docs-site.htaccess goes into every docs site’s root, with
docs-site-404.html as 404.html when the build wrote none:
Directive |
Why |
|---|---|
|
plain http answered 200 on every family site; the second condition stops a loop behind a proxy that ends TLS |
|
HSTS for a year, this subdomain only |
|
no content sniffing |
|
the FTP library’s state file lists every published file with its hash, and it was served |
|
|
|
the host gzips text itself but serves these whole: BeschleunigerBallett’s demo is a 7 MB wasm and a 61 MB |
|
a dead link shows a page with a way back, not Apache’s default |
Every directive is in Apache’s FileInfo override class, and the suite fails on any
other. That class is what the host is proven to allow: jonasheinle.de, on the same
address as every docs site, serves exactly the headers of jotrockenmitlocken’s deployed
web/.htaccess (Header, AddType, and AddOutputFilterByType DEFLATE, which gzips its
.wasm). A directive the host’s AllowOverride does not grant (Options, Require,
Order) would make every page a 500, so the state file is denied by RedirectMatch
rather than Require all denied. Each block sits in <IfModule>: a missing module drops
its rules instead of failing the site.
The server, read 2026-10-19 with curl -sI: containerization.jonasheinle.de and the
other eight FTP sites answer Server: Apache from 85.13.169.97; http:// answers 200
with no redirect; /.ftp-deploy-sync-state.json answers 200; an unknown page gets
Apache’s default 404; /.htaccess answers 403, so the server config denies .ht*
files itself. Read 2026-11-15: HTML, CSS and JavaScript come back
Content-Encoding: gzip without any .htaccess rule, and
beschleunigerballette.jonasheinle.de sent its demo’s .wasm as application/wasm but
uncompressed, so the template compresses the binary types only.
The family image carries no httpd, so the directives are checked by
linux/scripts/tests/test-docs-site-htaccess.sh (each directive, the <IfModule> guards
around the types and the filter, the state-file regex against sample paths, the 404 page
through the link gate) and by curl -sI after the first publish, not by a server in a
container. The docs-site.* mutations prove the suite.
An isolated app’s .htaccess#
A web app that needs crossOriginIsolated gets linux/webserver/templates/flutter-web-isolated.htaccess
as the .htaccess of its own directory. On a docs site, name the app’s directory in isolated-apps, and
the stager copies the template there before the link gate runs. Wasm threads, SharedArrayBuffer and ORT Web’s threaded builds
need isolation. OmniAccelerANT’s /app/ takes this template below its docs site’s root. The root keeps
docs-site.htaccess, and jotrockenmitlocken keeps flutter-web.htaccess.
Directive |
Why |
|---|---|
|
one of the two headers that isolate the page |
|
the other one; Safari has no |
|
|
|
the browser refuses a wasm or a module script served under another type |
|
|
|
only |
The HTTPS redirect, HSTS, |
the root’s rules again, so the file also works at a docroot |
The FileInfo rule of the root’s file holds here too, with the same <IfModule> guards. SetEnvIf is in
FileInfo. <If> is not: it needs AllowOverride All, so the versioned paths are matched by SetEnvIf.
Apache merges Header and AddType from the root’s file into a subdirectory’s. Rewrite rules do not
merge: a subdirectory file with its own RewriteRule replaces the root’s, so the template repeats the
redirect.
Under COEP require-corp the page loads nothing from another origin that sends no CORS or CORP header.
Build a Flutter app with --no-web-resources-cdn, so CanvasKit comes from the app’s own origin.
Suite linux/scripts/tests/test-flutter-web-isolated-htaccess.sh checks each directive, the guards, the
order of the two cache lines and the versioned-path patterns against sample paths. The
docs-site.isolated-* mutations prove it. After a publish, check-live-site.js <app URL> --isolated
checks the headers and crossOriginIsolated in Chrome:
ftp-deploys.md § The live-site check.
build-docs.yml runs that check itself when the caller passes live-url. Its live-check job needs the
publish, so it never runs on a pull request. It pulls the family image for node and Chrome, takes the published
site, and runs docs-site.sh live. That checks every app, also after a red one, and fails if any is red. It refuses a
plain-http address, an empty app list and an app path outside the site. An app published with
models/manifest.json also gets --models, which downloads each mirrored file and
compares its bytes.
Staging ORT Web for an app#
An app that runs ONNX Runtime in the browser ships the image’s own ORT Web builds. Stage them in the family image, in an amd64 job, before the link gate:
python3 -I linux/scripts/lib/stage-ort-web.py --out <site>/app [--jsep] [--no-js-bundles | --js-dir DIR]
It reads /usr/local/lib/onnxruntime-web (--source changes it) and writes ort/ below --out:
One directory per build,
ort/<version>-<build hash>/, in the order JSPI, Asyncify, CPU.--jsepadds JSEP last. The build hash is the first 16 hex digits of a SHA-256 over the build’s file hashes, so new bytes get a new path. The isolated-app.htaccessmarks only such a path immutable.Each directory holds the build’s
.wasm, its loader.mjs, itsort.*.mjsbundles, ORT’sLICENSEandThirdPartyNotices.txtand the probe’sort-webgpu-factory-probe.LICENSE. A*.bak, a source map or another build’s bundle never ships.ort/manifest.jsonlists each build with its path, its build hash, every file with role, SHA-256 and size, and its receipt: the configured flags, the CMake cache hash and the factory probe’s runtime receipt. It also names the ORT version, ref and revision, the image receipt’s hash and where the license texts came from.ort/manifest.jsonitself keeps its name, so the app revalidates it.
Build |
Files |
Bundles |
|---|---|---|
JSPI |
|
|
Asyncify |
|
|
CPU |
|
|
JSEP |
|
|
It refuses rather than ships fewer builds or other bytes. Exit 1, and no ort/ is written, when:
A requested build’s
.wasmor loader is missing, or its bundle is (pass--no-js-bundleswhere no bundle can exist: the image builds them on amd64 only).--js-dir DIRtakes every bundle fromDIR. On arm64 that is the npm package’s JS of the same ORT version.A JSPI or Asyncify build has no flavor in
ort-webgpu-wasm.json, or its bytes, its probe license or its runtime receipt differ from the receipt, or that runtime receipt records a failed probe.ORT’s license texts are neither beside the web output nor in an installed wheel of the receipt’s ORT version, or a wheel’s text differs from its
RECORD.--site-packagesnames the wheel’s directory; the default is the single/opt/venvone.<out>/ortalready exists.
The hashes of a build with a receipt come from the receipt, and the stager checks the bytes against them.
The image writes no receipt for CPU and JSEP, so their manifest entry says "receipt": null and every
hash there is of the bytes ("hash_from": "bytes").
Suite linux/scripts/tests/test-stage-ort-web.sh covers the order, the file lists, the hashes, the
license sources and every refusal over fixture outputs. The docs-site.ort-web-* mutations prove it.
Mirroring an app’s models#
GitHub release downloads send no CORS header. So an app loads its models from its own origin, mirrored from the data locks. The site’s build command runs the mirror in the family image, after the app’s build and before anything that lists the app’s files, such as a license inventory:
python3 -I linux/scripts/lib/mirror-app-models.py --out <site>/<app> [--model <lock> <file>]... \
[--genai <lock> <archive> <name>]... [--root DIR] [--cache DIR]
Each lock is a data lock of sha256 file url rows (the hub’s fetcher).
OmniAccelerANT’s build-docs-site.sh mirrors DEIM-D-FINE-N from OxidANT’s models.lock into doc/api/app.
The mirror fetches each model with its <name>.LICENSE and <name>.NOTICE through fetch-data-lock.py. That
checks every file by its SHA-256 and keeps a cache. The mirror then writes models/ below the app by one rename:
Every file lands at
models/<its sha256>/<file>, each license text under its own hash. The isolated-app.htaccessmarks only such a path immutable, so new bytes get a new URL.models/manifest.jsonkeeps its name, so the app revalidates it.--genaitakes a GenAI model directory archive and the model’s name. The lock must hold<name>.LICENSEand<name>.NOTICE, as ModelANT releases them. The mirror checks the archive by its SHA-256. The fetcher’s own extraction unpacks it. Each file lands atmodels/<archive sha256>/<directory>/<file>. So the graph andmodel.onnx.datastay side by side. The archive is not published.
It exits 1 and leaves the app as the build wrote it when:
A file is not in its lock, or its bytes differ from the lock’s SHA-256.
The lock has no
<name>.LICENSEor no<name>.NOTICEfor the model. ModelANT releases both with every model.A
--modelis an archive: the browser fetches single files. A--genaiis no archive, unpacks to a subdirectory, a link or nogenai_config.json.<app>/modelsexists or the app’s directory does not.A model is named twice, or a lock lies outside
--root. The default root is the working directory, wherebuild-docs.ymlruns the build command: the repository root.
The web manifest#
{
"schema_version": 1,
"models": [
{
"name": "deim_dfine_n_coco",
"file": "deim_dfine_n_coco.onnx",
"path": "models/<sha256>/deim_dfine_n_coco.onnx",
"sha256": "<sha256>",
"size": 15540167,
"lock": {
"path": "third_party/OxidANT/resources/models/models.lock",
"line": 4,
"url": "https://github.com/Kataglyphis/ModelANT/releases/download/deim_dfine_n_coco-v2/deim_dfine_n_coco.onnx"
},
"release": {"repository": "Kataglyphis/ModelANT", "tag": "deim_dfine_n_coco-v2"},
"licenses": [
{"file": "deim_dfine_n_coco.LICENSE", "path": "models/<sha256>/deim_dfine_n_coco.LICENSE",
"sha256": "<sha256>", "size": 11564, "lock": {"path": "...", "line": 5, "url": "..."}},
{"file": "deim_dfine_n_coco.NOTICE", "path": "models/<sha256>/deim_dfine_n_coco.NOTICE",
"sha256": "<sha256>", "size": 1155, "lock": {"path": "...", "line": 6, "url": "..."}}
]
}
]
}
Field |
Meaning |
|---|---|
|
|
|
One entry per model, in the order of the |
|
The file name without its last suffix, or the |
|
|
|
The file name in the lock |
|
|
|
The file’s or the archive’s bytes, as the lock pins them |
|
|
|
The row the file came from: the lock’s path in the repository, its line and its URL |
|
The GitHub release the URL names, or |
|
The model’s license texts, each with |
A browser reads it in three steps:
Fetch
models/manifest.json, then each model at itspath.Check the size and the SHA-256 of the bytes with
crypto.subtle.digestbefore ORT sees them. A missing file can come back as a page with status 200, from a host’s catch-all rule or a service worker.Cache the bytes by their hash. A hash the cache holds needs no download.
After each publish, the live-check job finds the manifest in the published tree and passes it to
check-live-site.js --models. That downloads every file the manifest names and fails on another status, size or
hash: ftp-deploys.md § The live-site check.
Suite linux/scripts/tests/test-mirror-app-models.sh covers the tree, the manifest and every refusal over file://
locks and a seeded cache. The docs-site.app-models-* mutations prove it; docs-site.live-models and the
live-site.models-* mutations prove the live check.
Detector parity of the ORT Web builds#
An app ships a staged build only if it detects what native ORT detects. Run the check in the family image after staging:
python3 -I shared/python/ort_web_parity.py --site <site>/app --model deim_dfine_n_coco.onnx \
--image two_cats.jpg --out <report dir> [--jsep] [--build NAME]... [--js-dir DIR]
The model is ModelANT’s deim_dfine_n_coco-v2 and the photo its contracts/fixtures/two_cats.jpg. Both are
checked by SHA-256. linux/scripts/ort-web-parity-ci.sh <report dir> [--jsep] stages the image’s builds,
fetches both through linux/scripts/lib/ort-web-parity.lock and runs the check.
How it runs:
The photo becomes one input tensor, stretched to 640x640 by nearest neighbour as OxidANT’s
vision_coredoes it. Native ORT and every build get the same bytes, so the report compares ORT builds, not decoders.Native ORT runs that tensor on
CPUExecutionProvider. Its result must pass the comparator’s two-cats baseline.linux/scripts/ort-web-detector-parity.jsserves the site with COOP and COEP and drives headless Chrome. JSPI, Asyncify and JSEP run thewebgpuprovider on SwiftShader’s WebGPU. CPU runs thewasmprovider with--disable-gpu.The page imports the build’s own
ort.*.min.mjswithwasmPathsat the build’s directory. It runs one session twice.
A build gets "verdict": "ship" when all four hold, else "refuse" with its reasons:
Its first run matches the native run within
compare_detector_parity.py’s tolerances: the same count and classes, IoU 0.90 or more, scores within 0.05.Its second run matches its first.
Each run finds at least two cats at 0.4 or more.
ORT placed nodes on the build’s provider:
WebGpuExecutionProvider,JsExecutionProviderorCPUExecutionProvider. ORT moves a node it cannot run to the CPU without a word.
The node counts come from the session’s verbose log, because no profile file leaves the wasm.
verify_ort_profile.py LOG.json --device webgpu --placements applies the same rule to a JSON list of log
lines and prints each provider’s share.
It exits 1 and writes no report when a requested build is not staged, a staged file differs from the manifest, the model or the photo is another, or the report directory exists.
<report dir>/<build>.json holds the verdict, the reasons and the tolerances. It also holds the worst IoU and
score difference measured, the cats per run, the nodes and shares per provider, the operators placed elsewhere,
the Chrome version, the adapter and the times. summary.json lists the verdicts. Each run’s detections sit
beside them in the comparator’s format, and <build>-page.json keeps the page’s answer with ORT’s whole log.
"decides": true only when the page loaded the build’s own bundle. The arm64 image has none, so --js-dir can
name the ort.*.mjs of the npm package of the same ORT version. Such a report proves the build’s wasm and
loader, and decides nothing.
Workflow ort-web-parity.yml runs ort-web-parity-ci.sh in the amd64 image on a push to its files, on
Mondays and on dispatch, which can add --jsep. It uploads the reports as ort-web-parity, and they decide
which builds ship.
On a Pi 5 in the arm64 image, Chrome 157 on SwiftShader with two threads, against the npm package’s JS of ORT 1.31.1. These reports decide nothing:
Build |
Verdict |
Worst IoU, score difference |
Nodes on its provider |
Session, first run, repeat |
|---|---|---|---|---|
JSPI |
refuse |
none: the first run failed |
727 of 737 |
10.6 s, failed |
Asyncify |
ship |
0.999999, 0.00003 |
727 of 737 |
12.7 s, 219 s, 19 s |
CPU |
ship |
0.999999, 0.00002 |
717 of 717 |
1.8 s, 0.9 s, 0.5 s |
JSEP |
refuse |
none: the first run failed |
760 of 773 |
5.0 s, failed |
JSPI stopped in a
Conv2dMMwithNo cached or pending pipeline for deferred dispatch. Three other runs of the JSPI build passed with Asyncify’s numbers in about 210 s and 19 s. The failure is intermittent, so JSPI waits for the amd64 reports.JSEP stopped at a
MaxPoolwithceil_mode, which its WebGPU kernel does not implement, and it putTopKon the CPU. JSEP is no fallback for DEIM.On the WebGPU builds the ten CPU nodes are shape arithmetic:
Unsqueeze,Tile,Div,Mul,SubandCast.GridSample,GatherElementsandTopKran on WebGPU.The first WebGPU run compiles every shader on SwiftShader, so the repeat takes a tenth of its time.
The deciding reports come from the amd64 image’s own bundles, dispatch run 46103260764 on b224ed00 with
Chrome 157 on SwiftShader:
Build |
Verdict |
Worst IoU, score difference |
Nodes on its provider |
Session, first run, repeat |
|---|---|---|---|---|
JSPI |
ship |
0.999999, 0.000008 |
727 of 737 |
2.2 s, 38 s, 27 s |
Asyncify |
ship |
0.999999, 0.000008 |
727 of 737 |
2.5 s, 35 s, 27 s |
CPU |
ship |
0.999999, 0.00001 |
717 of 717 |
0.9 s, 0.3 s, 0.2 s |
JSEP |
refuse |
none: the first run failed |
760 of 773 |
failed |
JSPI passed both runs on amd64; the Pi’s
Conv2dMMfailure did not show.JSEP failed at the same
MaxPoolwithceil_mode. It runs only on request and never ships, so its report informs and the three shipping builds decide the job’s exit. A run of JSEP alone still fails on its refusal.
Suite linux/scripts/tests/test-ort-web-parity.sh covers the verdicts, the tolerance edges, the cat rule, every
refusal and the report’s shape over fixture builds, and the page and its server against a fake ORT module. The
docs-site.ort-web-parity-*, docs-site.ort-web-harness-* and packaging.ort-profile-* mutations prove it.
Loading ORT Web in an app#
shared/web/javascript/ort-web-loader.mjs picks the staged build a browser can run and loads that build’s files
only. A consumer copies it into web/javascript/ (shared asset web-ort-loader-mjs) and imports it in the worker
that runs ORT:
import { createSession, loadOrtWeb, planOrtWeb } from '../javascript/ort-web-loader.mjs';
const base = new URL('../', import.meta.url); // the directory that holds ort/
const { provenance } = await planOrtWeb({ base }); // the choice, from ort/manifest.json alone
const loaded = await loadOrtWeb({ base }); // { ort, provenance, executionProviders }
const session = await createSession(loaded, modelBytes);
The choice, first match wins:
Build |
When |
|
|---|---|---|
any |
the caller passes |
|
CPU |
|
|
CPU |
no |
|
CPU |
|
|
JSPI |
|
|
Asyncify |
JSPI is missing |
|
planOrtWebreads<base>/ort/manifest.jsonand fetches nothing of the build. Its provenance has"verified": falseand"ort_web": null.loadOrtWebfetches the build’s bundle, loader and wasm. It checks each SHA-256 against the manifest withcrypto.subtle. Then it imports the bundle.env.wasm.wasmPathsgets that build’s{ mjs, wasm }, andenv.wasm.wasmBinarythe checked bytes. So no other build’s loader or wasm can load. The bundle isort.<prefix>.min.mjs, else.mjs, else.bundle.min.mjs, as in the parity check.Threads: ORT’s own default,
min(4, ceil(cores / 2)), whencrossOriginIsolated; one otherwise, with"threads_note": "not-isolated".createSession(loaded, model)creates the session with ORT’s verbose log. It counts the placement lines intoprovenance.session:placements,nodes,on_provider,shareandproven. ORT moves a node it cannot run to the CPU without a word. So the requested provider proves nothing. ORT’s glue bindsconsole.logandconsole.erroronce, when it loads. SoloadOrtWebtaps the console before the import. Sessions are created one at a time, so each count is its own.
It refuses with an OrtWebLoadError. Its code says why. Its provenance holds the choice made so far:
|
When |
|---|---|
|
|
|
not a schema 1 manifest, a path other than |
|
the chosen build or its bundle is missing (the image builds bundles on amd64 only) |
|
a file does not answer 200, or its bytes are not the manifest’s: a missing file can come back as |
|
no |
|
the bundle’s |
The provenance is plain JSON:
build,provider(webgpuorwasm),reason,reason_text.build_hash,path,ort_version,ort_revision,ort_web.files:bundle,loaderandwasm, each withfile,sha256andsize.verified,threads,threads_note.capabilities:secure_context,cross_origin_isolated,jspi,webgpu,adapter_error,hardware_concurrency, andadapterwithvendor,architecture,device,description,is_fallback.manifest:url,image_receipt_sha256.session, aftercreateSession.
linux/scripts/ort-web-loader-check.js runs it in the image’s headless Chrome under one browser condition:
node linux/scripts/ort-web-loader-check.js --site <app dir> --case <case> --out <report.json> \
[--in page|worker | --worker <app-relative worker> [--build NAME] [--image FILE | --camera FILE] [--threshold T]] [--fake-ort] \
[--model FILE --input-dims 1,3,640,640 --runs N]
|
Chrome |
The page |
|---|---|---|
|
SwiftShader’s WebGPU |
isolated |
|
SwiftShader’s WebGPU; |
isolated |
|
|
isolated |
|
SwiftShader, |
isolated |
|
SwiftShader; the page opens at |
not a secure context |
|
SwiftShader’s WebGPU |
without COOP and COEP |
--in page(default) orworkerruns the loader in the page or in a module worker.--modelthen creates a session and runs it on a zero tensor.--worker RELruns the app’s own worker below--siteinstead. It is sent{"id": 1, "op": "plan"}, then{"id": 2, "op": "load"}, as JSON strings, and answers each with{"id", "ok", "provenance", "error": {"code", "message"}}. OmniAccelerANT’sweb/inference/inference_worker.mjsspeaks it.--build NAMEputs"build"into each request.--image FILEthen sends{"id": 3, "op": "detect", "threshold"}as{request, image}, the file’s bytes transferred as anArrayBuffer;--thresholddefaults to 0.25, the comparator’s lowest score.--camera FILEmakes FILE (.y4mor.mjpeg) Chrome’s only camera. The page opens it withgetUserMedia, grabs one frame of the playing video as anImageBitmap, and sends{"id": 3, "op": "detectFrame"}as{request, frame}, the frame transferred. That is the path a webcam page takes.--fake-ortserves a stand-inort/: each build’s files with their real hashes, each bundle a fake ORT module. It proves the choice and the checks without ORT, also on arm64, where the image has no bundles.
On a Pi 5 in the arm64 image, Chrome 157 on SwiftShader, with ORT 1.31.1’s staged wasm and the npm package’s bundles of the same version. The image builds no bundle there, so this proves the loader and decides nothing about the shipped bundles. Each case chose the same in the page, in a worker and through OmniAccelerANT’s worker:
|
Build, |
Load |
Nodes on its provider |
DEIM, first run and repeat |
|---|---|---|---|---|
|
JSPI, |
checked, 2 threads |
727 of 737 |
209 s, 21 s in a worker |
|
Asyncify, |
checked, 2 threads |
727 of 737 |
a session only |
|
CPU, |
checked, 2 threads |
717 of 717 |
0.9 s, 0.5 s in a worker |
|
CPU, |
checked, 2 threads |
717 of 717 |
0.9 s in the page |
|
CPU, |
refused: |
none |
none |
|
JSPI, |
checked, 1 thread |
727 of 737 |
a session only |
No flag of Chrome 157 turns JSPI off or removes navigator.gpu: --js-flags=--no-experimental-wasm-jspi,
--js-flags=--no-wasm-jspi, --disable-features=WebAssemblyJSPromiseIntegration, --disable-features=WebGPU and
--disable-webgpu all left them in place. So asyncify and no-webgpu delete WebAssembly.Suspending or
navigator.gpu where the loader runs; around an app’s worker, a wrapper module deletes them, imports the worker and
hands it the messages sent meanwhile. A page without isolation still creates shared wasm memory, so the threaded
builds load there on one thread.
Suite linux/scripts/tests/test-ort-web-loader.sh covers the choice, the probe, the threads, the manifest
reading, the plan, the load with each build’s own files, every refusal and the session placements in node against
fakes, and the check’s arguments, stand-in and server. The docs-site.ort-web-loader-* mutations prove it.
test-ort-web-loader-chrome.sh runs each case in Chrome, in the page and in a worker, against --fake-ort.
Generating text with ORT Web#
GenAI has no web build. So the browser runs the decoder of a GenAI model directory on ORT Web, with
shared/web/javascript/ort-web-generate.mjs. Its shared asset is web-ort-generate-mjs. It runs in the worker
that loaded ORT:
import { decoderSpec, generate, sessionOptions } from '../javascript/ort-web-generate.mjs';
const spec = decoderSpec(genaiConfig); // genai_config.json: tensor names, cache shape, context, end tokens
const session = await createSession(loaded, modelBytes, { options: sessionOptions(spec, loaded.provenance.provider) });
const result = await generate({ ort: loaded.ort, session, spec, promptIds, options: { max_new_tokens: 8 },
onToken: (id) => postMessage({ token: id }), decode, signal });
The prompt goes in one run. Then each run adds one token.
Each run’s
present.*outputs are the next run’spast_key_values.*, the same tensors. The first past is empty.On WebGPU,
sessionOptionskeeps thepresent.*outputs on the GPU (preferredOutputLocation: 'gpu-buffer'). Each replaced past is disposed. On the CPU build ORT’s outputs stay where ORT puts them.The attention mask spans the past and the new tokens.
position_idsgo in only where the decoder has them.Temperature 0, the default, is greedy: the highest logit wins, and a tie keeps the lowest id, as GenAI’s top-1 does. It ignores
top_p,top_kandseed.Above 0, it samples. The logits are divided by the temperature.
top_kkeeps the k highest (default 50, 0 keeps all).top_pkeeps the fewest of them whose probability reaches it (default 1). Then a seeded draw picks one. The PRNG is mulberry32, so one seed gives the same ids in every browser. Without a seed it draws one.An end token from
eos_token_idor an id instop_token_idsis kept and ends the answer withstop.A stop string needs
decode, the tokenizer’s ids-to-text. After each token the text is decoded. At a stop string the answer ends withstop, andtextends before it. The budget ends it withlength, an abortedsignalwithcancelled.max_millis, an agent’s time left, ends it withlengthafter the current token.The result holds
ids,text(null withoutdecode),finish_reason, the token counts,time_to_first_token_ms,decode_tokens_per_sandrun_ms, the time insidesession.run.It takes token ids. The tokenizer and the chat template live elsewhere.
A
guideholds the answer to a schema. It compiles the schema to a constraint. Before each draw the constraint’s mask names the allowed ids, one bit per id as llguidance lays them out, and every other logit drops out. Then the constraint takes the drawn id. OxidANT’s text_web crate gives the llguidance guide GenAI uses.
It refuses before any run. The TextGenerationError’s code is the error name of the
text contract:
|
When |
|---|---|
|
no prompt ids; a budget that is no positive integer; a negative or not finite temperature; a |
|
a schema that is a JSON object, and no |
|
the guide refused the schema, or its mask allows no token |
|
a stop string without |
|
the prompt and the budget exceed |
|
the config lacks the layers, head size, context length or an end token |
ort-web-loader-check.js --generate DIR replays DIR’s fixture.json in Chrome, through the loader. It runs each
case whose messages are the fixture’s prompt, with the fixture’s prompt_ids. Other cases are skipped, since their
ids need the tokenizer. Weights in model.onnx.data beside the graph go to ORT as external data. --threads N
asks the loader for N threads. It takes no --model, --worker or --fake-ort.
--chat FILE replays through a consumer’s chat layer: a module whose load() gives a generate() over messages,
tools and options, with its own tokenizer, template and guide. Then every case runs, and the tool cases too.
lib/ort-web-fixture-verdict.js grades the report in one line. With a chat module a schema decodes, and each tool
case’s calls must match by name and by their arguments as JSON values.
The suites:
linux/scripts/tests/test-ort-web-generate.shruns the loop and the replay in node against a fake decoder.test-genai-contract-fixture.shcoverslinux/scripts/lib/genai-contract-fixture.pyagainst a stand-in GenAI, and the released-model gate.ort-web-generate-chrome-check.shstages the image’s ORT Web and runs the native check,tiny-genai-model.py --check. Then it decodes the tiny model’s fixture on the CPU build, in a worker and in the page. Each case answers as the fixture says. Only a schema object differs: it answersjson_schema_unsupported. Then a stand-in chat module, whose guide knows only a one-value enum, decodes the schema case to its one answer through the mask. It needs the image, so it is notest-*.sh:run-tests.shwould run it on the bare preflight runner.ort-web-generate-ci.shruns it in the parity workflow.The
docs-site.ort-web-generate-*,docs-site.ort-web-llm-gate-*anddocs-site.genai-contract-fixture-*mutations prove them.
The arm64 image has no ort.*.mjs bundles. There ORT_WEB_JS_DIR may name the npm package’s JS of the same ORT
version. The suite hands it to the stager as --js-dir. Such a run proves the wasm and the loop, not the shipped bundles. Without it the Chrome suite skips there.
SmolLM2 runs in amd64 CI only. linux/scripts/lib/ort-web-llm-gate.sh decides it:
Host |
|
Gate |
|---|---|---|
not x86_64 (the Pi, arm64) |
any |
skip: the tiny model only |
x86_64 |
none, |
fail |
x86_64 |
none, no |
skip |
x86_64 |
no |
fail |
x86_64 |
a model directory |
run |
linux/scripts/ort-web-generate-ci.sh fetches ModelANT’s smollm2_135m_instruct_web-v1 by
linux/scripts/lib/ort-web-generate.lock: the int8 web export and the contract of that release. An older
contract has no case for the web model. Workflow ort-web-parity.yml runs it after the parity step.
genai-contract-fixture.py --out writes the fixture of text-generation-v1 for the model. The prompt ids are
what GenAI’s tokenizer and chat template give, with the generation prompt. --report judges the browser’s answer:
the exact ids, or other ids whose decoded text holds must_contain.
Measured on a Pi 5 in the arm64 image, Chrome 157, ORT 1.31.1 with the npm package’s JS, SmolLM2 with the
42-token capital-of-france prompt and 8 new tokens. Every run gave the contract’s exact ids:
Build |
Threads |
First token |
Decode |
Time in |
|---|---|---|---|---|
CPU |
2 |
1.1 s |
2.2 tokens/s |
4.2 s of 4.3 s |
CPU |
1 |
1.7 s |
1.7 tokens/s |
5.8 s |
CPU |
4 |
1.4 s |
1.4 tokens/s |
6.3 s |
JSPI on SwiftShader |
2 |
58 s |
0.12 tokens/s |
117 s |
That was the int4 export. The int8 web export (MatMulInteger, tied embedding) decodes 12.2 tokens/s on the CPU
build at 2 threads on the same Pi, with the contract’s exact ids.
Almost all the time is inside
session.run. The JS around it (tensors, the cache hand-over, the argmax over 49 152 logits) takes milliseconds.ORT’s profile puts 95 % of the CPU time in
MatMulNBits: per decode step about 108 ms forlm_headand 2.5 to 3 ms for each MLP projection of the 30 layers. The wasm build has no 4-bit GEMM kernel, so each call dequantizes its weights first.More threads do not help on the Pi’s 4 cores, which the page shares with Chrome itself.
SwiftShader is a CPU emulation of a GPU. Its numbers say nothing about a real GPU.
Generating text over an endpoint#
The browser’s fallback when no model is loaded: shared/web/javascript/endpoint-generate.mjs, shared asset
web-endpoint-generate-mjs, next to ort-web-generate.mjs, whose option checks and TextGenerationError it
imports. It posts OpenAI chat requests to <url>/v1/chat/completions and reads the answer under the text contract:
import { endpointGen } from '../javascript/endpoint-generate.mjs';
const gen = endpointGen({ url: 'http://127.0.0.1:11434', model: 'qwen3:0.6b', apiKey, headers, requestExtra });
const result = await gen.generate({ messages, tools, tool_choice: 'auto', options: { max_new_tokens: 512, max_millis },
signal, onText: (piece) => postMessage({ piece }), onThinking });
// result: { text, thinking, tool_calls: [{ id, name, arguments }], finish_reason, raw_finish_reason, prompt_tokens,
// completion_tokens, time_to_first_token_ms, decode_tokens_per_s, answered_by: 'endpoint', model, ids: [] }
It takes messages, never token ids: the server holds the tokenizer, the template, stop strings and the grammar.
promptIdsalone isinvalid_options.Messages and tools go out as
openai-tool-calls.jsonsays: a call{id, name, arguments}in OpenAI’s shape, a tool’sactsflag left out,tool_choiceonly beside tools.The body is
requestExtrafirst, then the caller’s keys.top_pandtop_kgo out only above temperature 0 and away from their defaults.seedandstopas given.json_schemabecomes a strictresponse_format. A Qwen3 agent turns thinking off withrequestExtra: { chat_template_kwargs: { enable_thinking: false } }.It streams by default (
endpointGen(endpoint, { stream: false })asks for a whole answer). Text pieces go toonText, reasoning under either name toonThinking.finish_reasonisstop,length,tool_callsorcancelled. Any other raw reason ends asstop;raw_finish_reasonkeeps it. A stream that ends with no reason isgeneration_failed.An aborted
signalends it at once withcancelledand what arrived.max_millisends an unfinished answer withlength. Without usage the completion count is the pieces read.CORS is the server’s concern. The browser sends
Content-Typeand, with a key,Authorization.
Beside the option refusals of ort-web-generate.mjs:
|
When |
|---|---|
|
no messages, no model, a URL that is not http(s), a tool that is no named function, two tools under one name, a choice naming no tool, a tool message answering no earlier call |
|
an HTTP status of 400 or more; |
|
the fetch failed |
|
no whole answer in |
|
a streamed line over 1 MiB |
|
an error the server sent, a chunk that is no JSON object, a call without a name |
linux/scripts/tests/test-endpoint-generate.sh replays the requests, whole answers and streams of
openai-tool-calls.json, openai-stream-lines.json and openai-chat-answers.json in node against a fake fetch that
splits lines across reads, then the body, every refusal, cancel, the time budget and the timeout. The
docs-site.endpoint-generate-* mutations prove it. Its template cases are a local reader’s: the server parses its
own model’s calls.
OxidANT’s agentRun (text-web-agent.mjs) takes an endpointGen as its gen: WebAgent.advanceMessages hands
it the turn’s messages and tools, and replied takes its reply (OxidANT 1feed7c0). OmniAccelerANT’s worker runs
its Agent tab on it while no browser model is loaded.