Repository navigation
fix: Pass fp_mixed_precision to the reshaped kernel in ClGemm - #1325
nirvanahyj47 wants to merge 1 commit into
Conversation
morgolock
left a comment
There was a problem hiding this comment.
Please address the FP32 compatibility regression before merging.
With FP32 inputs and fp_mixed_precision=true, the new assignment makes RESHAPED fail validation with “Mixed precision only supported for F16 data type.” The same call worked before this change and still works through NATIVE and RESHAPED_ONLY_RHS.
Please gate the flag on F16 in both configure_reshaped() and validate_reshaped():
kernel_info.fp_mixed_precision =
data_type == DataType::F16 && gemm_info.fp_mixed_precision();I reproduced this with M=7, N=5, K=1024 and constant B on Firefly, forcing the RESHAPED dispatch. The intended FP16 accuracy improvement passed both precision-sensitive cases I tested.
Please also add a public CLGEMM regression covering FP16 mixed-precision execution and the existing FP32 behavior with the flag enabled. Existing kernel-level mixed-precision tests bypass the flag propagation being fixed here.
|
Could you share more about your use case for ACL?
As ACL approaches end of life, we want to help users identify suitable migration paths, including KleidiAI or LiteRT where appropriate. Understanding your requirements will help us assess which options could work for you. |
|
Could you please squash the commits into a single change? |
GEMMInfo::fp_mixed_precision() is never copied into the GEMMKernelInfo
that ClGemm builds, so ClGemmMatrixMultiplyReshapedKernel, which adds
-DMIXED_PRECISION (fp32 accumulators) when the flag is set, never sees
it. An F16 CLGEMM configured with fp_mixed_precision = true gives results
and speed identical to the default (max. relative error 1.95e-2 at
N = 256, 4.15e-2 at N = 1024 on a Mali-T628 under Mesa/Rusticl).
Copy the flag in configure_reshaped() and validate_reshaped(), the path
whose kernel implements mixed precision, and only for F16: the reshaped
kernel rejects the flag for other data types ("Mixed precision only
supported for F16 data type"), and an F32 CLGEMM with the flag set has
always ignored it. The native and reshaped_only_rhs kernels reject the
flag, so they keep ignoring it.
Add CLGEMM validation tests for the flag. A new fixture sets
fp_mixed_precision, can make B and C constant (CLGEMM selects the
reshaped kernels only for a constant B), checks that CLGEMM::validate()
accepts the configuration and compares F16 results against the mixed
precision reference. The cases are F16 on the small GEMM shapes and
F32 on the small GEMM shapes plus M = 7, N = 5, K = 1024, each with a
constant and a non-constant B.
With the change, the F16 GEMM with fp_mixed_precision = true gives a
max. relative error of 3.8e-4 to 4.4e-4 for N = 64 to 1024 (no element
off by more than the tolerance), at the same speed within noise
(3.0 / 4.65 / 6.33 GFLOPS for N = 256 / 512 / 1024), and all 26 cases
of the new suite pass on a Mali-T628 (Mesa Rusticl). A run of all CL
GEMM precommit tests gives the same results with and without this
change; the only failures are 14 OUTPUT_3D, INPUT_OUTPUT_3D and
BATCHED_MATMUL cases that this driver rejects at enqueue (no
non-uniform work-group support).
Found and written with Claude Code (Anthropic), a coding assistant;
tested on a Samsung ARTIK 10 (Exynos 5422).
Signed-off-by: Young-Jun Hong <nirvanah@nirvanahyj.com>
52cd181 to
aa42711
Compare
|
Thanks for the review and for reproducing it, and sorry for the delay. I squashed the change into a single commit. It gates the flag on F16 in On a Mali-T628 (Mesa Rusticl), the first version fails the four F32 On the use case: I use ACL directly, not through a framework, on an |
GEMMInfo::fp_mixed_precision() is never copied into the GEMMKernelInfo that ClGemm builds, so ClGemmMatrixMultiplyReshapedKernel, which adds -DMIXED_PRECISION (fp32 accumulators) when the flag is set, never sees it. An F16 CLGEMM configured with fp_mixed_precision = true gives results and speed identical to the default (max. relative error 1.95e-2 at N = 256, 4.15e-2 at N = 1024 on a Mali-T628 under Mesa/Rusticl).
Copy the flag in configure_reshaped() and validate_reshaped(), the path whose kernel implements mixed precision. The native and reshaped_only_rhs kernels reject the flag, so they keep ignoring it.
With the change, the same F16 GEMM with fp_mixed_precision = true gives a max. relative error of 3.8e-4 to 4.4e-4 for N = 64 to 1024 (no element off by more than the tolerance), at the same speed within noise (3.0 / 4.65 / 6.33 GFLOPS for N = 256 / 512 / 1024).
Found and written with Claude Code (Anthropic), a coding assistant; tested on v53.3.1 (Samsung ARTIK 10, Exynos 5422).