Skip to content

feat(semantic-emoji-filter): Laya in the browser — the web verifier on the Q8_0 lane - #45

Merged
michalharakal merged 1 commit into
developfrom
feature/sef-web-verifier
Oct 17, 2026
Merged

michalharakal merged 1 commit into
developfrom
feature/sef-web-verifier

Conversation

@michalharakal

Copy link
Copy Markdown
Contributor

Laya in the browser: the SemanticEmojiFilter web build gets the second stage, on the engine's browser lane (SKEEP-007) — the "web verifier" step of the plan.

How it works

  • A Web Worker owns the model. New module :webVerifier (Kotlin/Wasm executable, built with -PlayaVerifier=true); its raw compiler output ships under laya-worker/ next to the app and the page starts it as a module worker. The page's Kotlin/Wasm runs on the single JS thread and a decision is seconds of compute, so nothing of Laya runs on the page's thread.
  • Opt-in. The System 2 chip reads "tap to load Laya (644 MB, runs in a Web Worker)" (new VerifierState.OptIn, Verifier.enable()); nothing downloads until the user taps. The worker fetches the pinned Hugging Face checkpoint through CORS into the browser's Cache API, so later visits read it from disk (643 MB read into memory in 2.7 s).
  • Q8_0 at load. LayaWebSource (verifier module, wasmJsMain) builds the agent with the common LayaModelLoader.load(files, weights, …) and LayaWeightForms.q8_0For: about 340 MB of packed weights instead of 1.3 GB of FP32, served by the SIMD128 sidecar, which the worker installs first (simd128-mt inside the worker on the examples site, where the page is cross-origin isolated).
  • Same verifier code as desktop and Android. LayaVerifier, EmojiMatchSchema and the verdict cache are unchanged; only the checkpoint source differs. The page side (WorkerLayaVerifier) speaks a small string protocol (WorkerProtocol in shared) with request ids, so a verdict for a query the user has already left is dropped.
  • The verifier module gains a wasmJs target; the webapp.json build command uses -PlayaVerifier=true, so the examples site ships it. CI compiles the worker and the app with the flag.

Also fixed

  • The grid anchored its scroll on the first visible card's key (🥗 leads the unranked catalog); for a query that ranks it low, the grid followed it down and hid the matches. A new ranking now starts at the top.

Measured (headless Chromium on this laptop, served over http, cross-origin isolated)

  • First run: download + read + quantize ≈ 146 s; with the checkpoint cached: ≈ 88 s, of which quantize-at-load 78 s.
  • One decision: 5.0–6.7 s on the simd128-mt sidecar. The matmuls are no longer the cost; what is left is the Kotlin-side eager path (attention, norms, dequantizing token rows). That is the engine's next step (SKEEP-007 PR 3: resident activations, banded SDPA), not the sample's.
  • Verdicts agree with the FP32 desktop reference in the README: "healthy things to eat" → 🥗 0.34 (?), 🥬 0.17, 🍎 0.06, 🥓 0.06, 🥜 0.03; "feeling sick" → 🤢 0.94, 🤮 0.95, 🤧 0.85, 🤒 0.95, all accepted.

…on the Q8_0 lane

- :webVerifier, a Kotlin/Wasm worker shipped under laya-worker/ with -PlayaVerifier=true:
  fetches the pinned checkpoint from Hugging Face into the Cache API on an explicit opt-in
  (System 2 chip, VerifierState.OptIn / Verifier.enable), installs the SIMD128 sidecar, and
  builds the agent with LayaWeightForms.q8_0For (about 340 MB packed instead of 1.3 GB FP32).
- The verifier module gains a wasmJs target; LayaWebSource is the web checkpoint source,
  LayaVerifier and EmojiMatchSchema are shared with desktop and Android unchanged.
- WorkerLayaVerifier on the page side and WorkerProtocol (shared) with request ids, so a
  verdict for an abandoned query is dropped; progress lines go straight to the page.
- The grid scrolls to the top on every new ranking; it used to follow its first card's key.
- CI compiles the worker and the app with the flag; webapp.json builds the site with it.

Measured in headless Chromium: first load 146 s (download + quantize), cached 88 s;
5-7 s per decision on the simd128-mt sidecar; verdicts equal the FP32 desktop reference.
@michalharakal
michalharakal merged commit 0406ee2 into develop Oct 17, 2026
1 check passed
@michalharakal
michalharakal deleted the feature/sef-web-verifier branch October 17, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant