Skip to content

[WebGPU] zero-shot-classification model Xenova/nli-deberta-v3-xsmall not accelerated by WebGPU #955

@martin-ada-adam

Description

@martin-ada-adam

System Info

transformers.js v3 alpha 12-19, webapp chrome latest stable

Environment/Platform

  • Website/web-app
  • Browser extension
  • Server-side (e.g., Node.js, Deno, Bun)
  • Desktop app (e.g., Electron)
  • Other (e.g., VSCode extension)

Description

Embedding is pretty accelarated by WebGPU in v3 aplha but zero-shot-classification is quite slow using WebGPU
seems GPU is not much used,
q8 wasm is much faster - strange

Reproduction

import {env,pipeline} from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.0.0-alpha.19';

async function execute()
{

const classifierMulti = await pipeline('zero-shot-classification',
'Xenova/nli-deberta-v3-xsmall',
// { dtype: 'q8', device:'wasm'}
// { dtype: 'fp16', device:'wasm' }
{ dtype: 'fp16', device:'webgpu' }
);

const startTime = Date.now();
const result = await classifierMulti("Last week I upgraded my iOS version and ever since then my phone has been overheating whenever I use your app.",
["failure","database","mobile phone"], { multi_label: true });
const endTime = Date.now();
const timeSpent = endTime - startTime;

console.log("result",result);

console.log("time:",timeSpent);
}

execute();

codepen example
https://codepen.io/martin-adam/pen/eYqJPpy

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions