Repository navigation
webgpu : fix race condition in memset - #31162
Conversation
|
@yomaytk Such a global mutex seems a bit strange - is it really necessary to have it? Which part of WebGPU makes it necessary? |
Thanks, good catch. After this PR is merged, this global mutex is necessary for If it looks good, I'll open a follow-up PR to address this and check it with the tests. |
|
If we can move the buffers to the context and avoid the mutex it would be cleaner IMO. Not sure about the Vulkan mutex. It's used quite extensively already, so likely it's necessary for some reason. |
|
Got it, I'll try that design and open a follow-up PR once it's ready. |
Overview
#31157 enabled automatic parallel test workers. This exposed an existing race in the WebGPU backend in CI, e.g. https://github.com/ggml-org/llama.cpp/actions/runs/40218104124/job/121243543710
Concurrent calls to
ggml_backend_webgpu_buffer_memsetcan race between setting and using the sharedmemset_params_buf. Fix by guarding with the existing mutex.This showed up in CI consistently with the Grok fragmented KV-cache test. I didn't check this part, but apparently it showed up here specifically because "Grok runs without flash attention, so its transposed f16 value-cache writes can require small, unaligned updates".
A few quick perf checks did not reveal any regressions from using the lock here.
Requirements