← 输入框|github.com|刷新
Skip to content

Proposal for subgroup matrix feature - #5335

Merged
dneto0 merged 1 commit into
gpuweb:mainfrom
alan-baker:subgroup-matrix-proposal
Oct 7, 2025
Merged

dneto0 merged 1 commit into
gpuweb:mainfrom
alan-baker:subgroup-matrix-proposal

Conversation

@alan-baker

Copy link
Copy Markdown
Contributor

Refs #4195

@alan-baker alan-baker added proposal wgsl WebGPU Shading Language Issues api WebGPU API labels Oct 3, 2025
@github-actions

github-actions Bot commented Oct 3, 2025 •

Copy link
Copy Markdown
Contributor

Previews, as seen when this build job started (01420ea):
WebGPU webgpu.idl | Explainer | Correspondence Reference
WGSL grammar.js | wgsl.lalr.txt

@Kangz Kangz added this to the Milestone 2 milestone Oct 3, 2025
@dneto0
dneto0 self-requested a review October 3, 2025 14:17

@dneto0 dneto0 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This captures the proposal as intended, and is a good basis for further iteration and discusison.

Key changes from what's in the doc in the Dawn source tree:

  • change name of the extension
  • pull subgroup_id out to a separate feature
  • describe relation to the HLSL linalg proposal.

I think this is ready to land.

@jimblandy jimblandy moved this to Future agenda in JimB WGSL planning Oct 6, 2025
@jimblandy jimblandy moved this from Future agenda to Current agenda in JimB WGSL planning Oct 6, 2025
Comment on lines +271 to +276
#### Attributes

Add an additional error condition to `workgroup_size`.
It is a pipeline-creation error if the x dimension is not a multiple of
`GPUAdapterInfo.subgroupMaxSize` and the shader statically accesses any
subgroup matrix.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Apple Silicon, the subgroup-size restriction is likely to be a bottleneck. If we need a bound, could we use subgroupMinSize rather than subgroupMaxSize?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The better restriction would be that x dimension is a multiple of the selected subgroup size. The issue is that there is no good way to get that information. Metal can query the subgroup size of the pipeline, but Vulkan and D3D cannot. Vulkan and D3D can specify a specific subgroup size, but Metal cannot. So consider a device that reports the subgroup size range [8, 32]. If the compiler selects a subgroup size of 32, a workgroup size of 16 (multiple of min size) would be invalid. Are these devices common? I'm not certain, but it's not clear how to handle it.

We can look into devices more thoroughly compared to supported subgroup sizes, but I'm not certain how restrictive we want to be.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metal caps the subgroup size at 32 today, which makes this specification acceptable short-term.
google/dawn@d7d27a6

However, performance usually peaks when subgroup size aligns with the hardware SIMD width. If possible, consider returning the optimal subgroup size (in addition to—or instead of—min/max). For context, NVIDIA warps are 32, while AMD wavefronts are typically 64 (RDNA: 32 or 64), so a single max/min pair can be misleading across vendors.


### MSL/Metal

Apple calls them simdgroup matrices and support has existed since MSL 2.3. They are limited to relatively few GPUs though (Apple7+ in the [feature set](https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf)). That is iPhone 12+, some newer iPads, and the M1 and later macs.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'relatively few GPUs' is potentially inaccurate, since Apple7 is A14 Bionic which released 5 years ago.

But I agree it is certainly not supported on all Metal devices. I.e., no Intel Mac support, many iPads do not support this, and some iPhones too.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm capturing this feedback in an update to the proposal text in #5346

There's no need to quantify it as many or few, just that it's not all of them.

@jimblandy

Copy link
Copy Markdown
Contributor
Minutes from today's WGSL committee meeting Oct 7, 2025
  • Key changes from what's in the doc in the Dawn source tree:
    • change name of the extension
    • pull subgroup_id out to a separate feature
    • describe relation to the HLSL linalg proposal.
  • JB: Another PR that adds proposal, think we want to be liberal at accepting proposals and beat the tar out of it in further discussion. So, Mozilla things this looks good to accept as a proposal.
  • AB: One that one discussion, think that's basically a request for precise information. A lament that we can't provide a feature to select a subgroup size. If a driver gives 2 subgroup sizes and picks the larger, you can't run at the smaller that's invalid. It just won't work. Unfortunately, can we get the most precise information from the driver, and in the future could we do better, not a lot of intersection across platforms. Not a lot that can be done right now for that request.
  • JB: Thoughts on accepting
  • DN: Two thumbs up
  • MW: Thumb up.
  • JB: Great.

@jimblandy

Copy link
Copy Markdown
Contributor

My unofficial summary: looks good as proposal, let's have further discussion as PRs/issues regarding that document.

@jimblandy jimblandy moved this from Current agenda to Done in JimB WGSL planning Oct 7, 2025
@dneto0
dneto0 merged commit 8fe60fe into gpuweb:main Oct 7, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api WebGPU API proposal wgsl WebGPU Shading Language Issues

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

6 participants