You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Better error message when trying to run fp16 weights on CPU #96292
module: error checkingBugs related to incorrect/lacking error checkingtriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
@patrickvonplaten@drisspg Can we make it a warning instead of an error? We are in progress adding FP16 support on CPU. The work would improve the functional coverage of FP16 ops (which can address the problems you raise), improve the performance of CPU FP16 ops (expecting performance speedup with non conv/gemm ops, and conv/gemm will be sped up on next generation Xeon processors), add FP16 autocast (check RFC) and add FP16 support in TorchInductor. cc @mingfeima and @CaoE
In general, these error messages could be improved to use standardized dtype names: torch.float16 instead of Half. Same for thing called dispatch code, for sparse tensors the name is quite cryptic SparseCpu when it means torch.sparse_coo_tensor :(
Ah ok in this case maybe not worth it to introduce a new error/warning if Fp16 will work on CPU soon?
Agreed. We will prioritize the ops to cover according to the popular model families. Models from HuggingFace will definitively be at the top. Thanks for the patience.
The original addmm_impl_cpu_ error is now fixed - the _AT_DISPATCH_ADDMM_TYPES macro in LinearAlgebra.cpp now includes kHalf for non-mobile builds.
However, as @vadimkantorov noted, error messages still need improvement - they use internal names like 'Half' instead of user-friendly 'torch.float16'.
I'll submit a PR to improve the dtype formatting in error messages.
module: error checkingBugs related to incorrect/lacking error checkingtriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
Activity
drisspg commentedon Mar 8, 2023
Yeah I think this is a good idea. We would be happy to accept a PR doing this, and I would open to review it
patrickvonplaten commentedon Mar 8, 2023
Cool! Will open a PR for it
jgong5 commentedon Mar 9, 2023
@patrickvonplaten @drisspg Can we make it a warning instead of an error? We are in progress adding FP16 support on CPU. The work would improve the functional coverage of FP16 ops (which can address the problems you raise), improve the performance of CPU FP16 ops (expecting performance speedup with non conv/gemm ops, and conv/gemm will be sped up on next generation Xeon processors), add FP16 autocast (check RFC) and add FP16 support in TorchInductor. cc @mingfeima and @CaoE
patrickvonplaten commentedon Mar 9, 2023
Ah ok in this case maybe not worth it to introduce a new error/warning if Fp16 will work on CPU soon?
vadimkantorov commentedon Mar 9, 2023
In general, these error messages could be improved to use standardized dtype names: torch.float16 instead of Half. Same for thing called dispatch code, for sparse tensors the name is quite cryptic SparseCpu when it means torch.sparse_coo_tensor :(
jgong5 commentedon Mar 10, 2023
Agreed. We will prioritize the ops to cover according to the popular model families. Models from HuggingFace will definitively be at the top. Thanks for the patience.
lileidev commentedon Aug 22, 2024
file location: aten/src/ATen/native/LinearAlgebra.cpp
Why addmm_impl_cpu_ can support bfloat16 but dont't support half?
// Apply BLAS routine
AT_DISPATCH_ALL_TYPES_AND_COMPLEX_AND(kBFloat16,
result.scalar_type(), "addmm_impl_cpu_",
[&]{
using opmath_t = at::opmath_type<scalar_t>;
at::native::cpublas::gemm(
transpose_a ? a.is_conj() ? TransposeType::ConjTranspose : TransposeType::Transpose : TransposeType::NoTranspose,
transpose_b ? b.is_conj() ? TransposeType::ConjTranspose : TransposeType::Transpose : TransposeType::NoTranspose,
m, n, k,
alpha.to<opmath_t>(),
a.data_ptr<scalar_t>(), lda,
b.data_ptr<scalar_t>(), ldb,
beta.to<opmath_t>(),
c.data_ptr<scalar_t>(), ldc);
});
ramaseshanms commentedon Dec 23, 2025
If no one is currently working on this, I’m happy to pick it up and keep the discussion updated.
JonSnow1807 commentedon Jan 14, 2026
I'm picking this up and will submit a PR shortly.
After investigating the codebase:
The original
addmm_impl_cpu_error is now fixed - the_AT_DISPATCH_ADDMM_TYPESmacro inLinearAlgebra.cppnow includeskHalffor non-mobile builds.However, as @vadimkantorov noted, error messages still need improvement - they use internal names like
'Half'instead of user-friendly'torch.float16'.I'll submit a PR to improve the dtype formatting in error messages.
Improve dtype error messages by showing user-friendly names
nn: improve error message for unsupported dtype ops on CPU (pytorch#9…