Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Proposal: Support build-time metadata to describe how a graph will be driven

Abierto
#965 1 comentario 0 reacciones 0 asignados Ver en GitHub

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

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

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 webmachinelearning/webnn

Todos los issues de webmachinelearning/webnn

Issues similares

Más issues de Backend & API Design

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.