Skip to content

Commit 636967c

Browse files
authored
[ExecuTorch][WebGPU] Restore SDPA per-dispatch kernel_name labels (pytorch#20551)
[ExecuTorch][WebGPU] Restore SDPA per-dispatch kernel_name labels @diff-train-skip-merge
1 parent b919db7 commit 636967c

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

  • backends/webgpu/runtime/ops/sdpa

‎backends/webgpu/runtime/ops/sdpa/Sdpa.cpp‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ void build_dispatch(
160160
uint64_t uniform_size,
161161
uint32_t workgroup_count_x,
162162
uint32_t wg_size,
163-
bool retain_uniform = false) {
163+
bool retain_uniform = false,
164+
const char* kernel_name = "") {
164165
WGPUDevice device = graph.device();
165166

166167
WGPUShaderSourceWGSL wgsl_desc = {};
@@ -231,7 +232,7 @@ void build_dispatch(
231232
bg_desc.entries = bg_entries;
232233
WGPUBindGroup bind_group = wgpuDeviceCreateBindGroup(device, &bg_desc);
233234

234-
graph.add_dispatch({pipeline, bind_group, workgroup_count_x});
235+
graph.add_dispatch({pipeline, bind_group, workgroup_count_x, kernel_name});
235236

236237
wgpuShaderModuleRelease(shader);
237238
wgpuBindGroupLayoutRelease(bgl);
@@ -273,7 +274,8 @@ static WGPUBuffer record_update_cache_dispatch(
273274
sizeof(uc),
274275
wgc,
275276
uc_wg,
276-
dynamic_pos);
277+
dynamic_pos,
278+
"update_cache");
277279
return ubuf;
278280
}
279281

@@ -499,7 +501,8 @@ void sdpa_with_kv_cache_impl(WebGPUGraph& graph, const std::vector<int>& args) {
499501
sizeof(p),
500502
wgc,
501503
qk_wg,
502-
dynamic_pos);
504+
dynamic_pos,
505+
"sdpa_compute_attn_weights");
503506
qk_buf = ubuf;
504507
qk_idx = graph.num_dispatches() - 1;
505508
}
@@ -522,7 +525,8 @@ void sdpa_with_kv_cache_impl(WebGPUGraph& graph, const std::vector<int>& args) {
522525
sizeof(p),
523526
wgc,
524527
0,
525-
dynamic_pos);
528+
dynamic_pos,
529+
"sdpa_softmax");
526530
softmax_buf = ubuf;
527531
}
528532

@@ -547,7 +551,8 @@ void sdpa_with_kv_cache_impl(WebGPUGraph& graph, const std::vector<int>& args) {
547551
sizeof(p),
548552
wgc,
549553
av_wg,
550-
dynamic_pos);
554+
dynamic_pos,
555+
"sdpa_compute_out");
551556
av_buf = ubuf;
552557
}
553558

0 commit comments

Comments
 (0)