Repository navigation
Implement output_shapes for RMSNormVJP and LayerNormVJP - #5010
archidoge0 wants to merge 2 commits into
Conversation
|
Thank you for the contribution! We haven't noticed it before because for training we usually compile for a specific shape. |
Thanks for checking! Those failures were not caused by
I updated those two shapes in |
|
Can you take care of the crash in CPU backend? Probably another bug discovered 😅 |
@zcbenz already posted below/above (I don’t know how GitHub order the thread… |
|
You said you updated the tests to test the bug cleanly so I thought it would avoid the crash, I can rerun CI after merging #5016. |
8d5cda3 to
99e218f
Compare
|
The CPU backend is still crashing at the tests. |
Fix via: #5020 |
test_fast.py; PR description written manually.Fixes #4985.
RMSNormVJPandLayerNormVJPare multi-output primitives, socompile_replace(..., shapeless=True)callsPrimitive::output_shapeson them when replayingmx.compile(mx.grad(...), shapeless=True). Neither primitive implementedoutput_shapes, raisingValueErrorat replay time.This adds
output_shapesto both VJP primitives inmlx/fast_primitives.h:RMSNormVJP:{inputs[0].shape(), inputs[1].shape()}(gx,gw, including the scalar placeholder whenweight=None)LayerNormVJP:{inputs[0].shape(), inputs[1].shape(), inputs[2].shape()}(gx,gw,gb)Added
test_rms_norm_grad_shapelessandtest_layer_norm_grad_shapelessinpython/tests/test_fast.pycovering optionalweight/bias, varying batch and feature sizes (including looped-kernel dims4099/8196and empty batch(0, 64)), verified locally on Metal (M3 Max).