[GPU] Allow bf16 input transposes to fuse into SDPA (TransposeSDPAMatcher) #38122
Could you please use pattern::type_matches_any instead of a custom predicate? The same in TransposeSDPAMatcher.
Also, it would be great to store sdpa_supported_precisions list in one place (as a static SDPA node function, for example) and reuse it everywhere: this would allow to avoid code modifications in several places when new precision is supported by the GPU node. What do you think?
Could you please also add f16 test case? It looks like we can easily parametrize the existing tests by input precision
Could you please also add f16 test case?
Good idea. Make the changes.
done
Done
Shouldn't we also verify precisions in SDPA::validate_and_infer_types?
I would rather leave this to kernel implementation like validate_impl. Currently, the rest of intel_gpu custom ops doesn't assert precision set in validate_and_infer_types().
Wouldn't this lead to a more difficult-to-debug situation when an operation is created with an unsupported precision? In that case, we would only get an exception at the kernel creation stage, instead of catching it earlier during model compilation
Yes, adding validate_and_infer_types can catch during graph construction for fail early detection. However, if a new precision type that add in kernel but not add here, it will fail in validate_and_infer_types check. As other intel_gpu custom ops doesn't add the check, that why not plan to add here.
From my perspective, the best solution here is to enable such checks for all gpu custom ops. But I agree that this is out of scope of the current PR, and this activity requires a broader discussion
@isanghao could you please share your thoughts on that?
Approved these changes.
Approved these changes.
v-Golubev
clee30
TransposeSDPAMatcher / TransposeVLSDPAMatcher fold q/k/v Transpose ops into the internal SDPA op's input transpose orders so the SDPA kernel reads the natural [B,S,H,D] layout. The pattern predicate (is_fp_type) only allowed f16/f32 tensors, so under the bf16 inference hint every pre-SDPA transpose stayed as a standalone permute kernel.
Tickets:
- CVS-192281
AI Assistance:
- AI assistance used: no / yes
- If yes, summarize how AI was used and what human validation was performed (build/tests/manual checks).