# Speed issue with KahanSummation

**URL:** <https://discourse.julialang.org/t/speed-issue-with-kahansummation/75491>\
**Category:** Performance\
**Tags:** question, package, parallel\
**Created:** [January 31, 2022, 6:29am UTC](https://discourse.julialang.org/t/speed-issue-with-kahansummation/75491 "2022-01-31T06:29:26Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![goerch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerch/32/29122_2.png) [@goerch](https://discourse.julialang.org/u/goerch)\
**Post date:** [February 3, 2022, 3:26pm UTC](https://discourse.julialang.org/t/speed-issue-with-kahansummation/75491/12 "2022-02-03T15:26:42Z")

</div>

> [@Elrod](#):
>
> a) `VectorizationBase.Vec` should be ForwardDiff-compatible, but the support for that isn’t great beyond a few examples I needed. Feel free to file an issue.

Thanks for helping out. I had a short look into the error of this [MWE](https://discourse.julialang.org/t/high-precision-summation-functions-not-compatible-with-optim-jl-with-autodiff-forward/75714)

```julia
ERROR: MethodError: no method matching accumulate(::Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{var"#17#18", Float64}, Float64, 2}}}, ::AccurateArithmetic.Summation.var"#1#2"{typeof(AccurateArithmetic.EFT.fast_two_sum)}, ::Val{:scalar}, ::Val{2}, ::Val{0})

```

and noticed `accumulate` restricts the type to reals AFAIU

```julia
@generated function accumulate(x::NTuple{A, AbstractArray{T}},
                               accType::F,
                               rem_handling = Val(:scalar),
                               ::Val{Ushift} = Val(2),
                               ::Val{Prefetch} = Val(0),
                               ) where {F, A, T <: Union{Float32,Float64}, Ushift, Prefetch}

```

Is it possible and does it make sense to generalize this?

---

_[View the full topic](https://discourse.julialang.org/t/speed-issue-with-kahansummation/75491)._
