Enable WebGPU execution provider for semantic embeddings (WASM fallback)

Abierto
#1,209 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
55/100
Tipo de issue
Nueva funcionalidad
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
javascript, typescript

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
TypeScript
Estrellas
3
Forks
2
Merge medio
11 h 49 min
PR fusionados (30 d)
102

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de d-oit/do-knowledge-studio

Todos los issues de d-oit/do-knowledge-studio

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.