You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Add small compute examples illustrating new WGSL primitives for AI #350
@beaufortfrancois requested that some small examples be published here showing how to use the new WGSL primitives aimed at AI/ML workloads: shader-f16, DP4A, and soon, subgroups. Could we consider this?
Not sure what would be the most compelling - perhaps something with some visual output, and running a microbenchmark against the fallback WGSL code, assuming the feature is actually supported?
dp4a accelerates matrix multiplication right? Even a basic matrix multiplication sample could be enough for a sample. The sample could even just display some text. But sobel or any other simple convolution would make it more compelling.
If possible, I'd like to try my hand at this issue, at least for the next week (sorry about the timeline, day job is gonna day job). Sobel filter is a good place to start I think.
EDIT: 'GPGPU Compute Category' or 'Features Category'?
Just want to make sure I understand the assignment, the intended use of dp4a here. Instead of writing, say, this for our sobel filter.... (below is in pseudo-wgsl)
(Pixels loaded from texture using textureLoad and global_invocation_id
let result = 1 * pixel1.r
+ 2 * pixel2.r
+ 1 * pixel 3. r
- 1 * textureLoad(inputTexture, vec2<u32>(id.x + 1, id.y - 1), 0).r
textureStore(output, id.xy, result)
We should do something like this?
let pixelPack = pack4xU8Clamp(pixel1.r, pixel2.r, pixel3.r, pixel4.r)
let kernelPack = pack4xU8Clamp(1, 2, 1, -1)
let result = dot4U8Packed(pixelPack, kernelPack);
textureStore(output, id.xy, result)
Also it should have a toggle to enable/disable dp4a and hopefully see some performance improvement.
I suspect a Sobel filter is simple enough that it's limited by memory bandwidth instead of computation.
So I wouldn't get hung up on perf improvement for this sample.
Somebody else should take this on, I understand the functionality, but I'm struggling with the quantization of the dp4a result back to something usable.
There's now a very basic example in #572 that lets people play with dot4I8Packed but it doesn't do anything that would actually be faster than an unoptimized dot product. Would be interested to see someone either do something more graphical and compute intensive, which could replace this sample.
Activity
kenrussell commentedon Jan 24, 2024
CC @dneto0
dneto0 commentedon Feb 29, 2024
For dp4a:
kainino0x commentedon Feb 29, 2024
dp4a accelerates matrix multiplication right? Even a basic matrix multiplication sample could be enough for a sample. The sample could even just display some text. But sobel or any other simple convolution would make it more compelling.
kainino0x commentedon Mar 5, 2024
Also it should have a toggle to enable/disable dp4a and hopefully see some performance improvement.
cmhhelgeson commentedon Mar 5, 2024
Is dp4a available in the current version of WebGPU?
austinEng commentedon Mar 5, 2024
dp4a is available starting in Chromium M123. So today, that would be Chrome Beta and newer.
cmhhelgeson commentedon Mar 6, 2024
If possible, I'd like to try my hand at this issue, at least for the next week (sorry about the timeline, day job is gonna day job). Sobel filter is a good place to start I think.
EDIT: 'GPGPU Compute Category' or 'Features Category'?
cmhhelgeson commentedon Mar 6, 2024
Just want to make sure I understand the assignment, the intended use of dp4a here. Instead of writing, say, this for our sobel filter.... (below is in pseudo-wgsl)
We should do something like this?
dneto0 commentedon Mar 6, 2024
I suspect a Sobel filter is simple enough that it's limited by memory bandwidth instead of computation.
So I wouldn't get hung up on perf improvement for this sample.
cmhhelgeson commentedon Mar 12, 2024
Somebody else should take this on, I understand the functionality, but I'm struggling with the quantization of the dp4a result back to something usable.
Add Vision Transformer sample with attention visualization
Add external Vision Transformer sample (#570)
Add packed integer dot product sample (#572)
kainino0x commentedon Sep 16, 2026
There's now a very basic example in #572 that lets people play with
dot4I8Packedbut it doesn't do anything that would actually be faster than an unoptimized dot product. Would be interested to see someone either do something more graphical and compute intensive, which could replace this sample.