Fix GemmFloat8 C operand descriptor type - #31967
Fix GemmFloat8 C operand descriptor type#31967Akshay Sonawane (apsonawane) wants to merge 1 commit into
Conversation
Use the actual optional C tensor type for cuBLASLt layout descriptors, preserve output-typed fallback descriptors with an effective zero beta when C is absent, and cover mixed and scaled FP8 cases. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes how the CUDA GemmFloat8 contrib op configures cuBLASLt’s C operand matrix layout descriptor by using the actual (optional) input C tensor type when present, and a safe output-typed fallback (with beta=0) when C is absent. This aligns descriptor types with the real inputs and adds coverage for mixed-type and scaled FP8 scenarios.
Changes:
- Update cuBLASLt
Cdesccreation to usedtype_CwhenCexists, otherwise use the output type with an effectivebeta=0. - Add a CUDA<12 runtime guard for the unsupported combination of
C+ nonzerobeta. - Extend unit tests to cover mixed
Ctypes, scaled FP8, and FP8 execution withoutC.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| onnxruntime/test/contrib_ops/gemm_float8_test.cc | Adds CUDA tests for mixed-type C, scaled FP8 cases, and the “no C” path. |
| onnxruntime/contrib_ops/cuda/math/gemm_float8.cu | Fixes cuBLASLt C layout descriptor typing and ensures beta is effectively zero when C is absent. |
| onnxruntime/contrib_ops/cuda/math/gemm_float8.cc | Adds the kernel type constraint for TC to match the schema’s allowed C types. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Tianlei Wu (tianleiwu)
left a comment
There was a problem hiding this comment.
Two blocking FP8 issues remain. The non-FP8 mixed-C descriptor fix and the effective zero-beta handling are sound, but FP8 output currently selects unsupported C descriptor types, and the new FP8 regression tests never execute because their architecture threshold is impossible.
| onnxruntime::cuda::ToCudaDataType(ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT); | ||
| cudaDataType_t bias_cuda_type = onnxruntime::cuda::ToCudaDataType(dtype_C); | ||
| cudaDataType_t c_cuda_type = | ||
| has_bias ? onnxruntime::cuda::ToCudaDataType(dtype_C) : d_cuda_type; |
There was a problem hiding this comment.
Blocking: for FP8 D, cuBLASLt's supported type combinations require matrix C to be FP16 or BF16. This selects FP32 when the supplied C is float (as in the new scaled test), and selects FP8 when C is absent because c_cuda_type = d_cuda_type; neither (C=FP32, D=FP8) nor (C=FP8, D=FP8) is supported. Setting CUBLASLT_MATMUL_DESC_BIAS_DATA_TYPE below controls epilogue bias and does not make the matrix-C layout valid. Please use a supported FP16/BF16 C descriptor for FP8 output, reject or convert incompatible supplied C, and use a supported fallback descriptor with zero beta when C is absent.
| } | ||
|
|
||
| TEST(GemmFloat8OpTest, ScaledFloat8E4M3FNToFloat8E4M3FNWithoutC) { | ||
| if (!HasCudaEnvironment(11080)) { |
There was a problem hiding this comment.
Blocking test gap: HasCudaEnvironment expects compute capability encoded as 100 * major + 10 * minor (for example, 890 for Ada), not the CUDA toolkit version. No GPU can satisfy >= 11080, so this test always returns before constructing the model. The helper used by the other new scaled FP8 test has the same pre-existing threshold, which means all FP8 coverage in this file is currently skipped. Please use the actual FP8 minimum (890) and preferably GTEST_SKIP() so an unsupported runner reports a skip explicitly.
Use the actual optional C tensor type for cuBLASLt layout descriptors, preserve output-typed fallback descriptors with an effective zero beta when C is absent, and cover mixed and scaled FP8 cases.