Proposal: Support build-time metadata to describe how a graph will be driven
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- javascript, web-dev
- Área
- api, machine-learning
Línea de trabajo
Start by reading the WebNN build() definition and the surrounding Web IDL dictionaries in the spec. Work out how the proposed metadata members and optional build options fit the API, including the stated hint behavior and validation rules. Done means the spec describes the two language-model metadata fields and how backends may handle them.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Problem
WebNN can mark a dimension as dynamic (#883), but that doesn't tell the backend how the page will use it. For example, a dynamic seq_len doesn't say how long the longest prompt will be.
Some backends, especially NPUs, compile fixed-size models up front, so they need these numbers before the first dispatch. For a language model, an NPU backend has to decide at compile time:
- the longest prompt it will accept
- how much KV cache to reserve for the reply
Only the page knows these numbers, but today WebNN gives the page no way to pass these numbers at build time, so the backend can only guess. For example, OpenVINO's NPU path (NPUW) assumes by default a prompt of at most 1024 tokens and 128 tokens for the reply. A longer prompt fails. A larger default would waste memory and compile time for pages that don't need it.
Proposal
Add an optional options to build(), which contains metadata member:
dictionary MLModelMetadata {
[EnforceRange] unsigned long maxPromptLength; // longest prompt, in tokens, in one dispatch
[EnforceRange] unsigned long minResponseLength; // tokens reserved for the reply
};
dictionary MLBuildOptions {
MLModelMetadata metadata = {};
};
interface MLGraphBuilder {
// The existing build() gains an optional options argument.
Promise<MLGraph> build(MLNamedOperands outputs,
optional MLBuildOptions options = {});
};
const graph = await builder.build({logits}, {
metadata: {maxPromptLength: 4096, minResponseLength: 256},
});
How metadata behaves:
- Its members are defined by the spec, not chosen by the page. Like operators, each member is added by the Working Group. A page can't pass arbitrary keys, and there are no vendor-specific members. This issue proposes only the two language-model members above. Others can be proposed later in the same way.
- It is a hint. It never changes what the graph computes. It only affects performance and resource limits, such as how long a context fits. A backend may ignore a member, but must not fail because of it.
- It describes the workload, not the device. "The longest prompt is 4096 tokens", not "use tile size 64".
- Lenguaje dominante
- Bikeshed
- Estrellas
- 566
- Forks
- 72
- Merge medio
- 6 d 5 h
- PR fusionados (30 d)
- 1
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de webmachinelearning/webnn
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
webmachinelearning/webnn#967 ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
webmachinelearning/webnn#966 · 1 comentario ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
webmachinelearning/webnn#964 · 1 comentario · 1 reacción ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 30/100
webmachinelearning/webnn#963 · 3 comentarios · 2 reacciones ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 8/100
webmachinelearning/webnn#961 ·
Todos los issues de webmachinelearning/webnn
Issues similares
-
needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
11ty/buildawesome#4407 · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
area: image-engine bug priority: low
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
snapotter-hq/SnapOtter#3885 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
keyxmakerx/Chronicle#1721 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Gentleman-Programming/gentle-ai#5720 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día