ONNX Runtime JavaScript API
    Preparing search index...

    Interface WebGpuExecutionProviderOption

    interface WebGpuExecutionProviderOption {
        defaultBufferCacheMode?:
            | "disabled"
            | "lazyRelease"
            | "simple"
            | "bucket";
        device?: unknown;
        enableMatmulFp32Accumulation?: boolean;
        enableRobustness?: boolean;
        forceCpuNodeNames?: readonly string[];
        name: "webgpu";
        preferredLayout?: "NHWC"
        | "NCHW";
        queryResolveBufferCacheMode?:
            | "disabled"
            | "lazyRelease"
            | "simple"
            | "bucket";
        storageBufferCacheMode?: "disabled"
        | "lazyRelease"
        | "simple"
        | "bucket";
        uniformBufferCacheMode?: "disabled" | "lazyRelease" | "simple" | "bucket";
        validationMode?: "basic" | "disabled" | "full" | "wgpuOnly";
        weightLoadAcceleration?: "preferred" | "required" | "off";
    }

    Hierarchy (View Summary)

    Index

    Properties

    defaultBufferCacheMode?: "disabled" | "lazyRelease" | "simple" | "bucket"

    Specify the cache mode for buffers not covered by the other buffer cache mode options.

    See storageBufferCacheMode for a description of the available modes.

    'disabled'
    
    device?: unknown

    Specify an optional WebGPU device to be used by the WebGPU execution provider.

    enableMatmulFp32Accumulation?: boolean

    Accumulate the dot products in f32 instead of in the output element type. The input and weight tensors keep their own type, so global memory traffic is identical either way.

    When this is false the accumulator follows the output element type. Partial sums along K can exceed the f16 maximum (65504) on backends that round strictly at every step, which saturates the accumulator to Inf; setting this avoids that at the cost of registers and workgroup memory.

    Where a fused kernel computes its epilogue on the accumulators, that epilogue carries the wider type too. On the fused MLP decode fast path the bias, the SiLU and the gate/up product are applied to the f32 accumulators and rounded once at the final store rather than after every step, so with the option on its output can differ from the same graph run unfused by more than the accumulation change alone. Fused MLP shapes that do not take that fast path materialize the gate and up tensors in the output element type before the activation, and are unaffected in their epilogue.

    This currently applies to MatMulNBits and its fused variants. Coverage of the unquantized MatMul family is planned as follow-up work under the same option.

    This option is read by the native WebGPU execution provider only. Builds of onnxruntime-web that use the JSEP WebGPU backend ignore it, and their MatMulNBits shaders keep accumulating in the output element type.

    false
    
    enableRobustness?: boolean

    Enable robust buffer access for an ORT-created Dawn device. This is a global, first-device-wins option. Later conflicting values and values supplied with an external device are ignored with a warning.

    This setting is available only in ONNX Runtime (Node.js binding).

    true in Debug builds; false in Release and RelWithDebInfo builds

    forceCpuNodeNames?: readonly string[]

    Specify a list of node names that should be executed on CPU even when WebGPU EP is used.

    name: "webgpu"
    preferredLayout?: "NHWC" | "NCHW"

    Specify the preferred layout when running layout sensitive operators.

    'NCHW'
    
    queryResolveBufferCacheMode?: "disabled" | "lazyRelease" | "simple" | "bucket"

    Specify the cache mode for query resolve buffers.

    See storageBufferCacheMode for a description of the available modes.

    'disabled'
    
    storageBufferCacheMode?: "disabled" | "lazyRelease" | "simple" | "bucket"

    Specify the cache mode for storage buffers.

    • 'disabled': Disable buffer cache. Buffers are destroyed when no longer in use.
    • 'lazyRelease': Buffers are released lazily, at the end of the current run.
    • 'simple': Released buffers are cached and reused only for requests of the exact same size.
    • 'bucket': Released buffers are cached and reused using predefined size buckets. This is the default mode.

    For static-shape models, 'simple' may reduce GPU memory usage, because exact-size buffers are reused across runs instead of allocating new bucket-sized buffers.

    'bucket'
    
    uniformBufferCacheMode?: "disabled" | "lazyRelease" | "simple" | "bucket"

    Specify the cache mode for uniform buffers.

    See storageBufferCacheMode for a description of the available modes.

    'simple'
    
    validationMode?: "basic" | "disabled" | "full" | "wgpuOnly"

    Specify the validation mode for WebGPU execution provider.

    • 'disabled': Disable all validation. When used in Node.js, disable validation may cause process crash if WebGPU errors occur. Be cautious when using this mode. When used in web, this mode is equivalent to 'wgpuOnly'.
    • 'wgpuOnly': Perform WebGPU internal validation only.
    • 'basic': Perform basic validation including WebGPU internal validation. This is the default mode.
    • 'full': Perform full validation. This mode may have performance impact. Use it for debugging purpose.
    'basic'
    
    weightLoadAcceleration?: "preferred" | "required" | "off"

    Select accelerated external-weight loading for the native Windows WebGPU execution provider.

    • 'off': Disable accelerated weight loading.
    • 'preferred': Use D3D12 accelerated loading when available and otherwise use the ordinary loading path.
    • 'required': Require D3D12 accelerated loading support.

    This setting is available only in ONNX Runtime (Node.js binding) builds with D3D12 file loading support.

    'off'