Enable WebGPU execution provider for semantic embeddings (WASM fallback)

オープン
#1,209 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
55/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
javascript, typescript

調査の方向性

Start by reading src/lib/search/embeddings.ts, especially the device selection around lines 48 and 58-68, then inspect the device-guard tests. Extend the existing worker pipeline to probe WebGPU, retry with WASM on failure, and include the selected device in the fingerprints handled by src/lib/search/semantic-cache.ts and src/lib/search/semantic-digest.ts. Done means the fallback tests pass and the Settings view reports the active embedding device.

索引モデルが issue の本文から書いたものです。

説明

enhancement performance priority: medium search

Summary

The semantic search engine currently pins the transformers.js embedding pipeline to CPU/WASM execution (device: embeddingDevice with a WASM-only default). Transformers.js v4 — already the project dependency (@huggingface/transformers ^4.3.1) — makes WebGPU the default backend where the browser supports it, with a one-line device flag and mature WASM fallback.

Evidence

  • src/lib/search/embeddings.ts:48 — "CPU execution via WASM — no WebGPU required" comment documents the current deliberate choice.
  • src/lib/search/embeddings.ts:66-68 — setEmbeddingDeviceForTests shows the device selection is already parameterized; adding webgpu is a small, contained change.
  • Dependency is already at v4.x, so no upgrade is required to try it.

Impact

  • Performance: 2026 benchmarks report 40–75× embedding speedups on WebGPU vs WASM across integrated and discrete GPUs; semantic indexing of a large corpus drops from tens of seconds to near-instant for incremental updates.
  • Battery/UX: GPU inference frees the main thread and reduces CPU spin during indexing (the search worker already exists, so worker placement is solved).
  • No regression risk for unsupported browsers: navigator.gpu.requestAdapter() probe → fall back to the existing wasm path.

Proposed approach

  1. Probe navigator.gpu?.requestAdapter() in the worker before pipeline creation.
  2. Select device: 'webgpu' when available; on pipeline-creation failure, retry once with device: 'wasm'.
  3. Record the chosen device in the semantic cache fingerprint so vectors are not reused across devices (src/lib/search/semantic-cache.ts / semantic-digest.ts already fingerprint model + preprocessing + corpus).
  4. Extend the device-guard test (device error handling around embeddings.ts:58) and a new fallback unit test.
  5. Surface the active device in the Settings view (it already reports semantic index cost/budget).

References

主要言語
TypeScript
スター
3
フォーク
2
平均マージ
11時間 49分
マージ済み PR(30日)
102

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

d-oit/do-knowledge-studio のほかの issue

d-oit/do-knowledge-studio の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。