Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with sum along a dimension. May be an error in MutableArithmetics.jl. #3851

Closed
dcelisgarza opened this issue Oct 15, 2024 · 2 comments
Closed

Comments

@dcelisgarza
Copy link

dcelisgarza commented Oct 15, 2024

I caught this when doing CI. I reproduced it on my machine. Here's the output using a fresh install of Julia.

julia> versioninfo()
Julia Version 1.11.0
Commit 501a4f25c2 (2024-10-07 11:40 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 16 × AMD Ryzen 7 1700 Eight-Core Processor
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, znver1)
Threads: 1 default, 0 interactive, 1 GC (on 16 virtual cores)

(@v1.11) pkg> update
  Installing known registries into `C:\Users\usr\.julia`
       Added `General` registry to C:\Users\usr\.julia\registries
    Updating registry at `C:\Users\usr\.julia\registries\General.toml`
  No Changes to `C:\Users\usr\.julia\environments\v1.11\Project.toml`
  No Changes to `C:\Users\usr\.julia\environments\v1.11\Manifest.toml`
        Info We haven't cleaned this depot up for a bit, running Pkg.gc()...
      Active manifest files: 1 found
      Active artifact files: 0 found
      Active scratchspaces: 0 found
     Deleted no artifacts, repos, packages or scratchspaces

Add JuMP and nothing else.

julia>]add JuMP

julia> using JuMP

julia> model = JuMP.Model()
A JuMP Model
├ solver: none
├ objective_sense: FEASIBILITY_SENSE
├ num_variables: 0
├ num_constraints: 0
└ Names registered in the model: none

julia> @variable(model, x[1:3,1:5])
3×5 Matrix{VariableRef}:
 x[1,1]  x[1,2]  x[1,3]  x[1,4]  x[1,5]
 x[2,1]  x[2,2]  x[2,3]  x[2,4]  x[2,5]
 x[3,1]  x[3,2]  x[3,3]  x[3,4]  x[3,5]

julia> sum(x, dims=2)
ERROR: MethodError: no method matching operate(::typeof(sum), ::Matrix{VariableRef}; dims::Int64)
This error has been manually thrown, explicitly, so the method may exist but be intentionally marked as unimplemented.

Closest candidates are:
  operate(::typeof(sum), ::AbstractArray; init) got unsupported keyword argument "dims"
   @ MutableArithmetics C:\Users\usr\.julia\packages\MutableArithmetics\6jxVC\src\reduce.jl:53
  operate(::typeof(LinearAlgebra.dot), ::AbstractArray, ::AbstractArray) got unsupported keyword argument "dims"
   @ MutableArithmetics C:\Users\usr\.julia\packages\MutableArithmetics\6jxVC\src\implementations\LinearAlgebra.jl:521
  operate(::typeof(*), ::AbstractMatrix{S}, ::AbstractMatrix{T}) where {T, S} got unsupported keyword argument "dims"
   @ MutableArithmetics C:\Users\usr\.julia\packages\MutableArithmetics\6jxVC\src\implementations\LinearAlgebra.jl:426
  ...

Stacktrace:
 [1] kwerr(::@NamedTuple{dims::Int64}, ::Function, ::Function, ::Matrix{VariableRef})
   @ Base .\error.jl:165
 [2] sum(a::Matrix{VariableRef}; kwargs::@Kwargs{dims::Int64})
   @ MutableArithmetics C:\Users\usr\.julia\packages\MutableArithmetics\6jxVC\src\dispatch.jl:17
 [3] top-level scope
   @ REPL[5]:1

julia> sum(x)
x[1,1] + x[2,1] + x[3,1] + x[1,2] + x[2,2] + x[3,2] + x[1,3] + x[2,3] + x[3,3] + x[1,4] + x[2,4] + x[3,4] + x[1,5] + x[2,5] + x[3,5]

When I check the methods table for sum, I get the following output.

julia> methods(sum)
# 14 methods for generic function "sum" from Base:
  [1] sum(r::StepRangeLen{<:Any, <:Base.TwicePrecision, <:Base.TwicePrecision})
     @ twiceprecision.jl:603
  [2] sum(r::StepRangeLen)
     @ twiceprecision.jl:588
  [3] sum(r::AbstractRange{<:Real})
     @ range.jl:1405
  [4] sum(ct::DataStructures.Accumulator)
     @ DataStructures C:\Users\usr\.julia\packages\DataStructures\95DJa\src\accumulator.jl:60
  [5] sum(x::Union{JuMP.Containers.DenseAxisArray, JuMP.Containers.DenseAxisArrayView}; dims)
     @ JuMP.Containers C:\Users\usr\.julia\packages\JuMP\6RAQ9\src\Containers\DenseAxisArray.jl:863
  [6] sum(a::AbstractArray{<:MutableArithmetics.AbstractMutable}; kwargs...)
     @ MutableArithmetics C:\Users\usr\.julia\packages\MutableArithmetics\6jxVC\src\dispatch.jl:16
  [7] sum(arr::AbstractArray{BigFloat})
     @ Base.MPFR mpfr.jl:848
  [8] sum(a::AbstractArray{Bool}; kw...)
     @ reduce.jl:562
  [9] sum(arr::Union{Tuple{BigInt, Vararg{BigInt}}, AbstractArray{BigInt}})
     @ Base.GMP gmp.jl:679
 [10] sum(a::AbstractArray; dims, kw...)
     @ reducedim.jl:982
 [11] sum(f::F, x::Union{JuMP.Containers.DenseAxisArray, JuMP.Containers.DenseAxisArrayView}; dims) where F<:Function
     @ JuMP.Containers C:\Users\usr\.julia\packages\JuMP\6RAQ9\src\Containers\DenseAxisArray.jl:848
 [12] sum(f, a::AbstractArray; dims, kw...)
     @ reducedim.jl:983
 [13] sum(f, a; kw...)
     @ reduce.jl:532
 [14] sum(a; kw...)
     @ reduce.jl:561

When I use the @which macro I get this.

julia> @which sum(x)
sum(a::AbstractArray{<:MutableArithmetics.AbstractMutable}; kwargs...)
     @ MutableArithmetics C:\Users\usr\.julia\packages\MutableArithmetics\6jxVC\src\dispatch.jl:16

julia> @which sum(x, dims=2)
kwcall(::NamedTuple, ::typeof(sum), a::AbstractArray{<:MutableArithmetics.AbstractMutable})
     @ MutableArithmetics C:\Users\usr\.julia\packages\MutableArithmetics\6jxVC\src\dispatch.jl:16

It seems the error is in MutableArithmetics.jl. It's weird because it wasn't failing a few days ago, and it fails on CI as well as my pc.

Any insight?

@dcelisgarza dcelisgarza changed the title Error with sum along a dimension. May be an error in a dependency. Error with sum along a dimension. May be an error in MutableArithmetics.jl. Oct 15, 2024
@dcelisgarza
Copy link
Author

I think it's related to this issue, which is currently open.

JuliaLang/julia#55570

@odow
Copy link
Member

odow commented Oct 16, 2024

Closing in favor of jump-dev/MutableArithmetics.jl#309

I have a fix in jump-dev/MutableArithmetics.jl#310 that I'll try to release ASAP.

@odow odow closed this as completed Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants