Skip to content

Commit

Permalink
chore: bump dependencies (#85)
Browse files Browse the repository at this point in the history
* chore: bump dependencies

* test: skip QuadraticSpline again

* fix: GPU compilation of some basis functions
  • Loading branch information
avik-pal authored Nov 17, 2024
1 parent 66db89a commit b998e65
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 22 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Boltz"
uuid = "4544d5e4-abc5-4dea-817f-29e4c205d9c8"
authors = ["Avik Pal <[email protected]> and contributors"]
version = "1.0.3"
version = "1.1.0"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down Expand Up @@ -51,7 +51,7 @@ ChainRulesCore = "1.24"
Compat = "4.15"
ConcreteStructs = "0.2.3"
DataInterpolations = "6.4"
DynamicExpressions = "0.16, 0.17, 0.18, 0.19, 1"
DynamicExpressions = "1"
ForwardDiff = "0.10.36"
Functors = "0.4.12, 0.5"
GPUArraysCore = "0.1.6, 0.2"
Expand Down
6 changes: 3 additions & 3 deletions examples/SymbolicOptimalControl/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SymbolicUtils = "d1185830-fcd6-423d-90d6-eec64667417b"
Boltz = "1"
CairoMakie = "0.12"
ComponentArrays = "0.15.11"
DynamicExpressions = "0.16, 0.17, 0.18, 0.19, 1"
DynamicExpressions = "1"
Latexify = "0.16.2"
Literate = "2"
Lux = "1"
Expand All @@ -34,5 +34,5 @@ OptimizationOptimisers = "0.3.2"
OrdinaryDiffEqVerner = "1"
SciMLSensitivity = "7.57"
Statistics = "1.10"
SymbolicRegression = "0.24.1"
SymbolicUtils = "1.5.1, 2, 3"
SymbolicRegression = "1"
SymbolicUtils = "3"
21 changes: 10 additions & 11 deletions ext/BoltzDynamicExpressionsExt.jl
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
module BoltzDynamicExpressionsExt

using ChainRulesCore: NoTangent
using DynamicExpressions: DynamicExpressions, Node, OperatorEnum, eval_grad_tree_array,
eval_tree_array
using DynamicExpressions: DynamicExpressions, Node, OperatorEnum, EvalOptions, Expression,
eval_grad_tree_array, eval_tree_array
using ForwardDiff: ForwardDiff

using Lux: Lux, Chain, Parallel, WrappedFunction
using MLDataDevices: CPUDevice

using Boltz: Layers, Utils

@static if pkgversion(DynamicExpressions) v"0.19"
using DynamicExpressions: EvalOptions

const EvalOptionsTypes = Union{Missing, EvalOptions, NamedTuple}
else
const EvalOptionsTypes = Union{Missing, NamedTuple}
end
const EvalOptionsTypes = Union{Missing, EvalOptions, NamedTuple}

Utils.is_extension_loaded(::Val{:DynamicExpressions}) = true

Expand Down Expand Up @@ -45,11 +39,13 @@ function construct_eval_options(::EvalOptionsTypes, ::EvalOptionsTypes)
end

function Layers.DynamicExpressionsLayer(
operator_enum::OperatorEnum, expressions::AbstractVector{<:Node}; kwargs...)
operator_enum::OperatorEnum, expressions::AbstractVector{<:Union{Node, Expression}};
kwargs...)
return Layers.DynamicExpressionsLayer(operator_enum, expressions...; kwargs...)
end

function Layers.DynamicExpressionsLayer(operator_enum::OperatorEnum, expressions::Node...;
function Layers.DynamicExpressionsLayer(operator_enum::OperatorEnum,
expressions::Union{Node, Expression}...;
eval_options::EvalOptionsTypes=missing, turbo::Union{Bool, Val, Missing}=missing,
bumper::Union{Bool, Val, Missing}=missing)
eval_options = construct_eval_options(
Expand Down Expand Up @@ -161,4 +157,7 @@ function Layers.apply_dynamic_expression(
return ForwardDiff.Dual{Tag, fT, N}.(y, partials_y)
end

Layers.dynamic_expression_get_node(expr::Expression) = expr.tree
Layers.dynamic_expression_get_node(expr::Node) = expr

end
8 changes: 6 additions & 2 deletions src/basis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ Constructs a sine basis of the form $[\sin(x), \sin(2x), \dots, \sin(nx)]$.
- `dim::Int=1`: The dimension along which the basis functions are applied.
"""
Sin(n; dim::Int=1) = GeneralBasisFunction{:Sin}(@fastmath(sin∘*), n, dim)
Sin(n; dim::Int=1) = GeneralBasisFunction{:Sin}(sin_mul, n, dim)

sin_mul(x, y) = @fastmath(sin(x * y))

@doc doc"""
Cos(n; dim::Int=1)
Expand All @@ -92,7 +94,9 @@ Constructs a cosine basis of the form $[\cos(x), \cos(2x), \dots, \cos(nx)]$.
- `dim::Int=1`: The dimension along which the basis functions are applied.
"""
Cos(n; dim::Int=1) = GeneralBasisFunction{:Cos}(@fastmath(cos∘*), n, dim)
Cos(n; dim::Int=1) = GeneralBasisFunction{:Cos}(cos_mul, n, dim)

cos_mul(x, y) = @fastmath(cos(x * y))

@doc doc"""
Fourier(n; dim=1)
Expand Down
13 changes: 11 additions & 2 deletions src/layers/dynamic_expressions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,21 @@ end

function LuxCore.initialparameters(::AbstractRNG, layer::InternalDynamicExpressionWrapper)
params = map(Base.Fix2(getproperty, :val),
filter(node -> node.degree == 0 && node.constant, layer.expression))
filter(
node -> node.degree == 0 && node.constant,
dynamic_expression_get_node(layer.expression)
)
)
return (; params)
end

function update_de_expression_constants!(expression, ps)
# Don't use `set_constant_refs!` here, since it requires the types to match. In our
# case we just warn the user
params = filter(node -> node.degree == 0 && node.constant, expression)
params = filter(
node -> node.degree == 0 && node.constant,
dynamic_expression_get_node(expression)
)
foreach(enumerate(params)) do (i, node)
(node.val isa typeof(ps[i])) ||
@warn lazy"node.val::$(typeof(node.val)) != ps[$i]::$(typeof(ps[i])). Type of node.val takes precedence. Fix the input expression if this is unintended." maxlog=1
Expand Down Expand Up @@ -142,3 +149,5 @@ end
function apply_dynamic_expression_internal end

function ∇apply_dynamic_expression end

function dynamic_expression_get_node end
2 changes: 1 addition & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Bumper = "0.6, 0.7"
ComponentArrays = "0.15.16"
DataInterpolations = "6.4"
Downloads = "1.6"
DynamicExpressions = "0.16, 0.17, 0.18, 0.19, 1"
DynamicExpressions = "1"
Enzyme = "0.13"
ExplicitImports = "1.9.0"
ForwardDiff = "0.10.36"
Expand Down
4 changes: 3 additions & 1 deletion test/layer_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ end

@testset "$(spl): train_grid $(train_grid), dims $(dims)" for spl in (
ConstantInterpolation, LinearInterpolation,
QuadraticInterpolation, QuadraticSpline, CubicSpline),
QuadraticInterpolation,
# QuadraticSpline, # XXX: DataInterpolations.jl broke it again!!!
CubicSpline),
train_grid in (true, false),
dims in ((), (8,))

Expand Down

2 comments on commit b998e65

@avik-pal
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/119642

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.1.0 -m "<description of version>" b998e6533e917d642fb64d8da70000963b818476
git push origin v1.1.0

Please sign in to comment.