JuliaDiff / JuliaDiff/Diffractor.jl

Derivatives do not work with non-float types?

Open
#206 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Julia
Stars
453
Forks
33
PR merge metrics
No merged PRs in 30d

Description

E.g. this works fine

julia> derivative(DiffractorForwardBackend(), (a, b) -> sin(a) * cos(b), 1.0, 1.0)

but not this

julia> derivative(DiffractorForwardBackend(), (a, b) -> sin(a) * cos(b), 1, 1)
ERROR: MethodError: no method matching Diffractor.Jet(::Int64, ::Float64, ::Tuple{Float64})

Closest candidates are:
  Diffractor.Jet(::T, ::T, ::Tuple{Vararg{T, N}}) where {T, N}
   @ Diffractor ~/.julia/packages/Diffractor/vzpvE/src/jet.jl:19

Stacktrace:
  [1] njet(::Val{1}, ::typeof(sin), x₀::Int64)
    @ Diffractor ~/.julia/packages/Diffractor/vzpvE/src/higher_fwd_rules.jl:7
  [2] (::Diffractor.∂☆{1})(fb::ZeroBundle{1, typeof(sin)}, x::Diffractor.TangentBundle{1, Int64, Diffractor.TaylorTangent{…}})

and not this

julia> derivative(DiffractorForwardBackend(), (a, b) -> sin(a) * cos(b), π, 1.0)
ERROR: MethodError: no method matching Diffractor.Jet(::Irrational{:π}, ::Float64, ::Tuple{Float64})

Closest candidates are:
  Diffractor.Jet(::T, ::T, ::Tuple{Vararg{T, N}}) where {T, N}
   @ Diffractor ~/.julia/packages/Diffractor/vzpvE/src/jet.jl:19

Stacktrace:
  [1] njet(::Val{1}, ::typeof(sin), x₀::Irrational{:π})
julia> versioninfo()
Julia Version 1.10.0-beta1
Commit 6616549950e (2023-07-25 17:43 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin22.4.0)
  CPU: 12 × Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, skylake)
  Threads: 1 on 12 virtual cores
(jl_8k1XbP) pkg> st
Status `/private/var/folders/86/jlqr7cg52h3dd15zrj_145sr0000gn/T/jl_8k1XbP/Project.toml`
  [c29ec348] AbstractDifferentiation v0.5.2
  [9f5e2b26] Diffractor v0.2.1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the integer and π cases from the report, then inspect src/jet.jl and src/higher_fwd_rules.jl, where the stack traces identify the failing Jet construction and njet call. Done means the reported non-float inputs work with the forward backend without the shown MethodError.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.