Repository navigation
Conversation
MUL(signs) -> RESHAPE -> MUL_MAT(hadamard) now runs as one dispatch: the signed FWHT variant applies the sign vector while it loads the row, so the separate elementwise pass and the barrier that followed it are gone. Mirrors the Metal signed FWHT fusion. Ternary-Bonsai-2-27B on RX 6700S (RDNA2), -dev Vulkan1 -ngl 999 -p 512 -n 128 -r 3 -fa 1: PTQ1_0 tg128 18.16 -> 24.13 PQ2_0 tg128 16.88 -> 22.15 PPL 4.2521 +/- 0.29627 and the full test-backend-ops run are unchanged.
Reset the signed-FWHT dispatch flag along with the fused-node count when an overlapping buffer requires the unfused fallback. Otherwise MUL still dispatches the fused transform and the graph also executes the original MUL_MAT. Validated on Apple M5 Pro through MoltenVK with disjoint and partially overlapping buffers, block width 64, activation width 128, and 1/3/5 tokens. All three overlapping cases fail before this change; all six cases pass after it with maximum absolute error below 2.4e-7 against a scalar reference.
bri-prism
marked this pull request as ready for review
October 15, 2026 21:31
bri-prism
marked this pull request as draft
October 15, 2026 21:32
|
Thanks for integrating this and for keeping the original commit and authorship. The fix matches what I see: the overlap guard clears the fused-node count and the other flags, but not Please go ahead with #366. I will close #349. Happy to re-run anything on the RDNA2 box if useful. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Signed Hadamard fusion can produce incorrect output when the graph allocator overlaps an activation buffer with the final output. The overlap guard cancels fusion by resetting the fused-node count, but the signed-FWHT flag remains set: MUL still runs the fused transform, followed by the original MUL_MAT.
This carries the original optimization from #349, with its author and commit preserved, plus a one-line correction that clears the signed-FWHT flag whenever overlap disables fusion. It is an alternative integration branch for #349, not an additional optimization to merge twice.
Validation:
The original PR's AMD throughput measurements were not repeated. This validation establishes the fallback correction on MoltenVK; it does not establish an end-to-end speedup or coverage of every Vulkan device.