Releases: brianguenter/FastDifferentiation.jl
v0.4.2
FastDifferentiation v0.4.2
fixed bug which was causing enormous asymptotic slowdowns in evaluation of FD expressions. For modest size graphs, 1e4 nodes, should be approximately 100x faster. Speed improvement increases as graph size increases so for very large graphs, 1e6 nodes, speed improvement should be at least 1000x.
Merged pull requests:
- update ci.yml to use latest julia checkout (#97) (@brianguenter)
- fixed bug in is_variable. Was recursing through the graph for each call. Asymptotically slower than it should have been. (#101) (@brianguenter)
Closed issues:
v0.4.1
FastDifferentiation v0.4.1
This is a patch to fix two bugs, one introduced in 0.3.17 and one introduced in 0.4.0 when conditionals were added as a feature. These bugs caused derivative(x^y)
to fail. Other less commonly used functions were also affected. Neither 0.3.17 nor 0.4.0 should be used.
This release makes it possible to do two things:
Create an FD function that contains conditionals: f = if_else(x<y,x,y)
where x,y
are both FD variables.
Take derivatives of functions whose derivative definitions use conditionals. For example, the derivative definition for mod2pi
is now
DiffRules.@define_diffrule Base.mod2pi(x) = :(if_else(isinteger($x / $DiffRules.twoΟ), oftype(float($x), NaN), one(float($x))))
Example: derivative of mod2pi
julia> @variables x
x
julia> f = mod2pi(x)
mod2pi(x)
julia> derivative([f],x)
1-element Vector{FastDifferentiation.Node}:
(if_else isinteger((x / twoΟ)) NaN 1)
julia> g = derivative([f],x)
1-element Vector{FastDifferentiation.Node}:
(if_else isinteger((x / twoΟ)) NaN 1)
julia> h = make_function(g,[x])
RuntimeGeneratedFunction(#=in FastDifferentiation=#, #=using FastDifferentiation=#, :((input_variables,)->begin
#= c:\Users\seatt\source\FastDifferentiation.jl\src\CodeGeneration.jl:229 =#
#= c:\Users\seatt\source\FastDifferentiation.jl\src\CodeGeneration.jl:229 =# @inbounds begin
#= c:\Users\seatt\source\FastDifferentiation.jl\src\CodeGeneration.jl:230 =#
begin
result_element_type = promote_type(Float64, eltype(input_variables))
result = Array{result_element_type}(undef, (1,))
var"##227" = input_variables[1] / twoΟ
var"##226" = isinteger(var"##227")
var"##225" = if var"##226"
#= c:\Users\seatt\source\FastDifferentiation.jl\src\CodeGeneration.jl:58 =#
begin
var"##s#228" = NaN
end
else
#= c:\Users\seatt\source\FastDifferentiation.jl\src\CodeGeneration.jl:60 =#
begin
var"##s#229" = 1
end
end
result[1] = var"##225"
return result
end
end
end))
julia> h(2*pi)
1-element Vector{Float64}:
NaN
You cannot (yet) take derivatives of a function which contains conditionals. This will come in a future PR.
julia> f = if_else(x<y,x,y)
(if_else (x < y) x y)
julia> derivative([f],x)
ERROR: Your expression contained a if_else expression. FastDifferentiation does not yet support differentiation through this function)
Merged pull requests:
- Patch to correct bug introduced when added conditionals in PR #90 (comment) (#93) (@brianguenter)
Closed issues:
- Yank version 0.4.0? (#92)
v0.4.0
FastDifferentiation v0.4.0
WARNING: version 0.4.0 is broken. Revert to 0.3.17 until a patch release is made. Look here for details
Adds support for conditional expressions so you can write expresssions like ifelse(x<y,x,y)
where x,y
are FD nodes. Does not yet support differentiation through conditionals. This will come in another PR.
This may be a breaking change for some users since the meaning of x==y
has changed from previous versions of FD.
Previously x==y
returned Bool
. If you were storing FD Node
objects in a Dict
then ==
would have been used to determine if two entries were identical.
In the new version this code would no longer work because x==y
returns and FD Node
object.
Instead of Dict
you should use IDict
which uses ===
to test for identical elements.
There are undoubtedly other data structures where similar problems might arise.
Merged pull requests:
- Brianguenter/issue89 (#90) (@brianguenter)
Closed issues:
v0.3.17
FastDifferentiation v0.3.17
0.3.16 didn't pick up the patch to make Node <: Real. This is an attempt to fix the problem.
v0.3.16
FastDifferentiation v0.3.16
Before this patch FastDifferentiation expressions were a subtype of Number. Many Julia packages only worked with number types <: Real so they wouldn't work with FD expressions. This patch fixes this problem so now FD expressions <: Real. This should make FD more compatible with the Julia ecosystem.
Merged pull requests:
- would it make sense to have FastDifferentiation.Node <: Real? (#88) (@brianguenter)
Closed issues:
v0.3.15
FastDifferentiation v0.3.15
added Base methods to make type promotion work properly #85 (comment)
Merged pull requests:
- Add some more base methods (#85) (@elaine-ran)
Closed issues:
- Support for AbstractDifferentiation.jl / DifferentiationInterface.jl (#37)
v0.3.14
FastDifferentiation v0.3.14
patch update to fix unbound variables problem #83 (comment) and eliminate unnecessary dependencies #82 (comment)
Merged pull requests:
- project: delete highly undesirable unused strong deps (#82) (@nsajko)
- methods with unbound static parameters (#84) (@brianguenter)
Closed issues:
- methods with unbound static parameters (#83)
v0.3.13
FastDifferentiation v0.3.13
Merged pull requests:
- subgraph factorization order incorrect (#81) (@brianguenter)
Closed issues:
- subgraph factorization order incorrect (#80)
v0.3.12
FastDifferentiation v0.3.12
Merged pull requests:
- Bump julia-actions/cache from 1 to 2 (#79) (@dependabot[bot])
v0.3.11
FastDifferentiation v0.3.11
Patch to fix problems caused by edges to constant nodes in derivative graph.
Edges in the derivative graph which lead to constant nodes can cause incorrect reachability results in other edges in the graph. This causes an error of the form "there is more than 1 path from root i to variable j".
This fixes the bug by deleting edges to constant nodes upon derivative graph construction. These edges play no part in the derivative evaluation anyway so it is unnecessary to keep them.
Merged pull requests:
- Brianguenter/issue40 (#78) (@brianguenter)
Closed issues:
- Non-unique path assertion in
follow_path
(#40)