Repository navigation
Metal fill_gpu fails to keep fill value - #4660
ronaldmannak wants to merge 2 commits into
Conversation
zcbenz
left a comment
There was a problem hiding this comment.
This is usually caused by some code forgetting to call add_temporary(val) before using fill_gpu. There is no need to change fill_gpu.
|
@zcbenz Sounds good, I can remove the code in |
|
Yeah please update all the callers to use Regarding the test, I think it is likely going to be flaky, I'm good with no test since the change would be trivial to verify. |
The Metal
fill_gpufails to keep the fill value alive, and the GPU can read overwritten values, depending on timing.Callers of
fill_gpucurrently use different patterns. There are 12 call sites inconv.cppandgated_delta_update.cppthat do not keep the fill value alive and potentially expose the bug (confirmed with 3D Conv). There are 8 calls from attention, matmul and more that correctly keep the value alive usingadd_temporary, and there's one call fromPad::eval_gpuwhere the eval loop retains the valueThis PR adds a two line fix to
fill_gpuinmetal/copy.cppand a unit test. An alternative solution would be to addadd_temporary(zero)to the 12 call sites that fail to keep the fill value alive, but that seems like a brittle fix. A second alternative would be addingadd_temporary(val)tofill_gpu, but that may breakPadsince its fill value is a graph input and not temporary.To replicate the issue: