diff --git a/Project.toml b/Project.toml index c788bd0..fec6be5 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "HybridVariationalInference" uuid = "a108c475-a4e2-4021-9a84-cfa7df242f64" authors = ["Thomas Wutzler and contributors"] -version = "0.2" +version = "0.2.0" [deps] Bijectors = "76274a88-744f-5084-9051-94815aaf08c4" @@ -31,6 +31,7 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" StatsFuns = "4c63d2b9-4356-54db-8cca-17b64c39e42c" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed" Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" [weakdeps] @@ -69,7 +70,7 @@ MLUtils = "0.4.5" Missings = "1.2.0" NaNMath = "1.1.3" Optimisers = "0.4.6" -Optimization = "3.19.3, 4" +Optimization = "3.11, 4" Random = "1.10.0" SimpleChains = "0.4" StableRNGs = "1.0.2" @@ -77,6 +78,7 @@ StaticArrays = "1.9.13" StatsBase = "0.34.4" StatsFuns = "1.3.2" Test = "1.10" +UnPack = "1.0.2" Zygote = "0.7.10" julia = "1.10" diff --git a/README.md b/README.md index e3df30f..63c4880 100644 --- a/README.md +++ b/README.md @@ -55,9 +55,10 @@ of the posterior. It returns a NamedTuple of - the machine learning model parameters (usually weights), $\phi_g$ - means of the global parameters, $\phi_P = \mu_{\zeta_P}$ at transformed unconstrained scale - - additional parameters, $\phi_{unc}$ of the posterior, $q(\zeta)$, such as - coefficients that describe the scaling of variance with magnitude - and coefficients that parameterize the choleski-factor or the correlation matrix. + - additional parameters, $\phi_{ϕq}$ of the posterior, $q(\zeta)$, such as + - coefficients that describe the scaling of variance with magnitude + - coefficients that parameterize the choleski-factor or the correlation matrix + - mean of global parameters at unconstrained scale - `θP`: predicted means of the global parameters, $\theta_P$ - `resopt`: the original result object of the optimizer (useful for debugging) diff --git a/docs/src/tutorials/Project.toml b/docs/src/tutorials/Project.toml index 59ffeee..db69162 100644 --- a/docs/src/tutorials/Project.toml +++ b/docs/src/tutorials/Project.toml @@ -15,6 +15,8 @@ PairPlots = "43a3c2be-4208-490b-832a-a21dcd55d7da" Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" SimpleChains = "de6bee2f-e2f4-4ec7-b6ed-219cc6f6e9e5" StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3" +StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" StatsFuns = "4c63d2b9-4356-54db-8cca-17b64c39e42c" +UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed" Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" cuDNN = "02a925ec-e4fe-4b08-9a7e-0d78e3d38ccd" diff --git a/docs/src/tutorials/basic_cpu.md b/docs/src/tutorials/basic_cpu.md index c3475ec..b8031ac 100644 --- a/docs/src/tutorials/basic_cpu.md +++ b/docs/src/tutorials/basic_cpu.md @@ -17,6 +17,7 @@ using SimpleChains using StatsFuns using MLUtils using DistributionFits +using UnPack ``` Next, specify many moving parts of the Hybrid variational inference (HVI) @@ -33,9 +34,7 @@ $$ ``` julia function f_doubleMM(θc::CA.ComponentVector{ET}, x) where ET # extract parameters not depending on order, i.e whether they are in θP or θM - (r0, r1, K1, K2) = map((:r0, :r1, :K1, :K2)) do par - CA.getdata(θc[par])::ET - end + @unpack r0, r1, K1, K2 = θc r0 .+ r1 .* x.S1 ./ (K1 .+ x.S1) .* x.S2 ./ (K2 .+ x.S2) end ``` @@ -157,7 +156,7 @@ the problem below. ### Providing data in batches -HVI uses `MLUtils.DataLoader` to provide baches of the data during each +HVI uses `MLUtils.DataLoader` to provide batches of the data during each iteration of the solver. In addition to the data, it provides an index to the sites inside a tuple. @@ -165,7 +164,8 @@ index to the sites inside a tuple. n_site = size(y_o,2) n_batch = 20 train_dataloader = MLUtils.DataLoader( - (xM, xP, y_o, y_unc, 1:n_site), batchsize=n_batch, partial=false) + (CA.getdata(xM), CA.getdata(xP), y_o, y_unc, 1:n_site), + batchsize=n_batch, partial=false) ``` ## The Machine-Learning model @@ -211,7 +211,7 @@ However, for simplicity, a [`NormalScalingModelApplicator`](@ref) is fitted to the transformed 5% and 95% quantiles of the original prior. ``` julia -priorsM = [priors_dict[k] for k in keys(θM)] +priorsM = Tuple(priors_dict[k] for k in keys(θM)) lowers, uppers = get_quantile_transformed(priorsM, transM) g_chain_scaled = NormalScalingModelApplicator(g_chain_app, lowers, uppers, FT) ``` @@ -231,8 +231,9 @@ invocation of the process based model (PBM), defined at the beginning. ``` julia f_batch = PBMSiteApplicator(f_doubleMM; θP, θM, θFix, xPvec=xP[:,1]) +ϕq0 = init_hybrid_ϕq(MeanHVIApproximation(), θP, θM, transP) -prob = HybridProblem(θP, θM, g_chain_scaled, ϕg0, +prob = HybridProblem(θM, ϕq0, g_chain_scaled, ϕg0, f_batch, priors_dict, py, transM, transP, train_dataloader, n_covar, n_site, n_batch) ``` @@ -267,7 +268,7 @@ Then the solver is applied to the problem using [`solve`](@ref) for a given number of iterations or epochs. For this tutorial, we additionally specify that the function to transfer structures to the GPU is the identity function, so that all stays on the CPU, and this tutorial -hence does not require ad GPU or GPU livraries. +hence does not require ad GPU or GPU libraries. Among the return values are - `probo`: A copy of the HybridProblem, with updated optimized parameters @@ -276,7 +277,7 @@ will help analyzing the results. ## Using a population-level process-based model -So far, the process-based model ram for each single site. +So far, the process-based model ran for each single site. For this simple model, some performance grains result from matrix-computations when running the model for all sites within one batch simultaneously. @@ -289,29 +290,25 @@ one site. For the drivers and predictions, one column corresponds to one site. ``` julia function f_doubleMM_sites(θc::CA.ComponentMatrix, xPc::CA.ComponentMatrix) # extract several covariates from xP - ST = typeof(CA.getdata(xPc)[1:1,:]) # workaround for non-type-stable Symbol-indexing - S1 = (CA.getdata(xPc[:S1,:])::ST) - S2 = (CA.getdata(xPc[:S2,:])::ST) + S1 = view(xPc, Val(:S1), :) + S2 = view(xPc, Val(:S2), :) # # extract the parameters as row-repeated vectors - n_obs = size(S1, 1) - VT = typeof(CA.getdata(θc)[:,1]) # workaround for non-type-stable Symbol-indexing - (r0, r1, K1, K2) = map((:r0, :r1, :K1, :K2)) do par - p1 = CA.getdata(θc[:, par]) ::VT - repeat(p1', n_obs) # matrix: same for each concentration row in S1 - end - # + # θc[:,:r0] is parameter r0 for each site in batch + # dot-multiplication of full matrix times row-vector repeats for each observation row + # also introduces zero for missing observations, leading to zero gradient there + is_valid = isfinite.(S1) .&& isfinite.(S2) + r0 = is_valid .* CA.getdata(θc[:, Val(:r0)])' + r1 = is_valid .* CA.getdata(θc[:, Val(:r1)])' + K1 = is_valid .* CA.getdata(θc[:, Val(:K1)])' + K2 = is_valid .* CA.getdata(θc[:, Val(:K2)])' # each variable is a matrix (n_obs x n_site) r0 .+ r1 .* S1 ./ (K1 .+ S1) .* S2 ./ (K2 .+ S2) end ``` Again, the function should not rely on the order of parameters but use symbolic indexing -to extract the parameter vectors. For type stability of this symbolic indexing, -it uses a workaround to get the type of a single row. -Similarly, it uses type hints to index into the drivers, `xPc`, to extract -sub-matrices by symbols. Alternatively, here it could rely on the structure and -ordering of the columns in `xPc`. +to extract the parameter vectors. A corresponding [`PBMPopulationApplicator`](@ref) transforms calls with partitioned global and site parameters to calls of this matrix version of the PBM. @@ -323,11 +320,9 @@ probo_sites = HybridProblem(probo; f_batch) ``` For numerical efficiency, the number of sites within one batch is part of the -`PBMPopulationApplicator`. Hence, we have two different functions, one applied -to a batch of site, and another applied to all sites. - -As a test of the new applicator, the results are refined by running a few more -epochs of the optimization. +`PBMPopulationApplicator`. The problem stores an applicator for `n_batch` sites, +however, an applicator for `n_site_pred` sites can be obtained by +`create_nsite_applicator(f_batch, n_site_pred)`. ``` julia (; probo) = solve(probo_sites, solver; rng, @@ -344,7 +339,7 @@ in the following [Inspect results of fitted problem](@ref) tutorial. In order to use the results from this tutorial in other tutorials, the updated `probo` `HybridProblem` and the interpreters are saved to a JLD2 file. -Before the problem is updated to use the redefinition [`DoubleMM.f_doubleMM_sites`](@ref) +Before the problem is updated, so that it uses the redefinition [`DoubleMM.f_doubleMM_sites`](@ref) of the PBM in module `DoubleMM` rather than module `Main` to allow for easier reloading with JLD2. diff --git a/docs/src/tutorials/basic_cpu.qmd b/docs/src/tutorials/basic_cpu.qmd index 39cf0a5..6e3389d 100644 --- a/docs/src/tutorials/basic_cpu.qmd +++ b/docs/src/tutorials/basic_cpu.qmd @@ -27,6 +27,7 @@ using SimpleChains using StatsFuns using MLUtils using DistributionFits +using UnPack ``` Next, specify many moving parts of the Hybrid variational inference (HVI) @@ -42,9 +43,7 @@ $$ ```{julia} function f_doubleMM(θc::CA.ComponentVector{ET}, x) where ET # extract parameters not depending on order, i.e whether they are in θP or θM - (r0, r1, K1, K2) = map((:r0, :r1, :K1, :K2)) do par - CA.getdata(θc[par])::ET - end + @unpack r0, r1, K1, K2 = θc r0 .+ r1 .* x.S1 ./ (K1 .+ x.S1) .* x.S2 ./ (K2 .+ x.S2) end ``` @@ -166,7 +165,7 @@ the problem below. ### Providing data in batches -HVI uses `MLUtils.DataLoader` to provide baches of the data during each +HVI uses `MLUtils.DataLoader` to provide batches of the data during each iteration of the solver. In addition to the data, it provides an index to the sites inside a tuple. @@ -174,7 +173,8 @@ index to the sites inside a tuple. n_site = size(y_o,2) n_batch = 20 train_dataloader = MLUtils.DataLoader( - (xM, xP, y_o, y_unc, 1:n_site), batchsize=n_batch, partial=false) + (CA.getdata(xM), CA.getdata(xP), y_o, y_unc, 1:n_site), + batchsize=n_batch, partial=false) ``` ## The Machine-Learning model @@ -220,7 +220,7 @@ However, for simplicity, a [`NormalScalingModelApplicator`](@ref) is fitted to the transformed 5% and 95% quantiles of the original prior. ```{julia} -priorsM = [priors_dict[k] for k in keys(θM)] +priorsM = Tuple(priors_dict[k] for k in keys(θM)) lowers, uppers = get_quantile_transformed(priorsM, transM) g_chain_scaled = NormalScalingModelApplicator(g_chain_app, lowers, uppers, FT) ``` @@ -241,8 +241,9 @@ invocation of the process based model (PBM), defined at the beginning. ```{julia} f_batch = PBMSiteApplicator(f_doubleMM; θP, θM, θFix, xPvec=xP[:,1]) +ϕq0 = init_hybrid_ϕq(MeanHVIApproximation(), θP, θM, transP) -prob = HybridProblem(θP, θM, g_chain_scaled, ϕg0, +prob = HybridProblem(θM, ϕq0, g_chain_scaled, ϕg0, f_batch, priors_dict, py, transM, transP, train_dataloader, n_covar, n_site, n_batch) ``` @@ -302,7 +303,7 @@ Then the solver is applied to the problem using [`solve`](@ref) for a given number of iterations or epochs. For this tutorial, we additionally specify that the function to transfer structures to the GPU is the identity function, so that all stays on the CPU, and this tutorial -hence does not require ad GPU or GPU livraries. +hence does not require ad GPU or GPU libraries. Among the return values are - `probo`: A copy of the HybridProblem, with updated optimized parameters @@ -311,7 +312,7 @@ Among the return values are ## Using a population-level process-based model -So far, the process-based model ram for each single site. +So far, the process-based model ran for each single site. For this simple model, some performance grains result from matrix-computations when running the model for all sites within one batch simultaneously. @@ -323,31 +324,28 @@ one site. For the drivers and predictions, one column corresponds to one site. ```{julia} +using StaticArrays function f_doubleMM_sites(θc::CA.ComponentMatrix, xPc::CA.ComponentMatrix) # extract several covariates from xP - ST = typeof(CA.getdata(xPc)[1:1,:]) # workaround for non-type-stable Symbol-indexing - S1 = (CA.getdata(xPc[:S1,:])::ST) - S2 = (CA.getdata(xPc[:S2,:])::ST) + S1 = view(xPc, Val(:S1), :) + S2 = view(xPc, Val(:S2), :) # # extract the parameters as row-repeated vectors - n_obs = size(S1, 1) - VT = typeof(CA.getdata(θc)[:,1]) # workaround for non-type-stable Symbol-indexing - (r0, r1, K1, K2) = map((:r0, :r1, :K1, :K2)) do par - p1 = CA.getdata(θc[:, par]) ::VT - repeat(p1', n_obs) # matrix: same for each concentration row in S1 - end - # + # θc[:,:r0] is parameter r0 for each site in batch + # dot-multiplication of full matrix times row-vector repeats for each observation row + # also introduces zero for missing observations, leading to zero gradient there + is_valid = isfinite.(S1) .&& isfinite.(S2) + r0 = is_valid .* CA.getdata(θc[:, Val(:r0)])' + r1 = is_valid .* CA.getdata(θc[:, Val(:r1)])' + K1 = is_valid .* CA.getdata(θc[:, Val(:K1)])' + K2 = is_valid .* CA.getdata(θc[:, Val(:K2)])' # each variable is a matrix (n_obs x n_site) r0 .+ r1 .* S1 ./ (K1 .+ S1) .* S2 ./ (K2 .+ S2) end ``` Again, the function should not rely on the order of parameters but use symbolic indexing -to extract the parameter vectors. For type stability of this symbolic indexing, -it uses a workaround to get the type of a single row. -Similarly, it uses type hints to index into the drivers, `xPc`, to extract -sub-matrices by symbols. Alternatively, here it could rely on the structure and -ordering of the columns in `xPc`. +to extract the parameter vectors. A corresponding [`PBMPopulationApplicator`](@ref) transforms calls with partitioned global and site parameters to calls of this matrix version of the PBM. @@ -359,11 +357,9 @@ probo_sites = HybridProblem(probo; f_batch) ``` For numerical efficiency, the number of sites within one batch is part of the -`PBMPopulationApplicator`. Hence, we have two different functions, one applied -to a batch of site, and another applied to all sites. - -As a test of the new applicator, the results are refined by running a few more -epochs of the optimization. +`PBMPopulationApplicator`. The problem stores an applicator for `n_batch` sites, +however, an applicator for `n_site_pred` sites can be obtained by +`create_nsite_applicator(f_batch, n_site_pred)`. ```{julia} (; probo) = solve(probo_sites, solver; rng, @@ -379,7 +375,7 @@ in the following [Inspect results of fitted problem](@ref) tutorial. In order to use the results from this tutorial in other tutorials, the updated `probo` `HybridProblem` and the interpreters are saved to a JLD2 file. -Before the problem is updated to use the redefinition [`DoubleMM.f_doubleMM_sites`](@ref) +Before the problem is updated, so that it uses the redefinition [`DoubleMM.f_doubleMM_sites`](@ref) of the PBM in module `DoubleMM` rather than module `Main` to allow for easier reloading with JLD2. diff --git a/docs/src/tutorials/blocks_corr.md b/docs/src/tutorials/blocks_corr.md index 27a8629..5244069 100644 --- a/docs/src/tutorials/blocks_corr.md +++ b/docs/src/tutorials/blocks_corr.md @@ -54,7 +54,8 @@ The defaults specifies a single entry, meaning, there is only one big block respectively, spanning all parameters. ``` julia -cor_ends0 = (P=[length(prob.θP)], M=[length(prob.θM)]) +pt = get_hybridproblem_par_templates(prob) +cor_ends0 = (P=[length(pt.θP)], M=[length(pt.θM)]) ``` (P = [1], M = [2]) @@ -64,39 +65,29 @@ in the correlation block the site parameters, i.e. treating all parameters independently with not modelling any correlations between them. ``` julia -cor_ends = (P=[length(prob.θP)], M=1:length(prob.θM)) +cor_ends = (P=[length(pt.θP)], M=1:length(pt.θM)) ``` (P = [1], M = 1:2) -## Reinitialize parameters for the posterior approximation. - -HVI uses additional fitted parameters to represent the means and the -covariance matrix of the posterior distribution of model parameters. -With fewer correlations, also the number of those parameters changes, -and those parameters must be reinitialized after changing the block structure in -the correlation matrix. - -Here, we obtain construct initial estimates. using [`init_hybrid_ϕunc`](@ref) - -``` julia -ϕunc = init_hybrid_ϕunc(cor_ends, zero(eltype(prob.θM))) -``` - -In this two-site parameter case, the the blocked structure saves only one degree of freedom: +## Update the problem and redo the inversion ``` julia -length(ϕunc), length(probo_cor.ϕunc) +prob_ind = HybridProblem(prob; cor_ends) ``` - (5, 6) +HVI uses additional fitted parameters to represent the means and the +covariance matrix of the posterior distribution of model parameters. +With fewer correlations, also the correlation parameters changes. -## Update the problem and redo the inversion +Check that the new specification uses fewer parameters. ``` julia -prob_ind = HybridProblem(prob; cor_ends, ϕunc) +length(get_hybridproblem_ϕq(prob)), length(get_hybridproblem_ϕq(prob_ind)) ``` + (7, 6) + ``` julia using OptimizationOptimisers import Zygote @@ -128,7 +119,7 @@ i_site = 1 plt = pairplot(θ1_nt) ``` -![](blocks_corr_files/figure-commonmark/cell-11-output-1.png) +![](blocks_corr_files/figure-commonmark/cell-10-output-1.png) The corner plot of the independent-parameters estimate shows no correlations between site parameters, *r*₁ and *K*₁. @@ -146,7 +137,7 @@ axislegend(ax, unique=true) fig ``` -![](blocks_corr_files/figure-commonmark/cell-12-output-1.png) +![](blocks_corr_files/figure-commonmark/cell-11-output-1.png) ``` julia plot_sd_vs_mean = (par) -> begin @@ -163,7 +154,7 @@ end plot_sd_vs_mean(:K1) ``` -![](blocks_corr_files/figure-commonmark/cell-13-output-1.png) +![](blocks_corr_files/figure-commonmark/cell-12-output-1.png) The inversion that neglects correlations among site parameters results in the same magnitude of estimated uncertainty of predictions. diff --git a/docs/src/tutorials/blocks_corr.qmd b/docs/src/tutorials/blocks_corr.qmd index 16a0323..9a09bb0 100644 --- a/docs/src/tutorials/blocks_corr.qmd +++ b/docs/src/tutorials/blocks_corr.qmd @@ -62,7 +62,8 @@ The defaults specifies a single entry, meaning, there is only one big block respectively, spanning all parameters. ```{julia} #| output: true -cor_ends0 = (P=[length(prob.θP)], M=[length(prob.θM)]) +pt = get_hybridproblem_par_templates(prob) +cor_ends0 = (P=[length(pt.θP)], M=[length(pt.θM)]) ``` The following specification models one-entry blocks for each each parameter @@ -71,35 +72,25 @@ independently with not modelling any correlations between them. ```{julia} #| output: true -cor_ends = (P=[length(prob.θP)], M=1:length(prob.θM)) +cor_ends = (P=[length(pt.θP)], M=1:length(pt.θM)) ``` -## Reinitialize parameters for the posterior approximation. -HVI uses additional fitted parameters to represent the means and the -covariance matrix of the posterior distribution of model parameters. -With fewer correlations, also the number of those parameters changes, -and those parameters must be reinitialized after changing the block structure in -the correlation matrix. - -Here, we obtain construct initial estimates. using [`init_hybrid_ϕunc`](@ref) +## Update the problem and redo the inversion ```{julia} -ϕunc = init_hybrid_ϕunc(cor_ends, zero(eltype(prob.θM))) +prob_ind = HybridProblem(prob; cor_ends) ``` -In this two-site parameter case, the the blocked structure saves only one degree of freedom: +HVI uses additional fitted parameters to represent the means and the +covariance matrix of the posterior distribution of model parameters. +With fewer correlations, also the correlation parameters changes. +Check that the new specification uses fewer parameters. ```{julia} #| output: true -length(ϕunc), length(probo_cor.ϕunc) +length(get_hybridproblem_ϕq(prob)), length(get_hybridproblem_ϕq(prob_ind)) ``` -## Update the problem and redo the inversion - - -```{julia} -prob_ind = HybridProblem(prob; cor_ends, ϕunc) -``` ```{julia} using OptimizationOptimisers diff --git a/docs/src/tutorials/blocks_corr_files/figure-commonmark/cell-10-output-1.png b/docs/src/tutorials/blocks_corr_files/figure-commonmark/cell-10-output-1.png index ae3f294..6b042a8 100644 Binary files a/docs/src/tutorials/blocks_corr_files/figure-commonmark/cell-10-output-1.png and b/docs/src/tutorials/blocks_corr_files/figure-commonmark/cell-10-output-1.png differ diff --git a/docs/src/tutorials/blocks_corr_files/figure-commonmark/cell-11-output-1.png b/docs/src/tutorials/blocks_corr_files/figure-commonmark/cell-11-output-1.png index 27402c7..dfcdeea 100644 Binary files a/docs/src/tutorials/blocks_corr_files/figure-commonmark/cell-11-output-1.png and b/docs/src/tutorials/blocks_corr_files/figure-commonmark/cell-11-output-1.png differ diff --git a/docs/src/tutorials/blocks_corr_files/figure-commonmark/cell-12-output-1.png b/docs/src/tutorials/blocks_corr_files/figure-commonmark/cell-12-output-1.png index 16d94a6..d6e51d7 100644 Binary files a/docs/src/tutorials/blocks_corr_files/figure-commonmark/cell-12-output-1.png and b/docs/src/tutorials/blocks_corr_files/figure-commonmark/cell-12-output-1.png differ diff --git a/docs/src/tutorials/blocks_corr_files/figure-commonmark/cell-13-output-1.png b/docs/src/tutorials/blocks_corr_files/figure-commonmark/cell-13-output-1.png index d4f0d3e..24bb0d7 100644 Binary files a/docs/src/tutorials/blocks_corr_files/figure-commonmark/cell-13-output-1.png and b/docs/src/tutorials/blocks_corr_files/figure-commonmark/cell-13-output-1.png differ diff --git a/docs/src/tutorials/corr_site_global.md b/docs/src/tutorials/corr_site_global.md index 9a9f9ea..f3e00f6 100644 --- a/docs/src/tutorials/corr_site_global.md +++ b/docs/src/tutorials/corr_site_global.md @@ -84,7 +84,7 @@ g_chain = SimpleChain( # get a template of the parameter vector, ϕg0 g_chain_app, ϕg0 = construct_ChainsApplicator(rng, g_chain) # -priorsM = [prob.priors[k] for k in keys(prob.θM)] +priorsM = Tuple(prob.priors[k] for k in keys(prob.θM)) lowers, uppers = get_quantile_transformed(priorsM, prob.transM) FT = eltype(prob.θM) g_chain_scaled = NormalScalingModelApplicator(g_chain_app, lowers, uppers, FT) diff --git a/docs/src/tutorials/corr_site_global.qmd b/docs/src/tutorials/corr_site_global.qmd index 8d57973..dc7ae7e 100644 --- a/docs/src/tutorials/corr_site_global.qmd +++ b/docs/src/tutorials/corr_site_global.qmd @@ -94,7 +94,7 @@ g_chain = SimpleChain( # get a template of the parameter vector, ϕg0 g_chain_app, ϕg0 = construct_ChainsApplicator(rng, g_chain) # -priorsM = [prob.priors[k] for k in keys(prob.θM)] +priorsM = Tuple(prob.priors[k] for k in keys(prob.θM)) lowers, uppers = get_quantile_transformed(priorsM, prob.transM) FT = eltype(prob.θM) g_chain_scaled = NormalScalingModelApplicator(g_chain_app, lowers, uppers, FT) diff --git a/docs/src/tutorials/corr_site_global_files/figure-commonmark/cell-10-output-1.png b/docs/src/tutorials/corr_site_global_files/figure-commonmark/cell-10-output-1.png index 2a6eb64..51066e0 100644 Binary files a/docs/src/tutorials/corr_site_global_files/figure-commonmark/cell-10-output-1.png and b/docs/src/tutorials/corr_site_global_files/figure-commonmark/cell-10-output-1.png differ diff --git a/docs/src/tutorials/corr_site_global_files/figure-commonmark/cell-11-output-1.png b/docs/src/tutorials/corr_site_global_files/figure-commonmark/cell-11-output-1.png index 1a3ce8e..15a008f 100644 Binary files a/docs/src/tutorials/corr_site_global_files/figure-commonmark/cell-11-output-1.png and b/docs/src/tutorials/corr_site_global_files/figure-commonmark/cell-11-output-1.png differ diff --git a/docs/src/tutorials/corr_site_global_files/figure-commonmark/cell-12-output-1.png b/docs/src/tutorials/corr_site_global_files/figure-commonmark/cell-12-output-1.png index a29441d..c1a21ff 100644 Binary files a/docs/src/tutorials/corr_site_global_files/figure-commonmark/cell-12-output-1.png and b/docs/src/tutorials/corr_site_global_files/figure-commonmark/cell-12-output-1.png differ diff --git a/docs/src/tutorials/corr_site_global_files/figure-commonmark/cell-9-output-1.png b/docs/src/tutorials/corr_site_global_files/figure-commonmark/cell-9-output-1.png index 5114029..90833a8 100644 Binary files a/docs/src/tutorials/corr_site_global_files/figure-commonmark/cell-9-output-1.png and b/docs/src/tutorials/corr_site_global_files/figure-commonmark/cell-9-output-1.png differ diff --git a/docs/src/tutorials/inspect_results.md b/docs/src/tutorials/inspect_results.md index 7849c63..c0f5ef9 100644 --- a/docs/src/tutorials/inspect_results.md +++ b/docs/src/tutorials/inspect_results.md @@ -52,12 +52,12 @@ size(θsP), size(θsMs) The last dimension is the number of samples, the second-last dimension is the respective parameter. `θsMs` has an additional dimension denoting -the site for which parameters are samples. +the site for which parameters are sampled. They are ComponentArrays with the parameter dimension names that can be used: ``` julia -θsMs[1,:r1,:] # sample of r1 of the first site +θsMs[1,:r1,:] # samples of the first site of parameter r1 ``` ## Corner plots @@ -101,7 +101,7 @@ fig ![](inspect_results_files/figure-commonmark/cell-10-output-1.png) We see that $K_1$ across sites ranges from about 0.18 to 0.25, and that -its estimated uncertainty is about 0.034, slightly decreasing with the +its estimated uncertainty is about 0.04, slightly decreasing with the values of the parameter. ## Predictive Posterior diff --git a/docs/src/tutorials/inspect_results.qmd b/docs/src/tutorials/inspect_results.qmd index d22d91e..92bd94b 100644 --- a/docs/src/tutorials/inspect_results.qmd +++ b/docs/src/tutorials/inspect_results.qmd @@ -74,11 +74,11 @@ size(θsP), size(θsMs) ``` The last dimension is the number of samples, the second-last dimension is the respective parameter. `θsMs` has an additional dimension denoting -the site for which parameters are samples. +the site for which parameters are sampled. They are ComponentArrays with the parameter dimension names that can be used: ```{julia} -θsMs[1,:r1,:] # sample of r1 of the first site +θsMs[1,:r1,:] # samples of the first site of parameter r1 ``` ## Corner plots @@ -125,7 +125,7 @@ fig ``` We see that $K_1$ across sites ranges from about 0.18 to 0.25, and that -its estimated uncertainty is about 0.034, slightly decreasing with the +its estimated uncertainty is about 0.04, slightly decreasing with the values of the parameter. ## Predictive Posterior diff --git a/docs/src/tutorials/inspect_results_files/figure-commonmark/cell-10-output-1.png b/docs/src/tutorials/inspect_results_files/figure-commonmark/cell-10-output-1.png index 75b8d1d..acc1d00 100644 Binary files a/docs/src/tutorials/inspect_results_files/figure-commonmark/cell-10-output-1.png and b/docs/src/tutorials/inspect_results_files/figure-commonmark/cell-10-output-1.png differ diff --git a/docs/src/tutorials/inspect_results_files/figure-commonmark/cell-13-output-1.png b/docs/src/tutorials/inspect_results_files/figure-commonmark/cell-13-output-1.png index 88e0fff..28857b2 100644 Binary files a/docs/src/tutorials/inspect_results_files/figure-commonmark/cell-13-output-1.png and b/docs/src/tutorials/inspect_results_files/figure-commonmark/cell-13-output-1.png differ diff --git a/docs/src/tutorials/inspect_results_files/figure-commonmark/cell-8-output-1.png b/docs/src/tutorials/inspect_results_files/figure-commonmark/cell-8-output-1.png index feeda24..dfb5314 100644 Binary files a/docs/src/tutorials/inspect_results_files/figure-commonmark/cell-8-output-1.png and b/docs/src/tutorials/inspect_results_files/figure-commonmark/cell-8-output-1.png differ diff --git a/docs/src/tutorials/intermediate/basic_cpu_results.jld2 b/docs/src/tutorials/intermediate/basic_cpu_results.jld2 index 7704a51..17f8cc2 100644 Binary files a/docs/src/tutorials/intermediate/basic_cpu_results.jld2 and b/docs/src/tutorials/intermediate/basic_cpu_results.jld2 differ diff --git a/docs/src/tutorials/logden_user.md b/docs/src/tutorials/logden_user.md index 3ccd55d..e98eaf8 100644 --- a/docs/src/tutorials/logden_user.md +++ b/docs/src/tutorials/logden_user.md @@ -167,7 +167,7 @@ fig ![](logden_user_files/figure-commonmark/cell-9-output-1.png) The marginal posterior of the global parameters is also similar, with a small -trend of lower values. +trend towards lower values. ``` julia i_site = 1 @@ -209,10 +209,10 @@ plot_sd_vs_mean = (par) -> begin fig = Figure(); ax = Axis(fig[1,1], xlabel="mean($par)",ylabel="sd($par)") θmean_normal = [mean(θsMs_normal[s,par,:]) for s in axes(θsMs_normal, 1)] θsd_normal = [std(θsMs_normal[s,par,:]) for s in axes(θsMs_normal, 1)] - scatter!(ax, θmean_normal, θsd_normal, label="correlated") + scatter!(ax, θmean_normal, θsd_normal, label="normal") θmean_lognormal = [mean(θsMs_lognormal[s,par,:]) for s in axes(θsMs_lognormal, 1)] θsd_lognormal = [std(θsMs_lognormal[s,par,:]) for s in axes(θsMs_lognormal, 1)] - scatter!(ax, θmean_lognormal, θsd_lognormal, label="independent") + scatter!(ax, θmean_lognormal, θsd_lognormal, label="lognormal") axislegend(ax, unique=true) fig end diff --git a/docs/src/tutorials/logden_user.qmd b/docs/src/tutorials/logden_user.qmd index 06f3043..4a57b06 100644 --- a/docs/src/tutorials/logden_user.qmd +++ b/docs/src/tutorials/logden_user.qmd @@ -174,7 +174,7 @@ fig ``` The marginal posterior of the global parameters is also similar, with a small -trend of lower values. +trend towards lower values. ```{julia} #| output: true @@ -214,10 +214,10 @@ plot_sd_vs_mean = (par) -> begin fig = Figure(); ax = Axis(fig[1,1], xlabel="mean($par)",ylabel="sd($par)") θmean_normal = [mean(θsMs_normal[s,par,:]) for s in axes(θsMs_normal, 1)] θsd_normal = [std(θsMs_normal[s,par,:]) for s in axes(θsMs_normal, 1)] - scatter!(ax, θmean_normal, θsd_normal, label="correlated") + scatter!(ax, θmean_normal, θsd_normal, label="normal") θmean_lognormal = [mean(θsMs_lognormal[s,par,:]) for s in axes(θsMs_lognormal, 1)] θsd_lognormal = [std(θsMs_lognormal[s,par,:]) for s in axes(θsMs_lognormal, 1)] - scatter!(ax, θmean_lognormal, θsd_lognormal, label="independent") + scatter!(ax, θmean_lognormal, θsd_lognormal, label="lognormal") axislegend(ax, unique=true) fig end diff --git a/docs/src/tutorials/logden_user_files/figure-commonmark/cell-10-output-1.png b/docs/src/tutorials/logden_user_files/figure-commonmark/cell-10-output-1.png index 2db7fd4..42f0133 100644 Binary files a/docs/src/tutorials/logden_user_files/figure-commonmark/cell-10-output-1.png and b/docs/src/tutorials/logden_user_files/figure-commonmark/cell-10-output-1.png differ diff --git a/docs/src/tutorials/logden_user_files/figure-commonmark/cell-11-output-1.png b/docs/src/tutorials/logden_user_files/figure-commonmark/cell-11-output-1.png index cca665e..90d8cb3 100644 Binary files a/docs/src/tutorials/logden_user_files/figure-commonmark/cell-11-output-1.png and b/docs/src/tutorials/logden_user_files/figure-commonmark/cell-11-output-1.png differ diff --git a/docs/src/tutorials/logden_user_files/figure-commonmark/cell-12-output-1.png b/docs/src/tutorials/logden_user_files/figure-commonmark/cell-12-output-1.png index 37f60bc..ca1d37b 100644 Binary files a/docs/src/tutorials/logden_user_files/figure-commonmark/cell-12-output-1.png and b/docs/src/tutorials/logden_user_files/figure-commonmark/cell-12-output-1.png differ diff --git a/docs/src/tutorials/logden_user_files/figure-commonmark/cell-8-output-1.png b/docs/src/tutorials/logden_user_files/figure-commonmark/cell-8-output-1.png index 611a40d..7d1d356 100644 Binary files a/docs/src/tutorials/logden_user_files/figure-commonmark/cell-8-output-1.png and b/docs/src/tutorials/logden_user_files/figure-commonmark/cell-8-output-1.png differ diff --git a/docs/src/tutorials/logden_user_files/figure-commonmark/cell-9-output-1.png b/docs/src/tutorials/logden_user_files/figure-commonmark/cell-9-output-1.png index cc82add..12165e4 100644 Binary files a/docs/src/tutorials/logden_user_files/figure-commonmark/cell-9-output-1.png and b/docs/src/tutorials/logden_user_files/figure-commonmark/cell-9-output-1.png differ diff --git a/docs/src/tutorials/lux_gpu.md b/docs/src/tutorials/lux_gpu.md index 9e7328c..1f0887c 100644 --- a/docs/src/tutorials/lux_gpu.md +++ b/docs/src/tutorials/lux_gpu.md @@ -62,7 +62,7 @@ g_lux = Lux.Chain( rng = StableRNG(111) g_chain_app, ϕg0 = construct_ChainsApplicator(rng, g_lux) # -priorsM = [prob.priors[k] for k in keys(prob.θM)] +priorsM = Tuple(prob.priors[k] for k in keys(prob.θM)) lowers, uppers = get_quantile_transformed(priorsM, prob.transM) FT = eltype(prob.θM) g_chain_scaled = NormalScalingModelApplicator(g_chain_app, lowers, uppers, FT) @@ -87,7 +87,7 @@ for the standard GPU device. Hence specify - `gdevs = (; gdev_M=gpu_device(), gdev_P=gpu_device())`: to move both ML model and PBM to GPU -- `gdevs = (; gdev_M=gpu_device(), gdev_P=identity)`: to move both ML model to GPU but execute the PBM (and parameter transformation) on CPU +- `gdevs = (; gdev_M=gpu_device(), gdev_P=identity)`: to move ML model to GPU but execute the PBM (and parameter transformation) on CPU Currently, putting the PBM on gpu is not efficient during inversion, because prior distribution needs to be evaluated for each sample. @@ -130,7 +130,7 @@ and need to be transferred to CPU. typeof(θsMs_dev) ``` - ComponentArrays.ComponentArray{Float32, 3, CUDA.CuArray{Float32, 3, CUDA.DeviceMemory}, Tuple{ComponentArrays.Axis{(i = 1:800,)}, ComponentArrays.Axis{(r1 = 1, K1 = 2)}, ComponentArrays.Axis{(i = 1:400,)}}} + ComponentArrays.ComponentArray{Float32, 3, CUDA.CuArray{Float32, 3, CUDA.DeviceMemory}, Tuple{ComponentArrays.Shaped1DAxis{(800,)}, ComponentArrays.Axis{(r1 = 1, K1 = 2)}, ComponentArrays.Shaped1DAxis{(400,)}}} Handling of a `ComponentArrays` backed by GPUArrays can result in errors of scalar indexing. Therefore, use a semicolon diff --git a/docs/src/tutorials/lux_gpu.qmd b/docs/src/tutorials/lux_gpu.qmd index 44bc774..196b63a 100644 --- a/docs/src/tutorials/lux_gpu.qmd +++ b/docs/src/tutorials/lux_gpu.qmd @@ -73,7 +73,7 @@ g_lux = Lux.Chain( rng = StableRNG(111) g_chain_app, ϕg0 = construct_ChainsApplicator(rng, g_lux) # -priorsM = [prob.priors[k] for k in keys(prob.θM)] +priorsM = Tuple(prob.priors[k] for k in keys(prob.θM)) lowers, uppers = get_quantile_transformed(priorsM, prob.transM) FT = eltype(prob.θM) g_chain_scaled = NormalScalingModelApplicator(g_chain_app, lowers, uppers, FT) @@ -97,7 +97,7 @@ for the standard GPU device. Hence specify - `gdevs = (; gdev_M=gpu_device(), gdev_P=gpu_device())`: to move both ML model and PBM to GPU -- `gdevs = (; gdev_M=gpu_device(), gdev_P=identity)`: to move both ML model to GPU but execute the PBM (and parameter transformation) on CPU +- `gdevs = (; gdev_M=gpu_device(), gdev_P=identity)`: to move ML model to GPU but execute the PBM (and parameter transformation) on CPU Currently, putting the PBM on gpu is not efficient during inversion, because prior distribution needs to be evaluated for each sample. diff --git a/ext/HybridVariationalInferenceFluxExt.jl b/ext/HybridVariationalInferenceFluxExt.jl index 47136d8..315bc51 100644 --- a/ext/HybridVariationalInferenceFluxExt.jl +++ b/ext/HybridVariationalInferenceFluxExt.jl @@ -52,13 +52,6 @@ end # HVI.set_default_GPUHandler(FluxGPUDataHandler()) # end -# function HVI.HybridProblem(θP::CA.ComponentVector, θM::CA.ComponentVector, g_chain::Flux.Chain, -# args...; kwargs...) -# # constructor with Flux.Chain -# g, ϕg = construct_FluxApplicator(g_chain) -# HybridProblem(θP, θM, g, ϕg, args...; kwargs...) -# end - function HVI.construct_3layer_MLApplicator( rng::AbstractRNG, prob::HVI.AbstractHybridProblem, ::Val{:Flux}; scenario::Val{scen}) where scen diff --git a/ext/HybridVariationalInferenceSimpleChainsExt.jl b/ext/HybridVariationalInferenceSimpleChainsExt.jl index a572777..8c36453 100644 --- a/ext/HybridVariationalInferenceSimpleChainsExt.jl +++ b/ext/HybridVariationalInferenceSimpleChainsExt.jl @@ -15,7 +15,9 @@ function HVI.construct_ChainsApplicator(rng::AbstractRNG, m::SimpleChain, FloatT SimpleChainsApplicator(m), ϕ end -HVI.apply_model(app::SimpleChainsApplicator, x, ϕ; is_testmode=false) = app.m(x, ϕ) +function HVI.apply_model(app::SimpleChainsApplicator, x, ϕ; is_testmode=false) + app.m(x, ϕ) +end function HVI.construct_3layer_MLApplicator( rng::AbstractRNG, prob::HVI.AbstractHybridProblem, ::Val{:SimpleChains}; diff --git a/projects/Manifest.toml b/projects/Manifest.toml new file mode 100644 index 0000000..c83e0bd --- /dev/null +++ b/projects/Manifest.toml @@ -0,0 +1,3198 @@ +# This file is machine-generated - editing it directly is not advised + +julia_version = "1.11.4" +manifest_format = "2.0" +project_hash = "baa287b830a7869dfa579e32b8e2fb112028df20" + +[[deps.ADTypes]] +git-tree-sha1 = "60665b326b75db6517939d0e1875850bc4a54368" +uuid = "47edcb42-4c32-4615-8424-f2b9edc5f35b" +version = "1.17.0" +weakdeps = ["ChainRulesCore", "ConstructionBase", "EnzymeCore"] + + [deps.ADTypes.extensions] + ADTypesChainRulesCoreExt = "ChainRulesCore" + ADTypesConstructionBaseExt = "ConstructionBase" + ADTypesEnzymeCoreExt = "EnzymeCore" + +[[deps.AbstractFFTs]] +deps = ["LinearAlgebra"] +git-tree-sha1 = "d92ad398961a3ed262d8bf04a1a2b8340f915fef" +uuid = "621f4979-c628-5d54-868e-fcf4e3e8185c" +version = "1.5.0" +weakdeps = ["ChainRulesCore", "Test"] + + [deps.AbstractFFTs.extensions] + AbstractFFTsChainRulesCoreExt = "ChainRulesCore" + AbstractFFTsTestExt = "Test" + +[[deps.AbstractMCMC]] +deps = ["BangBang", "ConsoleProgressMonitor", "Distributed", "FillArrays", "LogDensityProblems", "Logging", "LoggingExtras", "ProgressLogging", "Random", "StatsBase", "TerminalLoggers", "Transducers", "UUIDs"] +git-tree-sha1 = "e4b6a25ba2e033c74ea11720daacafbc2ab50a7e" +uuid = "80f14c24-f653-4e6a-9b94-39d6b0f70001" +version = "5.7.2" + +[[deps.AbstractPPL]] +deps = ["AbstractMCMC", "Accessors", "DensityInterface", "JSON", "Random", "StatsBase"] +git-tree-sha1 = "b7a856399119394a573141c553aeb5b674a500b5" +uuid = "7a57a42e-76ec-4ea3-a279-07e840d6d9cf" +version = "0.13.0" +weakdeps = ["Distributions", "LinearAlgebra"] + + [deps.AbstractPPL.extensions] + AbstractPPLDistributionsExt = ["Distributions", "LinearAlgebra"] + +[[deps.AbstractTrees]] +git-tree-sha1 = "2d9c9a55f9c93e8887ad391fbae72f8ef55e1177" +uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" +version = "0.4.5" + +[[deps.Accessors]] +deps = ["CompositionsBase", "ConstructionBase", "Dates", "InverseFunctions", "MacroTools"] +git-tree-sha1 = "3b86719127f50670efe356bc11073d84b4ed7a5d" +uuid = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697" +version = "0.1.42" + + [deps.Accessors.extensions] + AxisKeysExt = "AxisKeys" + IntervalSetsExt = "IntervalSets" + LinearAlgebraExt = "LinearAlgebra" + StaticArraysExt = "StaticArrays" + StructArraysExt = "StructArrays" + TestExt = "Test" + UnitfulExt = "Unitful" + + [deps.Accessors.weakdeps] + AxisKeys = "94b1ba4f-4ee9-5380-92f1-94cde586c3c5" + IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953" + LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" + StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" + StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a" + Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" + +[[deps.Adapt]] +deps = ["LinearAlgebra", "Requires"] +git-tree-sha1 = "f7817e2e585aa6d924fd714df1e2a84be7896c60" +uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" +version = "4.3.0" +weakdeps = ["SparseArrays", "StaticArrays"] + + [deps.Adapt.extensions] + AdaptSparseArraysExt = "SparseArrays" + AdaptStaticArraysExt = "StaticArrays" + +[[deps.AdaptivePredicates]] +git-tree-sha1 = "7e651ea8d262d2d74ce75fdf47c4d63c07dba7a6" +uuid = "35492f91-a3bd-45ad-95db-fcad7dcfedb7" +version = "1.2.0" + +[[deps.AdvancedHMC]] +deps = ["AbstractMCMC", "ArgCheck", "DocStringExtensions", "LinearAlgebra", "LogDensityProblems", "LogDensityProblemsAD", "ProgressMeter", "Random", "Setfield", "Statistics", "StatsBase", "StatsFuns"] +git-tree-sha1 = "22496647c061d00217759e95a18d601c959df0c9" +uuid = "0bf59076-c3b1-5ca4-86bd-e02cd72cde3d" +version = "0.8.1" + + [deps.AdvancedHMC.extensions] + AdvancedHMCADTypesExt = "ADTypes" + AdvancedHMCCUDAExt = "CUDA" + AdvancedHMCComponentArraysExt = "ComponentArrays" + AdvancedHMCMCMCChainsExt = "MCMCChains" + AdvancedHMCOrdinaryDiffEqExt = "OrdinaryDiffEq" + + [deps.AdvancedHMC.weakdeps] + ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b" + CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" + ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66" + MCMCChains = "c7f686f2-ff18-58e9-bc7b-31028e88f75d" + OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" + +[[deps.AdvancedMH]] +deps = ["AbstractMCMC", "Distributions", "DocStringExtensions", "FillArrays", "LinearAlgebra", "LogDensityProblems", "Random", "Requires"] +git-tree-sha1 = "0205823d612410230d18c421ed6d9d851a5451b9" +uuid = "5b7e9947-ddc0-4b3f-9b55-0d8042f74170" +version = "0.8.8" +weakdeps = ["DiffResults", "ForwardDiff", "MCMCChains", "StructArrays"] + + [deps.AdvancedMH.extensions] + AdvancedMHForwardDiffExt = ["DiffResults", "ForwardDiff"] + AdvancedMHMCMCChainsExt = "MCMCChains" + AdvancedMHStructArraysExt = "StructArrays" + +[[deps.AdvancedPS]] +deps = ["AbstractMCMC", "Distributions", "Random", "Random123", "Requires", "SSMProblems", "StatsFuns"] +git-tree-sha1 = "5d34d826ece67ce790d4a7f3f97d837e52aba7f8" +uuid = "576499cb-2369-40b2-a588-c64705576edc" +version = "0.7.0" +weakdeps = ["Libtask"] + + [deps.AdvancedPS.extensions] + AdvancedPSLibtaskExt = "Libtask" + +[[deps.AdvancedVI]] +deps = ["ADTypes", "Accessors", "DiffResults", "DifferentiationInterface", "Distributions", "DocStringExtensions", "FillArrays", "Functors", "LinearAlgebra", "LogDensityProblems", "Optimisers", "ProgressMeter", "Random", "StatsBase"] +git-tree-sha1 = "59c9723a71ed815eafec430d4cafa592b5889b96" +uuid = "b5ca4192-6429-45e5-a2d9-87aec30a685c" +version = "0.4.1" +weakdeps = ["Bijectors"] + + [deps.AdvancedVI.extensions] + AdvancedVIBijectorsExt = "Bijectors" + +[[deps.AlgebraOfGraphics]] +deps = ["Accessors", "Colors", "DataAPI", "Dates", "Dictionaries", "FileIO", "GLM", "GeoInterface", "GeometryBasics", "GridLayoutBase", "Isoband", "KernelDensity", "Loess", "Makie", "NaturalSort", "PlotUtils", "PolygonOps", "PooledArrays", "PrecompileTools", "RelocatableFolders", "StatsBase", "StructArrays", "Tables"] +git-tree-sha1 = "b24e6d3bd76b6811b195557fe6325c95e010dd4e" +uuid = "cbdf2221-f076-402e-a563-3d30da359d67" +version = "0.11.3" + + [deps.AlgebraOfGraphics.extensions] + AlgebraOfGraphicsDynamicQuantitiesExt = "DynamicQuantities" + AlgebraOfGraphicsUnitfulExt = "Unitful" + + [deps.AlgebraOfGraphics.weakdeps] + DynamicQuantities = "06fc5a27-2a28-4c7c-a15d-362465fb6821" + Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" + +[[deps.AliasTables]] +deps = ["PtrArrays", "Random"] +git-tree-sha1 = "9876e1e164b144ca45e9e3198d0b689cadfed9ff" +uuid = "66dad0bd-aa9a-41b7-9441-69ab47430ed8" +version = "1.1.3" + +[[deps.Animations]] +deps = ["Colors"] +git-tree-sha1 = "e092fa223bf66a3c41f9c022bd074d916dc303e7" +uuid = "27a7e980-b3e6-11e9-2bcd-0b925532e340" +version = "0.4.2" + +[[deps.ArgCheck]] +git-tree-sha1 = "f9e9a66c9b7be1ad7372bbd9b062d9230c30c5ce" +uuid = "dce04be8-c92d-5529-be00-80e4d2c0e197" +version = "2.5.0" + +[[deps.ArgTools]] +uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" +version = "1.1.2" + +[[deps.ArrayInterface]] +deps = ["Adapt", "LinearAlgebra"] +git-tree-sha1 = "9606d7832795cbef89e06a550475be300364a8aa" +uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" +version = "7.19.0" + + [deps.ArrayInterface.extensions] + ArrayInterfaceBandedMatricesExt = "BandedMatrices" + ArrayInterfaceBlockBandedMatricesExt = "BlockBandedMatrices" + ArrayInterfaceCUDAExt = "CUDA" + ArrayInterfaceCUDSSExt = "CUDSS" + ArrayInterfaceChainRulesCoreExt = "ChainRulesCore" + ArrayInterfaceChainRulesExt = "ChainRules" + ArrayInterfaceGPUArraysCoreExt = "GPUArraysCore" + ArrayInterfaceReverseDiffExt = "ReverseDiff" + ArrayInterfaceSparseArraysExt = "SparseArrays" + ArrayInterfaceStaticArraysCoreExt = "StaticArraysCore" + ArrayInterfaceTrackerExt = "Tracker" + + [deps.ArrayInterface.weakdeps] + BandedMatrices = "aae01518-5342-5314-be14-df237901396f" + BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0" + CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" + CUDSS = "45b445bb-4962-46a0-9369-b4df9d0f772e" + ChainRules = "082447d4-558c-5d27-93f4-14fc19e9eca2" + ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" + GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527" + ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" + SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" + StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c" + Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" + +[[deps.Artifacts]] +uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" +version = "1.11.0" + +[[deps.Atomix]] +deps = ["UnsafeAtomics"] +git-tree-sha1 = "29bb0eb6f578a587a49da16564705968667f5fa8" +uuid = "a9b6321e-bd34-4604-b9c9-b65b8de01458" +version = "1.1.2" + + [deps.Atomix.extensions] + AtomixCUDAExt = "CUDA" + AtomixMetalExt = "Metal" + AtomixOpenCLExt = "OpenCL" + AtomixoneAPIExt = "oneAPI" + + [deps.Atomix.weakdeps] + CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" + Metal = "dde4c033-4e86-420c-a63e-0dd931031962" + OpenCL = "08131aa3-fb12-5dee-8b74-c09406e224a2" + oneAPI = "8f75cd03-7ff8-4ecb-9b8f-daf728133b1b" + +[[deps.Automa]] +deps = ["PrecompileTools", "SIMD", "TranscodingStreams"] +git-tree-sha1 = "a8f503e8e1a5f583fbef15a8440c8c7e32185df2" +uuid = "67c07d97-cdcb-5c2c-af73-a7f9c32a568b" +version = "1.1.0" + +[[deps.AxisAlgorithms]] +deps = ["LinearAlgebra", "Random", "SparseArrays", "WoodburyMatrices"] +git-tree-sha1 = "01b8ccb13d68535d73d2b0c23e39bd23155fb712" +uuid = "13072b0f-2c55-5437-9ae7-d433b7a33950" +version = "1.1.0" + +[[deps.AxisArrays]] +deps = ["Dates", "IntervalSets", "IterTools", "RangeArrays"] +git-tree-sha1 = "16351be62963a67ac4083f748fdb3cca58bfd52f" +uuid = "39de3d68-74b9-583c-8d2d-e117c070f3a9" +version = "0.4.7" + +[[deps.BFloat16s]] +deps = ["LinearAlgebra", "Printf", "Random"] +git-tree-sha1 = "3b642331600250f592719140c60cf12372b82d66" +uuid = "ab4f0b2a-ad5b-11e8-123f-65d77653426b" +version = "0.5.1" + +[[deps.BangBang]] +deps = ["Accessors", "ConstructionBase", "InitialValues", "LinearAlgebra"] +git-tree-sha1 = "26f41e1df02c330c4fa1e98d4aa2168fdafc9b1f" +uuid = "198e06fe-97b7-11e9-32a5-e1d131e6ad66" +version = "0.4.4" + + [deps.BangBang.extensions] + BangBangChainRulesCoreExt = "ChainRulesCore" + BangBangDataFramesExt = "DataFrames" + BangBangStaticArraysExt = "StaticArrays" + BangBangStructArraysExt = "StructArrays" + BangBangTablesExt = "Tables" + BangBangTypedTablesExt = "TypedTables" + + [deps.BangBang.weakdeps] + ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" + DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" + StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" + StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a" + Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" + TypedTables = "9d95f2ec-7b3d-5a63-8d20-e2491e220bb9" + +[[deps.Base64]] +uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" +version = "1.11.0" + +[[deps.BaseDirs]] +git-tree-sha1 = "bca794632b8a9bbe159d56bf9e31c422671b35e0" +uuid = "18cc8868-cbac-4acf-b575-c8ff214dc66f" +version = "1.3.2" + +[[deps.Baselet]] +git-tree-sha1 = "aebf55e6d7795e02ca500a689d326ac979aaf89e" +uuid = "9718e550-a3fa-408a-8086-8db961cd8217" +version = "0.1.1" + +[[deps.Bijectors]] +deps = ["ArgCheck", "ChainRulesCore", "ChangesOfVariables", "Distributions", "DocStringExtensions", "Functors", "InverseFunctions", "IrrationalConstants", "LinearAlgebra", "LogExpFunctions", "MappedArrays", "Random", "Reexport", "Roots", "SparseArrays", "Statistics"] +git-tree-sha1 = "5eb5a58ed34e012d7f8d665cb5198252e128e907" +uuid = "76274a88-744f-5084-9051-94815aaf08c4" +version = "0.15.8" + + [deps.Bijectors.extensions] + BijectorsDistributionsADExt = "DistributionsAD" + BijectorsEnzymeCoreExt = "EnzymeCore" + BijectorsForwardDiffExt = "ForwardDiff" + BijectorsLazyArraysExt = "LazyArrays" + BijectorsMooncakeExt = "Mooncake" + BijectorsReverseDiffChainRulesExt = ["ChainRules", "ReverseDiff"] + BijectorsReverseDiffExt = "ReverseDiff" + BijectorsTrackerExt = "Tracker" + + [deps.Bijectors.weakdeps] + ChainRules = "082447d4-558c-5d27-93f4-14fc19e9eca2" + DistributionsAD = "ced4e74d-a319-5a8a-b0ac-84af2272839c" + EnzymeCore = "f151be2c-9106-41f4-ab19-57ee4f262869" + ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" + LazyArrays = "5078a376-72f3-5289-bfd5-ec5146d43c02" + Mooncake = "da2b9cff-9c12-43a0-ae48-6db2b0edb7d6" + ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" + Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" + +[[deps.BitTwiddlingConvenienceFunctions]] +deps = ["Static"] +git-tree-sha1 = "f21cfd4950cb9f0587d5067e69405ad2acd27b87" +uuid = "62783981-4cbd-42fc-bca8-16325de8dc4b" +version = "0.1.6" + +[[deps.BlockDiagonals]] +deps = ["FillArrays", "LinearAlgebra"] +git-tree-sha1 = "6e0ac86a90783f36f6daa496acf39ca138be8922" +uuid = "0a1fb500-61f7-11e9-3c65-f5ef3456f9f0" +version = "0.2.0" +weakdeps = ["ChainRulesCore"] + + [deps.BlockDiagonals.extensions] + ChainRulesCoreExt = "ChainRulesCore" + +[[deps.Bzip2_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "1b96ea4a01afe0ea4090c5c8039690672dd13f2e" +uuid = "6e34b625-4abd-537c-b88f-471c36dfa7a0" +version = "1.0.9+0" + +[[deps.CEnum]] +git-tree-sha1 = "389ad5c84de1ae7cf0e28e381131c98ea87d54fc" +uuid = "fa961155-64e5-5f13-b03f-caf6b980ea82" +version = "0.5.0" + +[[deps.CPUSummary]] +deps = ["CpuId", "IfElse", "PrecompileTools", "Preferences", "Static"] +git-tree-sha1 = "f3a21d7fc84ba618a779d1ed2fcca2e682865bab" +uuid = "2a0fbf3d-bb9c-48f3-b0a9-814d99fd7ab9" +version = "0.2.7" + +[[deps.CRC32c]] +uuid = "8bf52ea8-c179-5cab-976a-9e18b702a9bc" +version = "1.11.0" + +[[deps.CRlibm]] +deps = ["CRlibm_jll"] +git-tree-sha1 = "66188d9d103b92b6cd705214242e27f5737a1e5e" +uuid = "96374032-68de-5a5b-8d9e-752f78720389" +version = "1.0.2" + +[[deps.CRlibm_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "e329286945d0cfc04456972ea732551869af1cfc" +uuid = "4e9b3aee-d8a1-5a3d-ad8b-7d824db253f0" +version = "1.0.1+0" + +[[deps.CUDA]] +deps = ["AbstractFFTs", "Adapt", "BFloat16s", "CEnum", "CUDA_Driver_jll", "CUDA_Runtime_Discovery", "CUDA_Runtime_jll", "Crayons", "DataFrames", "ExprTools", "GPUArrays", "GPUCompiler", "GPUToolbox", "KernelAbstractions", "LLVM", "LLVMLoopInfo", "LazyArtifacts", "Libdl", "LinearAlgebra", "Logging", "NVTX", "Preferences", "PrettyTables", "Printf", "Random", "Random123", "RandomNumbers", "Reexport", "Requires", "SparseArrays", "StaticArrays", "Statistics", "demumble_jll"] +git-tree-sha1 = "b8ae59258f3d96ce75a00f9229e719356eb929d6" +uuid = "052768ef-5323-5732-b1bb-66c8b64840ba" +version = "5.8.2" + + [deps.CUDA.extensions] + ChainRulesCoreExt = "ChainRulesCore" + EnzymeCoreExt = "EnzymeCore" + SparseMatricesCSRExt = "SparseMatricesCSR" + SpecialFunctionsExt = "SpecialFunctions" + + [deps.CUDA.weakdeps] + ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" + EnzymeCore = "f151be2c-9106-41f4-ab19-57ee4f262869" + SparseMatricesCSR = "a0a7dd2c-ebf4-11e9-1f05-cf50bc540ca1" + SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b" + +[[deps.CUDA_Driver_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "18afa851ed10552e6df25dfaa7ef450104ae73d4" +uuid = "4ee394cb-3365-5eb0-8335-949819d2adfc" +version = "0.13.1+0" + +[[deps.CUDA_Runtime_Discovery]] +deps = ["Libdl"] +git-tree-sha1 = "33576c7c1b2500f8e7e6baa082e04563203b3a45" +uuid = "1af6417a-86b4-443c-805f-a4643ffb695f" +version = "0.3.5" + +[[deps.CUDA_Runtime_jll]] +deps = ["Artifacts", "CUDA_Driver_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "TOML"] +git-tree-sha1 = "b5c173a64f9f4224a82fdc26fda8614cb2ecfa27" +uuid = "76a88914-d11a-5bdc-97e0-2f5a05c973a2" +version = "0.17.1+0" + +[[deps.CUDNN_jll]] +deps = ["Artifacts", "CUDA_Runtime_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "TOML"] +git-tree-sha1 = "12ab2a3e7d1e5f523e95b94cd9334ebcf5be220e" +uuid = "62b44479-cb7b-5706-934f-f13b2eb2e645" +version = "9.10.0+0" + +[[deps.Cairo]] +deps = ["Cairo_jll", "Colors", "Glib_jll", "Graphics", "Libdl", "Pango_jll"] +git-tree-sha1 = "71aa551c5c33f1a4415867fe06b7844faadb0ae9" +uuid = "159f3aea-2a34-519c-b102-8c37f9878175" +version = "1.1.1" + +[[deps.CairoMakie]] +deps = ["CRC32c", "Cairo", "Cairo_jll", "Colors", "FileIO", "FreeType", "GeometryBasics", "LinearAlgebra", "Makie", "PrecompileTools"] +git-tree-sha1 = "ed19d39c31fdce671fb25d20f357618c495bd225" +uuid = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" +version = "0.15.5" + +[[deps.Cairo_jll]] +deps = ["Artifacts", "Bzip2_jll", "CompilerSupportLibraries_jll", "Fontconfig_jll", "FreeType2_jll", "Glib_jll", "JLLWrappers", "LZO_jll", "Libdl", "Pixman_jll", "Xorg_libXext_jll", "Xorg_libXrender_jll", "Zlib_jll", "libpng_jll"] +git-tree-sha1 = "fde3bf89aead2e723284a8ff9cdf5b551ed700e8" +uuid = "83423d85-b0ee-5818-9007-b63ccbeb887a" +version = "1.18.5+0" + +[[deps.CategoricalArrays]] +deps = ["Compat", "DataAPI", "Future", "Missings", "Printf", "Requires", "Statistics", "Unicode"] +git-tree-sha1 = "80ccd62b060efe8ff65d4edd4fa1ce9f653ae411" +uuid = "324d7699-5711-5eae-9e2f-1d82baa6b597" +version = "1.0.1" + + [deps.CategoricalArrays.extensions] + CategoricalArraysArrowExt = "Arrow" + CategoricalArraysJSONExt = "JSON" + CategoricalArraysRecipesBaseExt = "RecipesBase" + CategoricalArraysSentinelArraysExt = "SentinelArrays" + CategoricalArraysStatsBaseExt = "StatsBase" + CategoricalArraysStructTypesExt = "StructTypes" + + [deps.CategoricalArrays.weakdeps] + Arrow = "69666777-d1a9-59fb-9406-91d4454c9d45" + JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" + RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" + SentinelArrays = "91c51154-3ec4-41a3-a24f-3f23e20d615c" + StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" + StructTypes = "856f2bd8-1eba-4b0a-8007-ebc267875bd4" + +[[deps.ChainRules]] +deps = ["Adapt", "ChainRulesCore", "Compat", "Distributed", "GPUArraysCore", "IrrationalConstants", "LinearAlgebra", "Random", "RealDot", "SparseArrays", "SparseInverseSubset", "Statistics", "StructArrays", "SuiteSparse"] +git-tree-sha1 = "224f9dc510986549c8139def08e06f78c562514d" +uuid = "082447d4-558c-5d27-93f4-14fc19e9eca2" +version = "1.72.5" + +[[deps.ChainRulesCore]] +deps = ["Compat", "LinearAlgebra"] +git-tree-sha1 = "e4c6a16e77171a5f5e25e9646617ab1c276c5607" +uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" +version = "1.26.0" +weakdeps = ["SparseArrays"] + + [deps.ChainRulesCore.extensions] + ChainRulesCoreSparseArraysExt = "SparseArrays" + +[[deps.ChainRulesTestUtils]] +deps = ["ChainRulesCore", "Compat", "FiniteDifferences", "LinearAlgebra", "Random", "Suppressor", "Test"] +git-tree-sha1 = "cffe963ae0879e455d74ffd8243348293d72988a" +uuid = "cdddcdb0-9152-4a09-a978-84456f9df70a" +version = "1.13.0" + +[[deps.Chairmarks]] +deps = ["Printf", "Random"] +git-tree-sha1 = "9a49491e67e7a4d6f885c43d00bb101e6e5a434b" +uuid = "0ca39b1e-fe0b-4e98-acfc-b1656634c4de" +version = "1.3.1" +weakdeps = ["Statistics"] + + [deps.Chairmarks.extensions] + StatisticsChairmarksExt = ["Statistics"] + +[[deps.ChangesOfVariables]] +deps = ["LinearAlgebra"] +git-tree-sha1 = "3aa4bf1532aa2e14e0374c4fd72bed9a9d0d0f6c" +uuid = "9e997f8a-9a97-42d5-a9f1-ce6bfc15e2c0" +version = "0.1.10" +weakdeps = ["InverseFunctions", "Test"] + + [deps.ChangesOfVariables.extensions] + ChangesOfVariablesInverseFunctionsExt = "InverseFunctions" + ChangesOfVariablesTestExt = "Test" + +[[deps.CloseOpenIntervals]] +deps = ["Static", "StaticArrayInterface"] +git-tree-sha1 = "05ba0d07cd4fd8b7a39541e31a7b0254704ea581" +uuid = "fb6a15b2-703c-40df-9091-08a04967cfa9" +version = "0.1.13" + +[[deps.ColorBrewer]] +deps = ["Colors", "JSON"] +git-tree-sha1 = "e771a63cc8b539eca78c85b0cabd9233d6c8f06f" +uuid = "a2cac450-b92f-5266-8821-25eda20663c8" +version = "0.4.1" + +[[deps.ColorSchemes]] +deps = ["ColorTypes", "ColorVectorSpace", "Colors", "FixedPointNumbers", "PrecompileTools", "Random"] +git-tree-sha1 = "a656525c8b46aa6a1c76891552ed5381bb32ae7b" +uuid = "35d6a980-a343-548e-a6ea-1d62b119f2f4" +version = "3.30.0" + +[[deps.ColorTypes]] +deps = ["FixedPointNumbers", "Random"] +git-tree-sha1 = "67e11ee83a43eb71ddc950302c53bf33f0690dfe" +uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f" +version = "0.12.1" +weakdeps = ["StyledStrings"] + + [deps.ColorTypes.extensions] + StyledStringsExt = "StyledStrings" + +[[deps.ColorVectorSpace]] +deps = ["ColorTypes", "FixedPointNumbers", "LinearAlgebra", "Requires", "Statistics", "TensorCore"] +git-tree-sha1 = "8b3b6f87ce8f65a2b4f857528fd8d70086cd72b1" +uuid = "c3611d14-8923-5661-9e6a-0046d554d3a4" +version = "0.11.0" +weakdeps = ["SpecialFunctions"] + + [deps.ColorVectorSpace.extensions] + SpecialFunctionsExt = "SpecialFunctions" + +[[deps.Colors]] +deps = ["ColorTypes", "FixedPointNumbers", "Reexport"] +git-tree-sha1 = "37ea44092930b1811e666c3bc38065d7d87fcc74" +uuid = "5ae59095-9a9b-59fe-a467-6f913c188581" +version = "0.13.1" + +[[deps.Combinatorics]] +git-tree-sha1 = "8010b6bb3388abe68d95743dcbea77650bb2eddf" +uuid = "861a8166-3701-5b0c-9a16-15d98fcdc6aa" +version = "1.0.3" + +[[deps.CommonSolve]] +git-tree-sha1 = "0eee5eb66b1cf62cd6ad1b460238e60e4b09400c" +uuid = "38540f10-b2f7-11e9-35d8-d573e4eb0ff2" +version = "0.2.4" + +[[deps.CommonSubexpressions]] +deps = ["MacroTools"] +git-tree-sha1 = "cda2cfaebb4be89c9084adaca7dd7333369715c5" +uuid = "bbf7d656-a473-5ed7-a52c-81e309532950" +version = "0.3.1" + +[[deps.CommonWorldInvalidations]] +git-tree-sha1 = "ae52d1c52048455e85a387fbee9be553ec2b68d0" +uuid = "f70d9fcc-98c5-4d4a-abd7-e4cdeebd8ca8" +version = "1.0.0" + +[[deps.Compat]] +deps = ["TOML", "UUIDs"] +git-tree-sha1 = "0037835448781bb46feb39866934e243886d756a" +uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" +version = "4.18.0" +weakdeps = ["Dates", "LinearAlgebra"] + + [deps.Compat.extensions] + CompatLinearAlgebraExt = "LinearAlgebra" + +[[deps.CompilerSupportLibraries_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" +version = "1.1.1+0" + +[[deps.ComponentArrays]] +deps = ["Adapt", "ArrayInterface", "ChainRulesCore", "ConstructionBase", "Functors", "LinearAlgebra", "StaticArrayInterface", "StaticArraysCore"] +git-tree-sha1 = "d8b02e2226568644b6758b2d113fe5b08884eec0" +uuid = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66" +version = "0.15.29" + + [deps.ComponentArrays.extensions] + ComponentArraysGPUArraysExt = "GPUArrays" + ComponentArraysKernelAbstractionsExt = "KernelAbstractions" + ComponentArraysOptimisersExt = "Optimisers" + ComponentArraysReactantExt = "Reactant" + ComponentArraysRecursiveArrayToolsExt = "RecursiveArrayTools" + ComponentArraysReverseDiffExt = "ReverseDiff" + ComponentArraysSciMLBaseExt = "SciMLBase" + ComponentArraysTrackerExt = "Tracker" + ComponentArraysZygoteExt = "Zygote" + + [deps.ComponentArrays.weakdeps] + GPUArrays = "0c68f7d7-f131-5f86-a1c3-88cf8149b2d7" + KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c" + Optimisers = "3bd65402-5787-11e9-1adc-39752487f4e2" + Reactant = "3c362404-f566-11ee-1572-e11a4b42c853" + RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd" + ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" + SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462" + Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" + Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" + +[[deps.CompositionsBase]] +git-tree-sha1 = "802bb88cd69dfd1509f6670416bd4434015693ad" +uuid = "a33af91c-f02d-484b-be07-31d278c5ca2b" +version = "0.1.2" +weakdeps = ["InverseFunctions"] + + [deps.CompositionsBase.extensions] + CompositionsBaseInverseFunctionsExt = "InverseFunctions" + +[[deps.ComputePipeline]] +deps = ["Observables", "Preferences"] +git-tree-sha1 = "cb1299fee09da21e65ec88c1ff3a259f8d0b5802" +uuid = "95dc2771-c249-4cd0-9c9f-1f3b4330693c" +version = "0.1.4" + +[[deps.ConsoleProgressMonitor]] +deps = ["Logging", "ProgressMeter"] +git-tree-sha1 = "3ab7b2136722890b9af903859afcf457fa3059e8" +uuid = "88cd18e8-d9cc-4ea6-8889-5259c0d15c8b" +version = "0.1.2" + +[[deps.ConstructionBase]] +git-tree-sha1 = "b4b092499347b18a015186eae3042f72267106cb" +uuid = "187b0558-2788-49d3-abe0-74a17ed4e7c9" +version = "1.6.0" +weakdeps = ["IntervalSets", "LinearAlgebra", "StaticArrays"] + + [deps.ConstructionBase.extensions] + ConstructionBaseIntervalSetsExt = "IntervalSets" + ConstructionBaseLinearAlgebraExt = "LinearAlgebra" + ConstructionBaseStaticArraysExt = "StaticArrays" + +[[deps.ContextVariablesX]] +deps = ["Compat", "Logging", "UUIDs"] +git-tree-sha1 = "25cc3803f1030ab855e383129dcd3dc294e322cc" +uuid = "6add18c4-b38d-439d-96f6-d6bc489c04c5" +version = "0.1.3" + +[[deps.Contour]] +git-tree-sha1 = "439e35b0b36e2e5881738abc8857bd92ad6ff9a8" +uuid = "d38c429a-6771-53c6-b99e-75d170b6e991" +version = "0.6.3" + +[[deps.CpuId]] +deps = ["Markdown"] +git-tree-sha1 = "fcbb72b032692610bfbdb15018ac16a36cf2e406" +uuid = "adafc99b-e345-5852-983c-f28acb93d879" +version = "0.3.1" + +[[deps.Crayons]] +git-tree-sha1 = "249fe38abf76d48563e2f4556bebd215aa317e15" +uuid = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f" +version = "4.1.1" + +[[deps.DataAPI]] +git-tree-sha1 = "abe83f3a2f1b857aac70ef8b269080af17764bbe" +uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a" +version = "1.16.0" + +[[deps.DataFrames]] +deps = ["Compat", "DataAPI", "DataStructures", "Future", "InlineStrings", "InvertedIndices", "IteratorInterfaceExtensions", "LinearAlgebra", "Markdown", "Missings", "PooledArrays", "PrecompileTools", "PrettyTables", "Printf", "Random", "Reexport", "SentinelArrays", "SortingAlgorithms", "Statistics", "TableTraits", "Tables", "Unicode"] +git-tree-sha1 = "fb61b4812c49343d7ef0b533ba982c46021938a6" +uuid = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" +version = "1.7.0" + +[[deps.DataStructures]] +deps = ["Compat", "InteractiveUtils", "OrderedCollections"] +git-tree-sha1 = "4e1fe97fdaed23e9dc21d4d664bea76b65fc50a0" +uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" +version = "0.18.22" + +[[deps.DataValueInterfaces]] +git-tree-sha1 = "bfc1187b79289637fa0ef6d4436ebdfe6905cbd6" +uuid = "e2d170a0-9d28-54be-80f0-106bbe20a464" +version = "1.0.0" + +[[deps.Dates]] +deps = ["Printf"] +uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" +version = "1.11.0" + +[[deps.DefineSingletons]] +git-tree-sha1 = "0fba8b706d0178b4dc7fd44a96a92382c9065c2c" +uuid = "244e2a9f-e319-4986-a169-4d1fe445cd52" +version = "0.1.2" + +[[deps.DelaunayTriangulation]] +deps = ["AdaptivePredicates", "EnumX", "ExactPredicates", "Random"] +git-tree-sha1 = "5620ff4ee0084a6ab7097a27ba0c19290200b037" +uuid = "927a84f5-c5f4-47a5-9785-b46e178433df" +version = "1.6.4" + +[[deps.DelimitedFiles]] +deps = ["Mmap"] +git-tree-sha1 = "9e2f36d3c96a820c678f2f1f1782582fcf685bae" +uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab" +version = "1.9.1" + +[[deps.DensityInterface]] +deps = ["InverseFunctions", "Test"] +git-tree-sha1 = "80c3e8639e3353e5d2912fb3a1916b8455e2494b" +uuid = "b429d917-457f-4dbc-8f4c-0cc954292b1d" +version = "0.4.0" + +[[deps.Dictionaries]] +deps = ["Indexing", "Random", "Serialization"] +git-tree-sha1 = "a86af9c4c4f33e16a2b2ff43c2113b2f390081fa" +uuid = "85a47980-9c8c-11e8-2b9f-f7ca1fa99fb4" +version = "0.4.5" + +[[deps.DiffResults]] +deps = ["StaticArraysCore"] +git-tree-sha1 = "782dd5f4561f5d267313f23853baaaa4c52ea621" +uuid = "163ba53b-c6d8-5494-b064-1a9d43ac40c5" +version = "1.1.0" + +[[deps.DiffRules]] +deps = ["IrrationalConstants", "LogExpFunctions", "NaNMath", "Random", "SpecialFunctions"] +git-tree-sha1 = "23163d55f885173722d1e4cf0f6110cdbaf7e272" +uuid = "b552c78f-8df3-52c6-915a-8e097449b14b" +version = "1.15.1" + +[[deps.DifferentiationInterface]] +deps = ["ADTypes", "LinearAlgebra"] +git-tree-sha1 = "54d7b8c74408048aea9c055ac8573b2b5c5ec11f" +uuid = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63" +version = "0.7.4" + + [deps.DifferentiationInterface.extensions] + DifferentiationInterfaceChainRulesCoreExt = "ChainRulesCore" + DifferentiationInterfaceDiffractorExt = "Diffractor" + DifferentiationInterfaceEnzymeExt = ["EnzymeCore", "Enzyme"] + DifferentiationInterfaceFastDifferentiationExt = "FastDifferentiation" + DifferentiationInterfaceFiniteDiffExt = "FiniteDiff" + DifferentiationInterfaceFiniteDifferencesExt = "FiniteDifferences" + DifferentiationInterfaceForwardDiffExt = ["ForwardDiff", "DiffResults"] + DifferentiationInterfaceGPUArraysCoreExt = "GPUArraysCore" + DifferentiationInterfaceGTPSAExt = "GTPSA" + DifferentiationInterfaceMooncakeExt = "Mooncake" + DifferentiationInterfacePolyesterForwardDiffExt = ["PolyesterForwardDiff", "ForwardDiff", "DiffResults"] + DifferentiationInterfaceReverseDiffExt = ["ReverseDiff", "DiffResults"] + DifferentiationInterfaceSparseArraysExt = "SparseArrays" + DifferentiationInterfaceSparseConnectivityTracerExt = "SparseConnectivityTracer" + DifferentiationInterfaceSparseMatrixColoringsExt = "SparseMatrixColorings" + DifferentiationInterfaceStaticArraysExt = "StaticArrays" + DifferentiationInterfaceSymbolicsExt = "Symbolics" + DifferentiationInterfaceTrackerExt = "Tracker" + DifferentiationInterfaceZygoteExt = ["Zygote", "ForwardDiff"] + + [deps.DifferentiationInterface.weakdeps] + ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" + DiffResults = "163ba53b-c6d8-5494-b064-1a9d43ac40c5" + Diffractor = "9f5e2b26-1114-432f-b630-d3fe2085c51c" + Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9" + EnzymeCore = "f151be2c-9106-41f4-ab19-57ee4f262869" + FastDifferentiation = "eb9bf01b-bf85-4b60-bf87-ee5de06c00be" + FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41" + FiniteDifferences = "26cc04aa-876d-5657-8c51-4c34ba976000" + ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" + GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527" + GTPSA = "b27dd330-f138-47c5-815b-40db9dd9b6e8" + Mooncake = "da2b9cff-9c12-43a0-ae48-6db2b0edb7d6" + PolyesterForwardDiff = "98d1487c-24ca-40b6-b7ab-df2af84e126b" + ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" + SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" + SparseConnectivityTracer = "9f842d2f-2579-4b1d-911e-f412cf18a3f5" + SparseMatrixColorings = "0a514795-09f3-496d-8182-132a7b665d35" + StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" + Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7" + Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" + Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" + +[[deps.Distances]] +deps = ["LinearAlgebra", "Statistics", "StatsAPI"] +git-tree-sha1 = "c7e3a542b999843086e2f29dac96a618c105be1d" +uuid = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7" +version = "0.10.12" +weakdeps = ["ChainRulesCore", "SparseArrays"] + + [deps.Distances.extensions] + DistancesChainRulesCoreExt = "ChainRulesCore" + DistancesSparseArraysExt = "SparseArrays" + +[[deps.Distributed]] +deps = ["Random", "Serialization", "Sockets"] +uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" +version = "1.11.0" + +[[deps.DistributionFits]] +deps = ["Distributions", "FillArrays", "LinearAlgebra", "Reexport", "Requires", "StaticArrays", "Statistics", "StatsAPI", "StatsFuns"] +git-tree-sha1 = "a50a9fbdcccc1cb08ff2e1f40c37a268a74b8879" +uuid = "45214091-1ed4-4409-9bcf-fdb48a05e921" +version = "0.3.9" +weakdeps = ["Optim"] + + [deps.DistributionFits.extensions] + DistributionFitsOptimExt = "Optim" + +[[deps.Distributions]] +deps = ["AliasTables", "FillArrays", "LinearAlgebra", "PDMats", "Printf", "QuadGK", "Random", "SpecialFunctions", "Statistics", "StatsAPI", "StatsBase", "StatsFuns"] +git-tree-sha1 = "3e6d038b77f22791b8e3472b7c633acea1ecac06" +uuid = "31c24e10-a181-5473-b8eb-7969acd0382f" +version = "0.25.120" +weakdeps = ["ChainRulesCore", "DensityInterface", "Test"] + + [deps.Distributions.extensions] + DistributionsChainRulesCoreExt = "ChainRulesCore" + DistributionsDensityInterfaceExt = "DensityInterface" + DistributionsTestExt = "Test" + +[[deps.DistributionsAD]] +deps = ["Adapt", "ChainRules", "ChainRulesCore", "Compat", "Distributions", "FillArrays", "LinearAlgebra", "PDMats", "Random", "Requires", "SpecialFunctions", "StaticArrays", "StatsFuns", "ZygoteRules"] +git-tree-sha1 = "4acbf909e892ce1f94c39a138541566c1aad5e66" +uuid = "ced4e74d-a319-5a8a-b0ac-84af2272839c" +version = "0.6.58" + + [deps.DistributionsAD.extensions] + DistributionsADForwardDiffExt = "ForwardDiff" + DistributionsADLazyArraysExt = "LazyArrays" + DistributionsADReverseDiffExt = "ReverseDiff" + DistributionsADTrackerExt = "Tracker" + + [deps.DistributionsAD.weakdeps] + ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" + LazyArrays = "5078a376-72f3-5289-bfd5-ec5146d43c02" + ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" + Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" + +[[deps.DocStringExtensions]] +git-tree-sha1 = "7442a5dfe1ebb773c29cc2962a8980f47221d76c" +uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" +version = "0.9.5" + +[[deps.Downloads]] +deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"] +uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" +version = "1.6.0" + +[[deps.DynamicPPL]] +deps = ["ADTypes", "AbstractMCMC", "AbstractPPL", "Accessors", "BangBang", "Bijectors", "Chairmarks", "Compat", "ConstructionBase", "DifferentiationInterface", "Distributions", "DocStringExtensions", "InteractiveUtils", "LinearAlgebra", "LogDensityProblems", "MacroTools", "OrderedCollections", "Printf", "Random", "Requires", "Statistics", "Test"] +git-tree-sha1 = "e36add2952240379bd53b83e76cfd3a8c56748d6" +uuid = "366bfd00-2699-11ea-058f-f148b4cae6d8" +version = "0.37.0" + + [deps.DynamicPPL.extensions] + DynamicPPLChainRulesCoreExt = ["ChainRulesCore"] + DynamicPPLEnzymeCoreExt = ["EnzymeCore"] + DynamicPPLForwardDiffExt = ["ForwardDiff"] + DynamicPPLJETExt = ["JET"] + DynamicPPLMCMCChainsExt = ["MCMCChains"] + DynamicPPLMooncakeExt = ["Mooncake"] + + [deps.DynamicPPL.weakdeps] + ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" + EnzymeCore = "f151be2c-9106-41f4-ab19-57ee4f262869" + ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" + JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" + KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c" + MCMCChains = "c7f686f2-ff18-58e9-bc7b-31028e88f75d" + Mooncake = "da2b9cff-9c12-43a0-ae48-6db2b0edb7d6" + +[[deps.EarCut_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "e3290f2d49e661fbd94046d7e3726ffcb2d41053" +uuid = "5ae413db-bbd1-5e63-b57d-d24a61df00f5" +version = "2.2.4+0" + +[[deps.EllipticalSliceSampling]] +deps = ["AbstractMCMC", "ArrayInterface", "Distributions", "Random", "Statistics"] +git-tree-sha1 = "e611b7fdfbfb5b18d5e98776c30daede41b44542" +uuid = "cad2338a-1db2-11e9-3401-43bc07c9ede2" +version = "2.0.0" + +[[deps.EnumX]] +git-tree-sha1 = "bddad79635af6aec424f53ed8aad5d7555dc6f00" +uuid = "4e289a0a-7415-4d19-859d-a7e5c4648b56" +version = "1.0.5" + +[[deps.EnzymeCore]] +git-tree-sha1 = "8272a687bca7b5c601c0c24fc0c71bff10aafdfd" +uuid = "f151be2c-9106-41f4-ab19-57ee4f262869" +version = "0.8.12" +weakdeps = ["Adapt"] + + [deps.EnzymeCore.extensions] + AdaptExt = "Adapt" + +[[deps.ExactPredicates]] +deps = ["IntervalArithmetic", "Random", "StaticArrays"] +git-tree-sha1 = "b3f2ff58735b5f024c392fde763f29b057e4b025" +uuid = "429591f6-91af-11e9-00e2-59fbe8cec110" +version = "2.2.8" + +[[deps.Expat_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "d55dffd9ae73ff72f1c0482454dcf2ec6c6c4a63" +uuid = "2e619515-83b5-522b-bb60-26c02a35a201" +version = "2.6.5+0" + +[[deps.ExprTools]] +git-tree-sha1 = "27415f162e6028e81c72b82ef756bf321213b6ec" +uuid = "e2ba6199-217a-4e67-a87a-7c52f15ade04" +version = "0.1.10" + +[[deps.ExproniconLite]] +git-tree-sha1 = "c13f0b150373771b0fdc1713c97860f8df12e6c2" +uuid = "55351af7-c7e9-48d6-89ff-24e801d99491" +version = "0.10.14" + +[[deps.Extents]] +git-tree-sha1 = "b309b36a9e02fe7be71270dd8c0fd873625332b4" +uuid = "411431e0-e8b7-467b-b5e0-f676ba4f2910" +version = "0.1.6" + +[[deps.FFMPEG_jll]] +deps = ["Artifacts", "Bzip2_jll", "FreeType2_jll", "FriBidi_jll", "JLLWrappers", "LAME_jll", "Libdl", "Ogg_jll", "OpenSSL_jll", "Opus_jll", "PCRE2_jll", "Zlib_jll", "libaom_jll", "libass_jll", "libfdk_aac_jll", "libvorbis_jll", "x264_jll", "x265_jll"] +git-tree-sha1 = "eaa040768ea663ca695d442be1bc97edfe6824f2" +uuid = "b22a6f82-2f65-5046-a5b2-351ab43fb4e5" +version = "6.1.3+0" + +[[deps.FFTW]] +deps = ["AbstractFFTs", "FFTW_jll", "LinearAlgebra", "MKL_jll", "Preferences", "Reexport"] +git-tree-sha1 = "797762812ed063b9b94f6cc7742bc8883bb5e69e" +uuid = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341" +version = "1.9.0" + +[[deps.FFTW_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "6d6219a004b8cf1e0b4dbe27a2860b8e04eba0be" +uuid = "f5851436-0d7a-5f13-b9de-f02708fd171a" +version = "3.3.11+0" + +[[deps.FLoops]] +deps = ["BangBang", "Compat", "FLoopsBase", "InitialValues", "JuliaVariables", "MLStyle", "Serialization", "Setfield", "Transducers"] +git-tree-sha1 = "0a2e5873e9a5f54abb06418d57a8df689336a660" +uuid = "cc61a311-1640-44b5-9fba-1b764f453329" +version = "0.2.2" + +[[deps.FLoopsBase]] +deps = ["ContextVariablesX"] +git-tree-sha1 = "656f7a6859be8673bf1f35da5670246b923964f7" +uuid = "b9860ae5-e623-471e-878b-f6a53c775ea6" +version = "0.1.1" + +[[deps.FastClosures]] +git-tree-sha1 = "acebe244d53ee1b461970f8910c235b259e772ef" +uuid = "9aa1b823-49e4-5ca5-8b0f-3971ec8bab6a" +version = "0.3.2" + +[[deps.FigureHelpers]] +deps = ["KernelDensity", "Parameters", "StatsBase"] +git-tree-sha1 = "78622394692f7662ae0cf926a5f75f3d3dc7cab2" +repo-rev = "main" +repo-url = "git@github.com:EarthyScience/FigureHelpers.jl.git" +uuid = "9ae22f58-2487-4805-bfc5-386577db46c8" +version = "0.1.0" +weakdeps = ["AbstractMCMC", "AlgebraOfGraphics", "Distributions", "MCMCChains", "Makie"] + + [deps.FigureHelpers.extensions] + FigureHelpersAoGExt = ["Makie", "AlgebraOfGraphics"] + FigureHelpersMakieAbstractMCMCExt = ["Makie", "AbstractMCMC"] + FigureHelpersMakieDistributionsExt = ["Makie", "Distributions"] + FigureHelpersMakieExt = ["Makie", "KernelDensity"] + +[[deps.FileIO]] +deps = ["Pkg", "Requires", "UUIDs"] +git-tree-sha1 = "b66970a70db13f45b7e57fbda1736e1cf72174ea" +uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" +version = "1.17.0" + + [deps.FileIO.extensions] + HTTPExt = "HTTP" + + [deps.FileIO.weakdeps] + HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3" + +[[deps.FilePaths]] +deps = ["FilePathsBase", "MacroTools", "Reexport", "Requires"] +git-tree-sha1 = "919d9412dbf53a2e6fe74af62a73ceed0bce0629" +uuid = "8fc22ac5-c921-52a6-82fd-178b2807b824" +version = "0.8.3" + +[[deps.FilePathsBase]] +deps = ["Compat", "Dates"] +git-tree-sha1 = "3bab2c5aa25e7840a4b065805c0cdfc01f3068d2" +uuid = "48062228-2e41-5def-b9a4-89aafe57970f" +version = "0.9.24" +weakdeps = ["Mmap", "Test"] + + [deps.FilePathsBase.extensions] + FilePathsBaseMmapExt = "Mmap" + FilePathsBaseTestExt = "Test" + +[[deps.FileWatching]] +uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" +version = "1.11.0" + +[[deps.FillArrays]] +deps = ["LinearAlgebra"] +git-tree-sha1 = "6a70198746448456524cb442b8af316927ff3e1a" +uuid = "1a297f60-69ca-5386-bcde-b61e274b549b" +version = "1.13.0" +weakdeps = ["PDMats", "SparseArrays", "Statistics"] + + [deps.FillArrays.extensions] + FillArraysPDMatsExt = "PDMats" + FillArraysSparseArraysExt = "SparseArrays" + FillArraysStatisticsExt = "Statistics" + +[[deps.FiniteDiff]] +deps = ["ArrayInterface", "LinearAlgebra", "Setfield"] +git-tree-sha1 = "f089ab1f834470c525562030c8cfde4025d5e915" +uuid = "6a86dc24-6348-571c-b903-95158fe2bd41" +version = "2.27.0" + + [deps.FiniteDiff.extensions] + FiniteDiffBandedMatricesExt = "BandedMatrices" + FiniteDiffBlockBandedMatricesExt = "BlockBandedMatrices" + FiniteDiffSparseArraysExt = "SparseArrays" + FiniteDiffStaticArraysExt = "StaticArrays" + + [deps.FiniteDiff.weakdeps] + BandedMatrices = "aae01518-5342-5314-be14-df237901396f" + BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0" + SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" + StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" + +[[deps.FiniteDifferences]] +deps = ["ChainRulesCore", "LinearAlgebra", "Printf", "Random", "Richardson", "SparseArrays", "StaticArrays"] +git-tree-sha1 = "06d76c780d657729cf20821fb5832c6cc4dfd0b5" +uuid = "26cc04aa-876d-5657-8c51-4c34ba976000" +version = "0.12.32" + +[[deps.FixedPointNumbers]] +deps = ["Statistics"] +git-tree-sha1 = "05882d6995ae5c12bb5f36dd2ed3f61c98cbb172" +uuid = "53c48c17-4a7d-5ca2-90c5-79b7896eea93" +version = "0.8.5" + +[[deps.Flux]] +deps = ["Adapt", "ChainRulesCore", "Compat", "EnzymeCore", "Functors", "LinearAlgebra", "MLCore", "MLDataDevices", "MLUtils", "MacroTools", "NNlib", "OneHotArrays", "Optimisers", "Preferences", "ProgressLogging", "Random", "Reexport", "Setfield", "SparseArrays", "SpecialFunctions", "Statistics", "Zygote"] +git-tree-sha1 = "d0751ca4c9762d9033534057274235dfef86aaf9" +uuid = "587475ba-b771-5e3f-ad9e-33799f191a9c" +version = "0.16.5" + + [deps.Flux.extensions] + FluxAMDGPUExt = "AMDGPU" + FluxCUDAExt = "CUDA" + FluxCUDAcuDNNExt = ["CUDA", "cuDNN"] + FluxEnzymeExt = "Enzyme" + FluxMPIExt = "MPI" + FluxMPINCCLExt = ["CUDA", "MPI", "NCCL"] + + [deps.Flux.weakdeps] + AMDGPU = "21141c5a-9bdb-4563-92ae-f87d6854732e" + CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" + Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9" + MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195" + NCCL = "3fe64909-d7a1-4096-9b7d-7a0f12cf0f6b" + cuDNN = "02a925ec-e4fe-4b08-9a7e-0d78e3d38ccd" + +[[deps.Fontconfig_jll]] +deps = ["Artifacts", "Bzip2_jll", "Expat_jll", "FreeType2_jll", "JLLWrappers", "Libdl", "Libuuid_jll", "Zlib_jll"] +git-tree-sha1 = "301b5d5d731a0654825f1f2e906990f7141a106b" +uuid = "a3f928ae-7b40-5064-980b-68af3947d34b" +version = "2.16.0+0" + +[[deps.Format]] +git-tree-sha1 = "9c68794ef81b08086aeb32eeaf33531668d5f5fc" +uuid = "1fa38f19-a742-5d3f-a2b9-30dd87b9d5f8" +version = "1.3.7" + +[[deps.ForwardDiff]] +deps = ["CommonSubexpressions", "DiffResults", "DiffRules", "LinearAlgebra", "LogExpFunctions", "NaNMath", "Preferences", "Printf", "Random", "SpecialFunctions"] +git-tree-sha1 = "a2df1b776752e3f344e5116c06d75a10436ab853" +uuid = "f6369f11-7733-5829-9624-2563aa707210" +version = "0.10.38" +weakdeps = ["StaticArrays"] + + [deps.ForwardDiff.extensions] + ForwardDiffStaticArraysExt = "StaticArrays" + +[[deps.FreeType]] +deps = ["CEnum", "FreeType2_jll"] +git-tree-sha1 = "907369da0f8e80728ab49c1c7e09327bf0d6d999" +uuid = "b38be410-82b0-50bf-ab77-7b57e271db43" +version = "4.1.1" + +[[deps.FreeType2_jll]] +deps = ["Artifacts", "Bzip2_jll", "JLLWrappers", "Libdl", "Zlib_jll"] +git-tree-sha1 = "2c5512e11c791d1baed2049c5652441b28fc6a31" +uuid = "d7e528f0-a631-5988-bf34-fe36492bcfd7" +version = "2.13.4+0" + +[[deps.FreeTypeAbstraction]] +deps = ["BaseDirs", "ColorVectorSpace", "Colors", "FreeType", "GeometryBasics", "Mmap"] +git-tree-sha1 = "4ebb930ef4a43817991ba35db6317a05e59abd11" +uuid = "663a7486-cb36-511b-a19d-713bb74d65c9" +version = "0.10.8" + +[[deps.FriBidi_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "7a214fdac5ed5f59a22c2d9a885a16da1c74bbc7" +uuid = "559328eb-81f9-559d-9380-de523a88c83c" +version = "1.0.17+0" + +[[deps.FunctionWrappers]] +git-tree-sha1 = "d62485945ce5ae9c0c48f124a84998d755bae00e" +uuid = "069b7b12-0de2-55c6-9aab-29f3d0a68a2e" +version = "1.1.3" + +[[deps.FunctionWrappersWrappers]] +deps = ["FunctionWrappers"] +git-tree-sha1 = "b104d487b34566608f8b4e1c39fb0b10aa279ff8" +uuid = "77dc65aa-8811-40c2-897b-53d922fa7daf" +version = "0.1.3" + +[[deps.Functors]] +deps = ["Compat", "ConstructionBase", "LinearAlgebra", "Random"] +git-tree-sha1 = "60a0339f28a233601cb74468032b5c302d5067de" +uuid = "d9f16b24-f501-4c13-a1f2-28368ffc5196" +version = "0.5.2" + +[[deps.Future]] +deps = ["Random"] +uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820" +version = "1.11.0" + +[[deps.GLM]] +deps = ["Distributions", "LinearAlgebra", "Printf", "Reexport", "SparseArrays", "SpecialFunctions", "Statistics", "StatsAPI", "StatsBase", "StatsFuns", "StatsModels"] +git-tree-sha1 = "273bd1cd30768a2fddfa3fd63bbc746ed7249e5f" +uuid = "38e38edf-8417-5370-95a0-9cbb8c7f171a" +version = "1.9.0" + +[[deps.GPUArrays]] +deps = ["Adapt", "GPUArraysCore", "KernelAbstractions", "LLVM", "LinearAlgebra", "Printf", "Random", "Reexport", "ScopedValues", "Serialization", "Statistics"] +git-tree-sha1 = "be941842a40b6daac98496994ea69054ba4c5144" +uuid = "0c68f7d7-f131-5f86-a1c3-88cf8149b2d7" +version = "11.2.3" + +[[deps.GPUArraysCore]] +deps = ["Adapt"] +git-tree-sha1 = "83cf05ab16a73219e5f6bd1bdfa9848fa24ac627" +uuid = "46192b85-c4d5-4398-a991-12ede77f4527" +version = "0.2.0" + +[[deps.GPUCompiler]] +deps = ["ExprTools", "InteractiveUtils", "LLVM", "Libdl", "Logging", "PrecompileTools", "Preferences", "Scratch", "Serialization", "TOML", "Tracy", "UUIDs"] +git-tree-sha1 = "eb1e212e12cc058fa16712082d44be499d23638c" +uuid = "61eb1bfa-7361-4325-ad38-22787b887f55" +version = "1.6.1" + +[[deps.GPUToolbox]] +git-tree-sha1 = "15d8b0f5a6dca9bf8c02eeaf6687660dafa638d0" +uuid = "096a3bc2-3ced-46d0-87f4-dd12716f4bfc" +version = "0.2.0" + +[[deps.GeoFormatTypes]] +git-tree-sha1 = "8e233d5167e63d708d41f87597433f59a0f213fe" +uuid = "68eda718-8dee-11e9-39e7-89f7f65f511f" +version = "0.4.4" + +[[deps.GeoInterface]] +deps = ["DataAPI", "Extents", "GeoFormatTypes"] +git-tree-sha1 = "0f265264b9287a19715dc5d491dbe3aff00c1e71" +uuid = "cf35fbd7-0cd7-5166-be24-54bfbe79505f" +version = "1.5.0" +weakdeps = ["GeometryBasics", "Makie", "RecipesBase"] + + [deps.GeoInterface.extensions] + GeoInterfaceMakieExt = ["Makie", "GeometryBasics"] + GeoInterfaceRecipesBaseExt = "RecipesBase" + +[[deps.GeometryBasics]] +deps = ["EarCut_jll", "Extents", "IterTools", "LinearAlgebra", "PrecompileTools", "Random", "StaticArrays"] +git-tree-sha1 = "1f5a80f4ed9f5a4aada88fc2db456e637676414b" +uuid = "5c1252a2-5f33-56bf-86c9-59e7332b4326" +version = "0.5.10" +weakdeps = ["GeoInterface"] + + [deps.GeometryBasics.extensions] + GeometryBasicsGeoInterfaceExt = "GeoInterface" + +[[deps.GettextRuntime_jll]] +deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Libiconv_jll"] +git-tree-sha1 = "45288942190db7c5f760f59c04495064eedf9340" +uuid = "b0724c58-0f36-5564-988d-3bb0596ebc4a" +version = "0.22.4+0" + +[[deps.Giflib_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "6570366d757b50fabae9f4315ad74d2e40c0560a" +uuid = "59f7168a-df46-5410-90c8-f2779963d0ec" +version = "5.2.3+0" + +[[deps.Glib_jll]] +deps = ["Artifacts", "GettextRuntime_jll", "JLLWrappers", "Libdl", "Libffi_jll", "Libiconv_jll", "Libmount_jll", "PCRE2_jll", "Zlib_jll"] +git-tree-sha1 = "35fbd0cefb04a516104b8e183ce0df11b70a3f1a" +uuid = "7746bdde-850d-59dc-9ae8-88ece973131d" +version = "2.84.3+0" + +[[deps.Graphics]] +deps = ["Colors", "LinearAlgebra", "NaNMath"] +git-tree-sha1 = "a641238db938fff9b2f60d08ed9030387daf428c" +uuid = "a2bd30eb-e257-5431-a919-1863eab51364" +version = "1.1.3" + +[[deps.Graphite2_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "8a6dbda1fd736d60cc477d99f2e7a042acfa46e8" +uuid = "3b182d85-2403-5c21-9c21-1e1f0cc25472" +version = "1.3.15+0" + +[[deps.GridLayoutBase]] +deps = ["GeometryBasics", "InteractiveUtils", "Observables"] +git-tree-sha1 = "dc6bed05c15523624909b3953686c5f5ffa10adc" +uuid = "3955a311-db13-416c-9275-1d80ed98e5e9" +version = "0.11.1" + +[[deps.Grisu]] +git-tree-sha1 = "53bb909d1151e57e2484c3d1b53e19552b887fb2" +uuid = "42e2da0e-8278-4e71-bc24-59509adca0fe" +version = "1.0.2" + +[[deps.HarfBuzz_jll]] +deps = ["Artifacts", "Cairo_jll", "Fontconfig_jll", "FreeType2_jll", "Glib_jll", "Graphite2_jll", "JLLWrappers", "Libdl", "Libffi_jll"] +git-tree-sha1 = "f923f9a774fcf3f5cb761bfa43aeadd689714813" +uuid = "2e76f6c2-a576-52d4-95c1-20adfe4de566" +version = "8.5.1+0" + +[[deps.HashArrayMappedTries]] +git-tree-sha1 = "2eaa69a7cab70a52b9687c8bf950a5a93ec895ae" +uuid = "076d061b-32b6-4027-95e0-9a2c6f6d7e74" +version = "0.2.0" + +[[deps.HostCPUFeatures]] +deps = ["BitTwiddlingConvenienceFunctions", "IfElse", "Libdl", "Static"] +git-tree-sha1 = "8e070b599339d622e9a081d17230d74a5c473293" +uuid = "3e5b6fbb-0976-4d2c-9146-d79de83f2fb0" +version = "0.1.17" + +[[deps.HybridVariationalInference]] +deps = ["Bijectors", "BlockDiagonals", "ChainRulesCore", "Combinatorics", "CommonSolve", "ComponentArrays", "DistributionFits", "Distributions", "Functors", "GPUArraysCore", "LinearAlgebra", "MLDataDevices", "MLUtils", "Optimization", "Random", "StableRNGs", "StaticArrays", "StatsBase", "StatsFuns", "Test"] +path = ".." +uuid = "a108c475-a4e2-4021-9a84-cfa7df242f64" +version = "1.0.0-DEV" + + [deps.HybridVariationalInference.extensions] + HybridVariationalInferenceCUDAExt = "CUDA" + HybridVariationalInferenceFluxExt = "Flux" + HybridVariationalInferenceLuxExt = "Lux" + HybridVariationalInferenceSimpleChainsExt = "SimpleChains" + + [deps.HybridVariationalInference.weakdeps] + CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" + Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c" + Lux = "b2108857-7c20-44ae-9111-449ecde12c47" + SimpleChains = "de6bee2f-e2f4-4ec7-b6ed-219cc6f6e9e5" + +[[deps.HypergeometricFunctions]] +deps = ["LinearAlgebra", "OpenLibm_jll", "SpecialFunctions"] +git-tree-sha1 = "68c173f4f449de5b438ee67ed0c9c748dc31a2ec" +uuid = "34004b35-14d8-5ef3-9330-4cdb6864b03a" +version = "0.3.28" + +[[deps.IRTools]] +deps = ["InteractiveUtils", "MacroTools"] +git-tree-sha1 = "57e9ce6cf68d0abf5cb6b3b4abf9bedf05c939c0" +uuid = "7869d1d1-7146-5819-86e3-90919afe41df" +version = "0.4.15" + +[[deps.IfElse]] +git-tree-sha1 = "debdd00ffef04665ccbb3e150747a77560e8fad1" +uuid = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173" +version = "0.1.1" + +[[deps.ImageAxes]] +deps = ["AxisArrays", "ImageBase", "ImageCore", "Reexport", "SimpleTraits"] +git-tree-sha1 = "e12629406c6c4442539436581041d372d69c55ba" +uuid = "2803e5a7-5153-5ecf-9a86-9b4c37f5f5ac" +version = "0.6.12" + +[[deps.ImageBase]] +deps = ["ImageCore", "Reexport"] +git-tree-sha1 = "eb49b82c172811fd2c86759fa0553a2221feb909" +uuid = "c817782e-172a-44cc-b673-b171935fbb9e" +version = "0.1.7" + +[[deps.ImageCore]] +deps = ["ColorVectorSpace", "Colors", "FixedPointNumbers", "MappedArrays", "MosaicViews", "OffsetArrays", "PaddedViews", "PrecompileTools", "Reexport"] +git-tree-sha1 = "8c193230235bbcee22c8066b0374f63b5683c2d3" +uuid = "a09fc81d-aa75-5fe9-8630-4744c3626534" +version = "0.10.5" + +[[deps.ImageIO]] +deps = ["FileIO", "IndirectArrays", "JpegTurbo", "LazyModules", "Netpbm", "OpenEXR", "PNGFiles", "QOI", "Sixel", "TiffImages", "UUIDs", "WebP"] +git-tree-sha1 = "696144904b76e1ca433b886b4e7edd067d76cbf7" +uuid = "82e4d734-157c-48bb-816b-45c225c6df19" +version = "0.6.9" + +[[deps.ImageMetadata]] +deps = ["AxisArrays", "ImageAxes", "ImageBase", "ImageCore"] +git-tree-sha1 = "2a81c3897be6fbcde0802a0ebe6796d0562f63ec" +uuid = "bc367c6b-8a6b-528e-b4bd-a4b897500b49" +version = "0.9.10" + +[[deps.Imath_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "0936ba688c6d201805a83da835b55c61a180db52" +uuid = "905a6f67-0a94-5f89-b386-d35d92009cd1" +version = "3.1.11+0" + +[[deps.Indexing]] +git-tree-sha1 = "ce1566720fd6b19ff3411404d4b977acd4814f9f" +uuid = "313cdc1a-70c2-5d6a-ae34-0150d3930a38" +version = "1.1.1" + +[[deps.IndirectArrays]] +git-tree-sha1 = "012e604e1c7458645cb8b436f8fba789a51b257f" +uuid = "9b13fd28-a010-5f03-acff-a1bbcff69959" +version = "1.0.0" + +[[deps.Inflate]] +git-tree-sha1 = "d1b1b796e47d94588b3757fe84fbf65a5ec4a80d" +uuid = "d25df0c9-e2be-5dd7-82c8-3ad0b3e990b9" +version = "0.1.5" + +[[deps.InitialValues]] +git-tree-sha1 = "4da0f88e9a39111c2fa3add390ab15f3a44f3ca3" +uuid = "22cec73e-a1b8-11e9-2c92-598750a2cf9c" +version = "0.3.1" + +[[deps.InlineStrings]] +git-tree-sha1 = "8594fac023c5ce1ef78260f24d1ad18b4327b420" +uuid = "842dd82b-1e85-43dc-bf29-5d0ee9dffc48" +version = "1.4.4" + + [deps.InlineStrings.extensions] + ArrowTypesExt = "ArrowTypes" + ParsersExt = "Parsers" + + [deps.InlineStrings.weakdeps] + ArrowTypes = "31f734f8-188a-4ce0-8406-c8a06bd891cd" + Parsers = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" + +[[deps.IntelOpenMP_jll]] +deps = ["Artifacts", "JLLWrappers", "LazyArtifacts", "Libdl"] +git-tree-sha1 = "ec1debd61c300961f98064cfb21287613ad7f303" +uuid = "1d5cc7b8-4909-519e-a0f8-d0f5ad9712d0" +version = "2025.2.0+0" + +[[deps.InteractiveUtils]] +deps = ["Markdown"] +uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" +version = "1.11.0" + +[[deps.Interpolations]] +deps = ["Adapt", "AxisAlgorithms", "ChainRulesCore", "LinearAlgebra", "OffsetArrays", "Random", "Ratios", "Requires", "SharedArrays", "SparseArrays", "StaticArrays", "WoodburyMatrices"] +git-tree-sha1 = "f2905febca224eade352a573e129ef43aa593354" +uuid = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59" +version = "0.16.1" +weakdeps = ["ForwardDiff", "Unitful"] + + [deps.Interpolations.extensions] + InterpolationsForwardDiffExt = "ForwardDiff" + InterpolationsUnitfulExt = "Unitful" + +[[deps.IntervalArithmetic]] +deps = ["CRlibm", "MacroTools", "OpenBLASConsistentFPCSR_jll", "Random", "RoundingEmulator"] +git-tree-sha1 = "79342df41c3c24664e5bf29395cfdf2f2a599412" +uuid = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253" +version = "0.22.36" + + [deps.IntervalArithmetic.extensions] + IntervalArithmeticArblibExt = "Arblib" + IntervalArithmeticDiffRulesExt = "DiffRules" + IntervalArithmeticForwardDiffExt = "ForwardDiff" + IntervalArithmeticIntervalSetsExt = "IntervalSets" + IntervalArithmeticLinearAlgebraExt = "LinearAlgebra" + IntervalArithmeticRecipesBaseExt = "RecipesBase" + IntervalArithmeticSparseArraysExt = "SparseArrays" + + [deps.IntervalArithmetic.weakdeps] + Arblib = "fb37089c-8514-4489-9461-98f9c8763369" + DiffRules = "b552c78f-8df3-52c6-915a-8e097449b14b" + ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" + IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953" + LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" + RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" + SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" + +[[deps.IntervalSets]] +git-tree-sha1 = "5fbb102dcb8b1a858111ae81d56682376130517d" +uuid = "8197267c-284f-5f27-9208-e0e47529a953" +version = "0.7.11" +weakdeps = ["Random", "RecipesBase", "Statistics"] + + [deps.IntervalSets.extensions] + IntervalSetsRandomExt = "Random" + IntervalSetsRecipesBaseExt = "RecipesBase" + IntervalSetsStatisticsExt = "Statistics" + +[[deps.InverseFunctions]] +git-tree-sha1 = "a779299d77cd080bf77b97535acecd73e1c5e5cb" +uuid = "3587e190-3f89-42d0-90ee-14403ec27112" +version = "0.1.17" +weakdeps = ["Dates", "Test"] + + [deps.InverseFunctions.extensions] + InverseFunctionsDatesExt = "Dates" + InverseFunctionsTestExt = "Test" + +[[deps.InvertedIndices]] +git-tree-sha1 = "6da3c4316095de0f5ee2ebd875df8721e7e0bdbe" +uuid = "41ab1584-1d38-5bbf-9106-f11c6c58b48f" +version = "1.3.1" + +[[deps.IrrationalConstants]] +git-tree-sha1 = "e2222959fbc6c19554dc15174c81bf7bf3aa691c" +uuid = "92d709cd-6900-40b7-9082-c6be49f344b6" +version = "0.2.4" + +[[deps.Isoband]] +deps = ["isoband_jll"] +git-tree-sha1 = "f9b6d97355599074dc867318950adaa6f9946137" +uuid = "f1662d9f-8043-43de-a69a-05efc1cc6ff4" +version = "0.1.1" + +[[deps.IterTools]] +git-tree-sha1 = "42d5f897009e7ff2cf88db414a389e5ed1bdd023" +uuid = "c8e1da08-722c-5040-9ed9-7db0dc04731e" +version = "1.10.0" + +[[deps.IteratorInterfaceExtensions]] +git-tree-sha1 = "a3f24677c21f5bbe9d2a714f95dcd58337fb2856" +uuid = "82899510-4779-5014-852e-03e436cf321d" +version = "1.0.0" + +[[deps.JLD2]] +deps = ["FileIO", "MacroTools", "Mmap", "OrderedCollections", "PrecompileTools", "ScopedValues", "TranscodingStreams"] +git-tree-sha1 = "d97791feefda45729613fafeccc4fbef3f539151" +uuid = "033835bb-8acc-5ee8-8aae-3f567f8a3819" +version = "0.5.15" +weakdeps = ["UnPack"] + + [deps.JLD2.extensions] + UnPackExt = "UnPack" + +[[deps.JLLWrappers]] +deps = ["Artifacts", "Preferences"] +git-tree-sha1 = "0533e564aae234aff59ab625543145446d8b6ec2" +uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210" +version = "1.7.1" + +[[deps.JSON]] +deps = ["Dates", "Mmap", "Parsers", "Unicode"] +git-tree-sha1 = "31e996f0a15c7b280ba9f76636b3ff9e2ae58c9a" +uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" +version = "0.21.4" + +[[deps.Jieko]] +deps = ["ExproniconLite"] +git-tree-sha1 = "2f05ed29618da60c06a87e9c033982d4f71d0b6c" +uuid = "ae98c720-c025-4a4a-838c-29b094483192" +version = "0.2.1" + +[[deps.JpegTurbo]] +deps = ["CEnum", "FileIO", "ImageCore", "JpegTurbo_jll", "TOML"] +git-tree-sha1 = "9496de8fb52c224a2e3f9ff403947674517317d9" +uuid = "b835a17e-a41a-41e7-81f0-2f016b05efe0" +version = "0.1.6" + +[[deps.JpegTurbo_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "eac1206917768cb54957c65a615460d87b455fc1" +uuid = "aacddb02-875f-59d6-b918-886e6ef4fbf8" +version = "3.1.1+0" + +[[deps.JuliaNVTXCallbacks_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "af433a10f3942e882d3c671aacb203e006a5808f" +uuid = "9c1d0b0a-7046-5b2e-a33f-ea22f176ac7e" +version = "0.2.1+0" + +[[deps.JuliaVariables]] +deps = ["MLStyle", "NameResolution"] +git-tree-sha1 = "49fb3cb53362ddadb4415e9b73926d6b40709e70" +uuid = "b14d175d-62b4-44ba-8fb7-3064adc8c3ec" +version = "0.2.4" + +[[deps.KernelAbstractions]] +deps = ["Adapt", "Atomix", "InteractiveUtils", "MacroTools", "PrecompileTools", "Requires", "StaticArrays", "UUIDs"] +git-tree-sha1 = "83c617e9e9b02306a7acab79e05ec10253db7c87" +uuid = "63c18a36-062a-441e-b654-da1e3ab1ce7c" +version = "0.9.38" +weakdeps = ["EnzymeCore", "LinearAlgebra", "SparseArrays"] + + [deps.KernelAbstractions.extensions] + EnzymeExt = "EnzymeCore" + LinearAlgebraExt = "LinearAlgebra" + SparseArraysExt = "SparseArrays" + +[[deps.KernelDensity]] +deps = ["Distributions", "DocStringExtensions", "FFTW", "Interpolations", "StatsBase"] +git-tree-sha1 = "ba51324b894edaf1df3ab16e2cc6bc3280a2f1a7" +uuid = "5ab0869b-81aa-558d-bb23-cbf5423bbe9b" +version = "0.6.10" + +[[deps.LAME_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "059aabebaa7c82ccb853dd4a0ee9d17796f7e1bc" +uuid = "c1c5ebd0-6772-5130-a774-d5fcae4a789d" +version = "3.100.3+0" + +[[deps.LBFGSB]] +deps = ["L_BFGS_B_jll"] +git-tree-sha1 = "e2e6f53ee20605d0ea2be473480b7480bd5091b5" +uuid = "5be7bae1-8223-5378-bac3-9e7378a2f6e6" +version = "0.4.1" + +[[deps.LERC_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "aaafe88dccbd957a8d82f7d05be9b69172e0cee3" +uuid = "88015f11-f218-50d7-93a8-a6af411a945d" +version = "4.0.1+0" + +[[deps.LLVM]] +deps = ["CEnum", "LLVMExtra_jll", "Libdl", "Preferences", "Printf", "Unicode"] +git-tree-sha1 = "9c7c721cfd800d87d48c745d8bfb65144f0a91df" +uuid = "929cbde3-209d-540e-8aea-75f648917ca0" +version = "9.4.2" +weakdeps = ["BFloat16s"] + + [deps.LLVM.extensions] + BFloat16sExt = "BFloat16s" + +[[deps.LLVMExtra_jll]] +deps = ["Artifacts", "JLLWrappers", "LazyArtifacts", "Libdl", "TOML"] +git-tree-sha1 = "2ea068aac1e7f0337d381b0eae3110581e3f3216" +uuid = "dad2f222-ce93-54a1-a47d-0025e8a3acab" +version = "0.0.37+2" + +[[deps.LLVMLoopInfo]] +git-tree-sha1 = "2e5c102cfc41f48ae4740c7eca7743cc7e7b75ea" +uuid = "8b046642-f1f6-4319-8d3c-209ddc03c586" +version = "1.0.0" + +[[deps.LLVMOpenMP_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "eb62a3deb62fc6d8822c0c4bef73e4412419c5d8" +uuid = "1d63c593-3942-5779-bab2-d838dc0a180e" +version = "18.1.8+0" + +[[deps.LZO_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "1c602b1127f4751facb671441ca72715cc95938a" +uuid = "dd4b983a-f0e5-5f8d-a1b7-129d4a5fb1ac" +version = "2.10.3+0" + +[[deps.L_BFGS_B_jll]] +deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "77feda930ed3f04b2b0fbb5bea89e69d3677c6b0" +uuid = "81d17ec3-03a1-5e46-b53e-bddc35a13473" +version = "3.0.1+0" + +[[deps.LaTeXStrings]] +git-tree-sha1 = "dda21b8cbd6a6c40d9d02a73230f9d70fed6918c" +uuid = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f" +version = "1.4.0" + +[[deps.LayoutPointers]] +deps = ["ArrayInterface", "LinearAlgebra", "ManualMemory", "SIMDTypes", "Static", "StaticArrayInterface"] +git-tree-sha1 = "a9eaadb366f5493a5654e843864c13d8b107548c" +uuid = "10f19ff3-798f-405d-979b-55457f8fc047" +version = "0.1.17" + +[[deps.LazyArtifacts]] +deps = ["Artifacts", "Pkg"] +uuid = "4af54fe1-eca0-43a8-85a7-787d91b784e3" +version = "1.11.0" + +[[deps.LazyModules]] +git-tree-sha1 = "a560dd966b386ac9ae60bdd3a3d3a326062d3c3e" +uuid = "8cdb02fc-e678-4876-92c5-9defec4f444e" +version = "0.3.1" + +[[deps.LeftChildRightSiblingTrees]] +deps = ["AbstractTrees"] +git-tree-sha1 = "95ba48564903b43b2462318aa243ee79d81135ff" +uuid = "1d6d02ad-be62-4b6b-8a6d-2f90e265016e" +version = "0.2.1" + +[[deps.LibCURL]] +deps = ["LibCURL_jll", "MozillaCACerts_jll"] +uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" +version = "0.6.4" + +[[deps.LibCURL_jll]] +deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] +uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" +version = "8.6.0+0" + +[[deps.LibGit2]] +deps = ["Base64", "LibGit2_jll", "NetworkOptions", "Printf", "SHA"] +uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" +version = "1.11.0" + +[[deps.LibGit2_jll]] +deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll"] +uuid = "e37daf67-58a4-590a-8e99-b0245dd2ffc5" +version = "1.7.2+0" + +[[deps.LibSSH2_jll]] +deps = ["Artifacts", "Libdl", "MbedTLS_jll"] +uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" +version = "1.11.0+1" + +[[deps.LibTracyClient_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "d2bc4e1034b2d43076b50f0e34ea094c2cb0a717" +uuid = "ad6e5548-8b26-5c9f-8ef3-ef0ad883f3a5" +version = "0.9.1+6" + +[[deps.Libdl]] +uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" +version = "1.11.0" + +[[deps.Libffi_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "c8da7e6a91781c41a863611c7e966098d783c57a" +uuid = "e9f186c6-92d2-5b65-8a66-fee21dc1b490" +version = "3.4.7+0" + +[[deps.Libglvnd_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Xorg_libX11_jll", "Xorg_libXext_jll"] +git-tree-sha1 = "d36c21b9e7c172a44a10484125024495e2625ac0" +uuid = "7e76a0d4-f3c7-5321-8279-8d96eeed0f29" +version = "1.7.1+1" + +[[deps.Libiconv_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "be484f5c92fad0bd8acfef35fe017900b0b73809" +uuid = "94ce4f54-9a6c-5748-9c1c-f9c7231a4531" +version = "1.18.0+0" + +[[deps.Libmount_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "a31572773ac1b745e0343fe5e2c8ddda7a37e997" +uuid = "4b2f31a3-9ecc-558c-b454-b3730dcb73e9" +version = "2.41.0+0" + +[[deps.Libtask]] +deps = ["MistyClosures", "Test"] +git-tree-sha1 = "40574644c2baf96ec5d8dbb8c6d038a2e50b775c" +uuid = "6f1fad26-d15e-5dc8-ae53-837a1d7b8c9f" +version = "0.9.3" + +[[deps.Libtiff_jll]] +deps = ["Artifacts", "JLLWrappers", "JpegTurbo_jll", "LERC_jll", "Libdl", "XZ_jll", "Zlib_jll", "Zstd_jll"] +git-tree-sha1 = "4ab7581296671007fc33f07a721631b8855f4b1d" +uuid = "89763e89-9b03-5906-acba-b20f662cd828" +version = "4.7.1+0" + +[[deps.Libuuid_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "321ccef73a96ba828cd51f2ab5b9f917fa73945a" +uuid = "38a345b3-de98-5d2b-a5d3-14cd9215e700" +version = "2.41.0+0" + +[[deps.LineSearches]] +deps = ["LinearAlgebra", "NLSolversBase", "NaNMath", "Parameters", "Printf"] +git-tree-sha1 = "4adee99b7262ad2a1a4bbbc59d993d24e55ea96f" +uuid = "d3d80556-e9d4-5f37-9878-2ab0fcc64255" +version = "7.4.0" + +[[deps.LinearAlgebra]] +deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"] +uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +version = "1.11.0" + +[[deps.Loess]] +deps = ["Distances", "LinearAlgebra", "Statistics", "StatsAPI"] +git-tree-sha1 = "f749e7351f120b3566e5923fefdf8e52ba5ec7f9" +uuid = "4345ca2d-374a-55d4-8d30-97f9976e7612" +version = "0.6.4" + +[[deps.LogDensityProblems]] +deps = ["ArgCheck", "DocStringExtensions", "Random"] +git-tree-sha1 = "4e0128c1590d23a50dcdb106c7e2dbca99df85c0" +uuid = "6fdf6af0-433a-55f7-b3ed-c6c6e0b8df7c" +version = "2.1.2" + +[[deps.LogDensityProblemsAD]] +deps = ["DocStringExtensions", "LogDensityProblems"] +git-tree-sha1 = "7b83f3ad0a8105f79a067cafbfd124827bb398d0" +uuid = "996a588d-648d-4e1f-a8f0-a84b347e47b1" +version = "1.13.1" + + [deps.LogDensityProblemsAD.extensions] + LogDensityProblemsADADTypesExt = "ADTypes" + LogDensityProblemsADDifferentiationInterfaceExt = ["ADTypes", "DifferentiationInterface"] + LogDensityProblemsADEnzymeExt = "Enzyme" + LogDensityProblemsADFiniteDifferencesExt = "FiniteDifferences" + LogDensityProblemsADForwardDiffBenchmarkToolsExt = ["BenchmarkTools", "ForwardDiff"] + LogDensityProblemsADForwardDiffExt = "ForwardDiff" + LogDensityProblemsADReverseDiffExt = "ReverseDiff" + LogDensityProblemsADTrackerExt = "Tracker" + LogDensityProblemsADZygoteExt = "Zygote" + + [deps.LogDensityProblemsAD.weakdeps] + ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b" + BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" + DifferentiationInterface = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63" + Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9" + FiniteDifferences = "26cc04aa-876d-5657-8c51-4c34ba976000" + ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" + ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" + Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" + Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" + +[[deps.LogExpFunctions]] +deps = ["DocStringExtensions", "IrrationalConstants", "LinearAlgebra"] +git-tree-sha1 = "13ca9e2586b89836fd20cccf56e57e2b9ae7f38f" +uuid = "2ab3a3ac-af41-5b50-aa03-7779005ae688" +version = "0.3.29" +weakdeps = ["ChainRulesCore", "ChangesOfVariables", "InverseFunctions"] + + [deps.LogExpFunctions.extensions] + LogExpFunctionsChainRulesCoreExt = "ChainRulesCore" + LogExpFunctionsChangesOfVariablesExt = "ChangesOfVariables" + LogExpFunctionsInverseFunctionsExt = "InverseFunctions" + +[[deps.Logging]] +uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" +version = "1.11.0" + +[[deps.LoggingExtras]] +deps = ["Dates", "Logging"] +git-tree-sha1 = "f02b56007b064fbfddb4c9cd60161b6dd0f40df3" +uuid = "e6f89c97-d47a-5376-807f-9c37f3926c36" +version = "1.1.0" + +[[deps.LoopVectorization]] +deps = ["ArrayInterface", "CPUSummary", "CloseOpenIntervals", "DocStringExtensions", "HostCPUFeatures", "IfElse", "LayoutPointers", "LinearAlgebra", "OffsetArrays", "PolyesterWeave", "PrecompileTools", "SIMDTypes", "SLEEFPirates", "Static", "StaticArrayInterface", "ThreadingUtilities", "UnPack", "VectorizationBase"] +git-tree-sha1 = "e5afce7eaf5b5ca0d444bcb4dc4fd78c54cbbac0" +uuid = "bdcacae8-1622-11e9-2a5c-532679323890" +version = "0.12.172" +weakdeps = ["ChainRulesCore", "ForwardDiff", "SpecialFunctions"] + + [deps.LoopVectorization.extensions] + ForwardDiffExt = ["ChainRulesCore", "ForwardDiff"] + SpecialFunctionsExt = "SpecialFunctions" + +[[deps.MCMCChains]] +deps = ["AbstractMCMC", "AxisArrays", "DataAPI", "Dates", "Distributions", "IteratorInterfaceExtensions", "KernelDensity", "LinearAlgebra", "MCMCDiagnosticTools", "MLJModelInterface", "NaturalSort", "OrderedCollections", "PrettyTables", "Random", "RecipesBase", "Statistics", "StatsBase", "StatsFuns", "TableTraits", "Tables"] +git-tree-sha1 = "a1b9bf62acb012e4a717562f83f859257c5b6fec" +uuid = "c7f686f2-ff18-58e9-bc7b-31028e88f75d" +version = "7.1.0" + +[[deps.MCMCDiagnosticTools]] +deps = ["AbstractFFTs", "DataAPI", "DataStructures", "Distributions", "LinearAlgebra", "MLJModelInterface", "Random", "SpecialFunctions", "Statistics", "StatsBase", "StatsFuns", "Tables"] +git-tree-sha1 = "526c98cd41028da22c01cb8a203246799ad853a8" +uuid = "be115224-59cd-429b-ad48-344e309966f0" +version = "0.3.15" + +[[deps.MKL_jll]] +deps = ["Artifacts", "IntelOpenMP_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "oneTBB_jll"] +git-tree-sha1 = "282cadc186e7b2ae0eeadbd7a4dffed4196ae2aa" +uuid = "856f044c-d86e-5d09-b602-aeab76dc8ba7" +version = "2025.2.0+0" + +[[deps.MLCore]] +deps = ["DataAPI", "SimpleTraits", "Tables"] +git-tree-sha1 = "73907695f35bc7ffd9f11f6c4f2ee8c1302084be" +uuid = "c2834f40-e789-41da-a90e-33b280584a8c" +version = "1.0.0" + +[[deps.MLDataDevices]] +deps = ["Adapt", "Compat", "Functors", "Preferences", "Random"] +git-tree-sha1 = "0ad0d8f83ddf28a7eba28ed94d0d68015ce645b7" +uuid = "7e8f7934-dd98-4c1a-8fe8-92b47a384d40" +version = "1.11.1" + + [deps.MLDataDevices.extensions] + MLDataDevicesAMDGPUExt = "AMDGPU" + MLDataDevicesCUDAExt = "CUDA" + MLDataDevicesChainRulesCoreExt = "ChainRulesCore" + MLDataDevicesChainRulesExt = "ChainRules" + MLDataDevicesComponentArraysExt = "ComponentArrays" + MLDataDevicesFillArraysExt = "FillArrays" + MLDataDevicesGPUArraysExt = "GPUArrays" + MLDataDevicesMLUtilsExt = "MLUtils" + MLDataDevicesMetalExt = ["GPUArrays", "Metal"] + MLDataDevicesOneHotArraysExt = "OneHotArrays" + MLDataDevicesReactantExt = "Reactant" + MLDataDevicesRecursiveArrayToolsExt = "RecursiveArrayTools" + MLDataDevicesReverseDiffExt = "ReverseDiff" + MLDataDevicesSparseArraysExt = "SparseArrays" + MLDataDevicesTrackerExt = "Tracker" + MLDataDevicesZygoteExt = "Zygote" + MLDataDevicescuDNNExt = ["CUDA", "cuDNN"] + MLDataDevicesoneAPIExt = ["GPUArrays", "oneAPI"] + + [deps.MLDataDevices.weakdeps] + AMDGPU = "21141c5a-9bdb-4563-92ae-f87d6854732e" + CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" + ChainRules = "082447d4-558c-5d27-93f4-14fc19e9eca2" + ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" + ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66" + FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b" + GPUArrays = "0c68f7d7-f131-5f86-a1c3-88cf8149b2d7" + MLUtils = "f1d291b0-491e-4a28-83b9-f70985020b54" + Metal = "dde4c033-4e86-420c-a63e-0dd931031962" + OneHotArrays = "0b1bfda6-eb8a-41d2-88d8-f5af5cad476f" + Reactant = "3c362404-f566-11ee-1572-e11a4b42c853" + RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd" + ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" + SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" + Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" + Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" + cuDNN = "02a925ec-e4fe-4b08-9a7e-0d78e3d38ccd" + oneAPI = "8f75cd03-7ff8-4ecb-9b8f-daf728133b1b" + +[[deps.MLJModelInterface]] +deps = ["InteractiveUtils", "REPL", "Random", "ScientificTypesBase", "StatisticalTraits"] +git-tree-sha1 = "ccaa3f7938890ee8042cc970ba275115428bd592" +uuid = "e80e1ace-859a-464e-9ed9-23947d8ae3ea" +version = "1.12.0" + +[[deps.MLStyle]] +git-tree-sha1 = "bc38dff0548128765760c79eb7388a4b37fae2c8" +uuid = "d8e11817-5142-5d16-987a-aa16d5891078" +version = "0.4.17" + +[[deps.MLUtils]] +deps = ["ChainRulesCore", "Compat", "DataAPI", "DelimitedFiles", "FLoops", "MLCore", "NNlib", "Random", "ShowCases", "SimpleTraits", "Statistics", "StatsBase", "Tables", "Transducers"] +git-tree-sha1 = "a772d8d1987433538a5c226f79393324b55f7846" +uuid = "f1d291b0-491e-4a28-83b9-f70985020b54" +version = "0.4.8" + +[[deps.MacroTools]] +git-tree-sha1 = "1e0228a030642014fe5cfe68c2c0a818f9e3f522" +uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" +version = "0.5.16" + +[[deps.Makie]] +deps = ["Animations", "Base64", "CRC32c", "ColorBrewer", "ColorSchemes", "ColorTypes", "Colors", "ComputePipeline", "Contour", "Dates", "DelaunayTriangulation", "Distributions", "DocStringExtensions", "Downloads", "FFMPEG_jll", "FileIO", "FilePaths", "FixedPointNumbers", "Format", "FreeType", "FreeTypeAbstraction", "GeometryBasics", "GridLayoutBase", "ImageBase", "ImageIO", "InteractiveUtils", "Interpolations", "IntervalSets", "InverseFunctions", "Isoband", "KernelDensity", "LaTeXStrings", "LinearAlgebra", "MacroTools", "Markdown", "MathTeXEngine", "Observables", "OffsetArrays", "PNGFiles", "Packing", "Pkg", "PlotUtils", "PolygonOps", "PrecompileTools", "Printf", "REPL", "Random", "RelocatableFolders", "Scratch", "ShaderAbstractions", "Showoff", "SignedDistanceFields", "SparseArrays", "Statistics", "StatsBase", "StatsFuns", "StructArrays", "TriplotBase", "UnicodeFun", "Unitful"] +git-tree-sha1 = "c2dbe9f2b1360edb15d4f711e6cc3ca0cad1acde" +uuid = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" +version = "0.24.5" + +[[deps.ManualMemory]] +git-tree-sha1 = "bcaef4fc7a0cfe2cba636d84cda54b5e4e4ca3cd" +uuid = "d125e4d3-2237-4719-b19c-fa641b8a4667" +version = "0.1.8" + +[[deps.MappedArrays]] +git-tree-sha1 = "2dab0221fe2b0f2cb6754eaa743cc266339f527e" +uuid = "dbb5928d-eab1-5f90-85c2-b9b0edb7c900" +version = "0.4.2" + +[[deps.MarchingCubes]] +deps = ["PrecompileTools", "StaticArrays"] +git-tree-sha1 = "0e893025924b6becbae4109f8020ac0e12674b01" +uuid = "299715c1-40a9-479a-aaf9-4a633d36f717" +version = "0.1.11" + +[[deps.Markdown]] +deps = ["Base64"] +uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" +version = "1.11.0" + +[[deps.MathTeXEngine]] +deps = ["AbstractTrees", "Automa", "DataStructures", "FreeTypeAbstraction", "GeometryBasics", "LaTeXStrings", "REPL", "RelocatableFolders", "UnicodeFun"] +git-tree-sha1 = "a370fef694c109e1950836176ed0d5eabbb65479" +uuid = "0a4f8689-d25c-4efe-a92b-7142dfc1aa53" +version = "0.6.6" + +[[deps.MbedTLS_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" +version = "2.28.6+0" + +[[deps.MicroCollections]] +deps = ["Accessors", "BangBang", "InitialValues"] +git-tree-sha1 = "44d32db644e84c75dab479f1bc15ee76a1a3618f" +uuid = "128add7d-3638-4c79-886c-908ea0c25c34" +version = "0.2.0" + +[[deps.Missings]] +deps = ["DataAPI"] +git-tree-sha1 = "ec4f7fbeab05d7747bdf98eb74d130a2a2ed298d" +uuid = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28" +version = "1.2.0" + +[[deps.MistyClosures]] +git-tree-sha1 = "d1a692e293c2a0dc8fda79c04cad60582f3d4de3" +uuid = "dbe65cb8-6be2-42dd-bbc5-4196aaced4f4" +version = "2.1.0" + +[[deps.Mmap]] +uuid = "a63ad114-7e13-5084-954f-fe012c677804" +version = "1.11.0" + +[[deps.MosaicViews]] +deps = ["MappedArrays", "OffsetArrays", "PaddedViews", "StackViews"] +git-tree-sha1 = "7b86a5d4d70a9f5cdf2dacb3cbe6d251d1a61dbe" +uuid = "e94cdb99-869f-56ef-bcf0-1ae2bcbe0389" +version = "0.3.4" + +[[deps.Moshi]] +deps = ["ExproniconLite", "Jieko"] +git-tree-sha1 = "53f817d3e84537d84545e0ad749e483412dd6b2a" +uuid = "2e0e35c7-a2e4-4343-998d-7ef72827ed2d" +version = "0.3.7" + +[[deps.MozillaCACerts_jll]] +uuid = "14a3606d-f60d-562e-9121-12d972cd8159" +version = "2023.12.12" + +[[deps.NLSolversBase]] +deps = ["ADTypes", "DifferentiationInterface", "Distributed", "FiniteDiff", "ForwardDiff"] +git-tree-sha1 = "25a6638571a902ecfb1ae2a18fc1575f86b1d4df" +uuid = "d41bc354-129a-5804-8e4c-c37616107c6c" +version = "7.10.0" + +[[deps.NNlib]] +deps = ["Adapt", "Atomix", "ChainRulesCore", "GPUArraysCore", "KernelAbstractions", "LinearAlgebra", "Random", "ScopedValues", "Statistics"] +git-tree-sha1 = "eb6eb10b675236cee09a81da369f94f16d77dc2f" +uuid = "872c559c-99b0-510c-b3b7-b6c96a88d5cd" +version = "0.9.31" + + [deps.NNlib.extensions] + NNlibAMDGPUExt = "AMDGPU" + NNlibCUDACUDNNExt = ["CUDA", "cuDNN"] + NNlibCUDAExt = "CUDA" + NNlibEnzymeCoreExt = "EnzymeCore" + NNlibFFTWExt = "FFTW" + NNlibForwardDiffExt = "ForwardDiff" + NNlibSpecialFunctionsExt = "SpecialFunctions" + + [deps.NNlib.weakdeps] + AMDGPU = "21141c5a-9bdb-4563-92ae-f87d6854732e" + CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" + EnzymeCore = "f151be2c-9106-41f4-ab19-57ee4f262869" + FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341" + ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" + SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b" + cuDNN = "02a925ec-e4fe-4b08-9a7e-0d78e3d38ccd" + +[[deps.NVTX]] +deps = ["Colors", "JuliaNVTXCallbacks_jll", "Libdl", "NVTX_jll"] +git-tree-sha1 = "6b573a3e66decc7fc747afd1edbf083ff78c813a" +uuid = "5da4648a-3479-48b8-97b9-01cb529c0a1f" +version = "1.0.1" + +[[deps.NVTX_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "af2232f69447494514c25742ba1503ec7e9877fe" +uuid = "e98f9f5b-d649-5603-91fd-7774390e6439" +version = "3.2.2+0" + +[[deps.NaNMath]] +deps = ["OpenLibm_jll"] +git-tree-sha1 = "9b8215b1ee9e78a293f99797cd31375471b2bcae" +uuid = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3" +version = "1.1.3" + +[[deps.NameResolution]] +deps = ["PrettyPrint"] +git-tree-sha1 = "1a0fa0e9613f46c9b8c11eee38ebb4f590013c5e" +uuid = "71a1bf82-56d0-4bbc-8a3c-48b961074391" +version = "0.1.5" + +[[deps.NamedArrays]] +deps = ["Combinatorics", "DataStructures", "DelimitedFiles", "InvertedIndices", "LinearAlgebra", "Random", "Requires", "SparseArrays", "Statistics"] +git-tree-sha1 = "b0219babbb69e4f0b292a11ad7f33520bdfcea8f" +uuid = "86f7a689-2022-50b4-a561-43c23ac3c673" +version = "0.10.4" + +[[deps.NaturalSort]] +git-tree-sha1 = "eda490d06b9f7c00752ee81cfa451efe55521e21" +uuid = "c020b1a1-e9b0-503a-9c33-f039bfc54a85" +version = "1.0.0" + +[[deps.Netpbm]] +deps = ["FileIO", "ImageCore", "ImageMetadata"] +git-tree-sha1 = "d92b107dbb887293622df7697a2223f9f8176fcd" +uuid = "f09324ee-3d7c-5217-9330-fc30815ba969" +version = "1.1.1" + +[[deps.NetworkOptions]] +uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" +version = "1.2.0" + +[[deps.Observables]] +git-tree-sha1 = "7438a59546cf62428fc9d1bc94729146d37a7225" +uuid = "510215fc-4207-5dde-b226-833fc4488ee2" +version = "0.5.5" + +[[deps.OffsetArrays]] +git-tree-sha1 = "117432e406b5c023f665fa73dc26e79ec3630151" +uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" +version = "1.17.0" +weakdeps = ["Adapt"] + + [deps.OffsetArrays.extensions] + OffsetArraysAdaptExt = "Adapt" + +[[deps.Ogg_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "b6aa4566bb7ae78498a5e68943863fa8b5231b59" +uuid = "e7412a2a-1a6e-54c0-be00-318e2571c051" +version = "1.3.6+0" + +[[deps.OneHotArrays]] +deps = ["Adapt", "ChainRulesCore", "Compat", "GPUArraysCore", "LinearAlgebra", "NNlib"] +git-tree-sha1 = "bfe8e84c71972f77e775f75e6d8048ad3fdbe8bc" +uuid = "0b1bfda6-eb8a-41d2-88d8-f5af5cad476f" +version = "0.2.10" + +[[deps.OpenBLASConsistentFPCSR_jll]] +deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl"] +git-tree-sha1 = "567515ca155d0020a45b05175449b499c63e7015" +uuid = "6cdc7f73-28fd-5e50-80fb-958a8875b1af" +version = "0.3.29+0" + +[[deps.OpenBLAS_jll]] +deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] +uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" +version = "0.3.27+1" + +[[deps.OpenEXR]] +deps = ["Colors", "FileIO", "OpenEXR_jll"] +git-tree-sha1 = "97db9e07fe2091882c765380ef58ec553074e9c7" +uuid = "52e1d378-f018-4a11-a4be-720524705ac7" +version = "0.3.3" + +[[deps.OpenEXR_jll]] +deps = ["Artifacts", "Imath_jll", "JLLWrappers", "Libdl", "Zlib_jll"] +git-tree-sha1 = "8292dd5c8a38257111ada2174000a33745b06d4e" +uuid = "18a262bb-aa17-5467-a713-aee519bc75cb" +version = "3.2.4+0" + +[[deps.OpenLibm_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "05823500-19ac-5b8b-9628-191a04bc5112" +version = "0.8.1+4" + +[[deps.OpenSSL_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "2ae7d4ddec2e13ad3bddf5c0796f7547cf682391" +uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95" +version = "3.5.2+0" + +[[deps.OpenSpecFun_jll]] +deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl"] +git-tree-sha1 = "1346c9208249809840c91b26703912dff463d335" +uuid = "efe28fd5-8261-553b-a9e1-b2916fc3738e" +version = "0.5.6+0" + +[[deps.Optim]] +deps = ["Compat", "EnumX", "FillArrays", "ForwardDiff", "LineSearches", "LinearAlgebra", "NLSolversBase", "NaNMath", "PositiveFactorizations", "Printf", "SparseArrays", "StatsBase"] +git-tree-sha1 = "61942645c38dd2b5b78e2082c9b51ab315315d10" +uuid = "429524aa-4258-5aef-a3af-852621145aeb" +version = "1.13.2" + + [deps.Optim.extensions] + OptimMOIExt = "MathOptInterface" + + [deps.Optim.weakdeps] + MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee" + +[[deps.Optimisers]] +deps = ["ChainRulesCore", "ConstructionBase", "Functors", "LinearAlgebra", "Random", "Statistics"] +git-tree-sha1 = "131dc319e7c58317e8c6d5170440f6bdaee0a959" +uuid = "3bd65402-5787-11e9-1adc-39752487f4e2" +version = "0.4.6" + + [deps.Optimisers.extensions] + OptimisersAdaptExt = ["Adapt"] + OptimisersEnzymeCoreExt = "EnzymeCore" + OptimisersReactantExt = "Reactant" + + [deps.Optimisers.weakdeps] + Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" + EnzymeCore = "f151be2c-9106-41f4-ab19-57ee4f262869" + Reactant = "3c362404-f566-11ee-1572-e11a4b42c853" + +[[deps.Optimization]] +deps = ["ADTypes", "ArrayInterface", "ConsoleProgressMonitor", "DocStringExtensions", "LBFGSB", "LinearAlgebra", "Logging", "LoggingExtras", "OptimizationBase", "Printf", "ProgressLogging", "Reexport", "SciMLBase", "SparseArrays", "TerminalLoggers"] +git-tree-sha1 = "41902230755effe29a8599ea4b61dc3ffc2c952d" +uuid = "7f7a1694-90dd-40f0-9382-eb1efda571ba" +version = "4.5.0" + +[[deps.OptimizationBase]] +deps = ["ADTypes", "ArrayInterface", "DifferentiationInterface", "DocStringExtensions", "FastClosures", "LinearAlgebra", "PDMats", "Reexport", "Requires", "SciMLBase", "SparseArrays", "SparseConnectivityTracer", "SparseMatrixColorings"] +git-tree-sha1 = "474b2fa6de9288d34b8ad42c9c500088132621a7" +uuid = "bca83a33-5cc9-4baa-983d-23429ab6bcbb" +version = "2.10.0" + + [deps.OptimizationBase.extensions] + OptimizationEnzymeExt = "Enzyme" + OptimizationFiniteDiffExt = "FiniteDiff" + OptimizationForwardDiffExt = "ForwardDiff" + OptimizationMLDataDevicesExt = "MLDataDevices" + OptimizationMLUtilsExt = "MLUtils" + OptimizationMTKExt = "ModelingToolkit" + OptimizationReverseDiffExt = "ReverseDiff" + OptimizationSymbolicAnalysisExt = "SymbolicAnalysis" + OptimizationZygoteExt = "Zygote" + + [deps.OptimizationBase.weakdeps] + Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9" + FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41" + ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" + MLDataDevices = "7e8f7934-dd98-4c1a-8fe8-92b47a384d40" + MLUtils = "f1d291b0-491e-4a28-83b9-f70985020b54" + ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78" + ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" + SymbolicAnalysis = "4297ee4d-0239-47d8-ba5d-195ecdf594fe" + Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" + +[[deps.OptimizationOptimJL]] +deps = ["Optim", "Optimization", "PrecompileTools", "Reexport", "SparseArrays"] +git-tree-sha1 = "6f228118b81ce4e849091ee0d00805f2ecb18f54" +uuid = "36348300-93cb-4f02-beb5-3c3902f8871e" +version = "0.4.3" + +[[deps.OptimizationOptimisers]] +deps = ["Optimisers", "Optimization", "Printf", "ProgressLogging", "Reexport"] +git-tree-sha1 = "06d5ec14933d0e6f62a3709ef30a7a251daf7a22" +uuid = "42dfb2eb-d2b4-4451-abcd-913932933ac1" +version = "0.3.9" + +[[deps.Opus_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "c392fc5dd032381919e3b22dd32d6443760ce7ea" +uuid = "91d4177d-7536-5919-b921-800302f37372" +version = "1.5.2+0" + +[[deps.OrderedCollections]] +git-tree-sha1 = "05868e21324cede2207c6f0f466b4bfef6d5e7ee" +uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" +version = "1.8.1" + +[[deps.PCRE2_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "efcefdf7-47ab-520b-bdef-62a2eaa19f15" +version = "10.42.0+1" + +[[deps.PDMats]] +deps = ["LinearAlgebra", "SparseArrays", "SuiteSparse"] +git-tree-sha1 = "f07c06228a1c670ae4c87d1276b92c7c597fdda0" +uuid = "90014a1f-27ba-587c-ab20-58faa44d9150" +version = "0.11.35" + +[[deps.PNGFiles]] +deps = ["Base64", "CEnum", "ImageCore", "IndirectArrays", "OffsetArrays", "libpng_jll"] +git-tree-sha1 = "cf181f0b1e6a18dfeb0ee8acc4a9d1672499626c" +uuid = "f57f5aa1-a3ce-4bc8-8ab9-96f992907883" +version = "0.4.4" + +[[deps.Packing]] +deps = ["GeometryBasics"] +git-tree-sha1 = "bc5bf2ea3d5351edf285a06b0016788a121ce92c" +uuid = "19eb6ba3-879d-56ad-ad62-d5c202156566" +version = "0.5.1" + +[[deps.PaddedViews]] +deps = ["OffsetArrays"] +git-tree-sha1 = "0fac6313486baae819364c52b4f483450a9d793f" +uuid = "5432bcbf-9aad-5242-b902-cca2824c8663" +version = "0.5.12" + +[[deps.Pango_jll]] +deps = ["Artifacts", "Cairo_jll", "Fontconfig_jll", "FreeType2_jll", "FriBidi_jll", "Glib_jll", "HarfBuzz_jll", "JLLWrappers", "Libdl"] +git-tree-sha1 = "275a9a6d85dc86c24d03d1837a0010226a96f540" +uuid = "36c8627f-9965-5494-a995-c6b170f724f3" +version = "1.56.3+0" + +[[deps.Parameters]] +deps = ["OrderedCollections", "UnPack"] +git-tree-sha1 = "34c0e9ad262e5f7fc75b10a9952ca7692cfc5fbe" +uuid = "d96e819e-fc66-5662-9728-84c9c7592b0a" +version = "0.12.3" + +[[deps.Parsers]] +deps = ["Dates", "PrecompileTools", "UUIDs"] +git-tree-sha1 = "7d2f8f21da5db6a806faf7b9b292296da42b2810" +uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" +version = "2.8.3" + +[[deps.Pixman_jll]] +deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "LLVMOpenMP_jll", "Libdl"] +git-tree-sha1 = "db76b1ecd5e9715f3d043cec13b2ec93ce015d53" +uuid = "30392449-352a-5448-841d-b1acce4e97dc" +version = "0.44.2+0" + +[[deps.Pkg]] +deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "Random", "SHA", "TOML", "Tar", "UUIDs", "p7zip_jll"] +uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" +version = "1.11.0" +weakdeps = ["REPL"] + + [deps.Pkg.extensions] + REPLExt = "REPL" + +[[deps.PkgVersion]] +deps = ["Pkg"] +git-tree-sha1 = "f9501cc0430a26bc3d156ae1b5b0c1b47af4d6da" +uuid = "eebad327-c553-4316-9ea0-9fa01ccd7688" +version = "0.3.3" + +[[deps.PlotUtils]] +deps = ["ColorSchemes", "Colors", "Dates", "PrecompileTools", "Printf", "Random", "Reexport", "StableRNGs", "Statistics"] +git-tree-sha1 = "3ca9a356cd2e113c420f2c13bea19f8d3fb1cb18" +uuid = "995b91a9-d308-5afd-9ec6-746e21dbc043" +version = "1.4.3" + +[[deps.Polyester]] +deps = ["ArrayInterface", "BitTwiddlingConvenienceFunctions", "CPUSummary", "IfElse", "ManualMemory", "PolyesterWeave", "Static", "StaticArrayInterface", "StrideArraysCore", "ThreadingUtilities"] +git-tree-sha1 = "6f7cd22a802094d239824c57d94c8e2d0f7cfc7d" +uuid = "f517fe37-dbe3-4b94-8317-1923a5111588" +version = "0.7.18" + +[[deps.PolyesterWeave]] +deps = ["BitTwiddlingConvenienceFunctions", "CPUSummary", "IfElse", "Static", "ThreadingUtilities"] +git-tree-sha1 = "645bed98cd47f72f67316fd42fc47dee771aefcd" +uuid = "1d0040c9-8b98-4ee7-8388-3f51789ca0ad" +version = "0.2.2" + +[[deps.PolygonOps]] +git-tree-sha1 = "77b3d3605fc1cd0b42d95eba87dfcd2bf67d5ff6" +uuid = "647866c9-e3ac-4575-94e7-e3d426903924" +version = "0.1.2" + +[[deps.PooledArrays]] +deps = ["DataAPI", "Future"] +git-tree-sha1 = "36d8b4b899628fb92c2749eb488d884a926614d3" +uuid = "2dfb63ee-cc39-5dd5-95bd-886bf059d720" +version = "1.4.3" + +[[deps.PositiveFactorizations]] +deps = ["LinearAlgebra"] +git-tree-sha1 = "17275485f373e6673f7e7f97051f703ed5b15b20" +uuid = "85a6dd25-e78a-55b7-8502-1745935b8125" +version = "0.2.4" + +[[deps.PrecompileTools]] +deps = ["Preferences"] +git-tree-sha1 = "5aa36f7049a63a1528fe8f7c3f2113413ffd4e1f" +uuid = "aea7be01-6a6a-4083-8856-8a6e6704d82a" +version = "1.2.1" + +[[deps.Preferences]] +deps = ["TOML"] +git-tree-sha1 = "0f27480397253da18fe2c12a4ba4eb9eb208bf3d" +uuid = "21216c6a-2e73-6563-6e65-726566657250" +version = "1.5.0" + +[[deps.PrettyPrint]] +git-tree-sha1 = "632eb4abab3449ab30c5e1afaa874f0b98b586e4" +uuid = "8162dcfd-2161-5ef2-ae6c-7681170c5f98" +version = "0.2.0" + +[[deps.PrettyTables]] +deps = ["Crayons", "LaTeXStrings", "Markdown", "PrecompileTools", "Printf", "Reexport", "StringManipulation", "Tables"] +git-tree-sha1 = "1101cd475833706e4d0e7b122218257178f48f34" +uuid = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d" +version = "2.4.0" + +[[deps.Printf]] +deps = ["Unicode"] +uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" +version = "1.11.0" + +[[deps.ProgressLogging]] +deps = ["Logging", "SHA", "UUIDs"] +git-tree-sha1 = "d95ed0324b0799843ac6f7a6a85e65fe4e5173f0" +uuid = "33c8b6b6-d38a-422a-b730-caa89a2f386c" +version = "0.1.5" + +[[deps.ProgressMeter]] +deps = ["Distributed", "Printf"] +git-tree-sha1 = "13c5103482a8ed1536a54c08d0e742ae3dca2d42" +uuid = "92933f4c-e287-5a05-a399-4b506db050ca" +version = "1.10.4" + +[[deps.PtrArrays]] +git-tree-sha1 = "1d36ef11a9aaf1e8b74dacc6a731dd1de8fd493d" +uuid = "43287f4e-b6f4-7ad1-bb20-aadabca52c3d" +version = "1.3.0" + +[[deps.QOI]] +deps = ["ColorTypes", "FileIO", "FixedPointNumbers"] +git-tree-sha1 = "8b3fc30bc0390abdce15f8822c889f669baed73d" +uuid = "4b34888f-f399-49d4-9bb3-47ed5cae4e65" +version = "1.0.1" + +[[deps.QuadGK]] +deps = ["DataStructures", "LinearAlgebra"] +git-tree-sha1 = "9da16da70037ba9d701192e27befedefb91ec284" +uuid = "1fd47b50-473d-5c70-9696-f719f8f3bcdc" +version = "2.11.2" + + [deps.QuadGK.extensions] + QuadGKEnzymeExt = "Enzyme" + + [deps.QuadGK.weakdeps] + Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9" + +[[deps.REPL]] +deps = ["InteractiveUtils", "Markdown", "Sockets", "StyledStrings", "Unicode"] +uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" +version = "1.11.0" + +[[deps.Random]] +deps = ["SHA"] +uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" +version = "1.11.0" + +[[deps.Random123]] +deps = ["Random", "RandomNumbers"] +git-tree-sha1 = "dbe5fd0b334694e905cb9fda73cd8554333c46e2" +uuid = "74087812-796a-5b5d-8853-05524746bad3" +version = "1.7.1" + +[[deps.RandomNumbers]] +deps = ["Random"] +git-tree-sha1 = "c6ec94d2aaba1ab2ff983052cf6a606ca5985902" +uuid = "e6cf234a-135c-5ec9-84dd-332b85af5143" +version = "1.6.0" + +[[deps.RangeArrays]] +git-tree-sha1 = "b9039e93773ddcfc828f12aadf7115b4b4d225f5" +uuid = "b3c3ace0-ae52-54e7-9d0b-2c1406fd6b9d" +version = "0.3.2" + +[[deps.Ratios]] +deps = ["Requires"] +git-tree-sha1 = "1342a47bf3260ee108163042310d26f2be5ec90b" +uuid = "c84ed2f1-dad5-54f0-aa8e-dbefe2724439" +version = "0.4.5" +weakdeps = ["FixedPointNumbers"] + + [deps.Ratios.extensions] + RatiosFixedPointNumbersExt = "FixedPointNumbers" + +[[deps.RealDot]] +deps = ["LinearAlgebra"] +git-tree-sha1 = "9f0a1b71baaf7650f4fa8a1d168c7fb6ee41f0c9" +uuid = "c1ae055f-0cd5-4b69-90a6-9a35b1a98df9" +version = "0.1.0" + +[[deps.RecipesBase]] +deps = ["PrecompileTools"] +git-tree-sha1 = "5c3d09cc4f31f5fc6af001c250bf1278733100ff" +uuid = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" +version = "1.3.4" + +[[deps.RecursiveArrayTools]] +deps = ["Adapt", "ArrayInterface", "DocStringExtensions", "GPUArraysCore", "LinearAlgebra", "RecipesBase", "StaticArraysCore", "Statistics", "SymbolicIndexingInterface"] +git-tree-sha1 = "7c7ac305885b1e0292585d087ecd60331a705965" +uuid = "731186ca-8d62-57ce-b412-fbd966d074cd" +version = "3.37.0" + + [deps.RecursiveArrayTools.extensions] + RecursiveArrayToolsFastBroadcastExt = "FastBroadcast" + RecursiveArrayToolsForwardDiffExt = "ForwardDiff" + RecursiveArrayToolsKernelAbstractionsExt = "KernelAbstractions" + RecursiveArrayToolsMeasurementsExt = "Measurements" + RecursiveArrayToolsMonteCarloMeasurementsExt = "MonteCarloMeasurements" + RecursiveArrayToolsReverseDiffExt = ["ReverseDiff", "Zygote"] + RecursiveArrayToolsSparseArraysExt = ["SparseArrays"] + RecursiveArrayToolsStructArraysExt = "StructArrays" + RecursiveArrayToolsTablesExt = ["Tables"] + RecursiveArrayToolsTrackerExt = "Tracker" + RecursiveArrayToolsZygoteExt = "Zygote" + + [deps.RecursiveArrayTools.weakdeps] + FastBroadcast = "7034ab61-46d4-4ed7-9d0f-46aef9175898" + ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" + KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c" + Measurements = "eff96d63-e80a-5855-80a2-b1b0885c5ab7" + MonteCarloMeasurements = "0987c9cc-fe09-11e8-30f0-b96dd679fdca" + ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" + SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" + StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a" + Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" + Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" + Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" + +[[deps.Reexport]] +git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b" +uuid = "189a3867-3050-52da-a836-e630ba90ab69" +version = "1.2.2" + +[[deps.RelocatableFolders]] +deps = ["SHA", "Scratch"] +git-tree-sha1 = "ffdaf70d81cf6ff22c2b6e733c900c3321cab864" +uuid = "05181044-ff0b-4ac5-8273-598c1e38db00" +version = "1.0.1" + +[[deps.Requires]] +deps = ["UUIDs"] +git-tree-sha1 = "62389eeff14780bfe55195b7204c0d8738436d64" +uuid = "ae029012-a4dd-5104-9daa-d747884805df" +version = "1.3.1" + +[[deps.Richardson]] +deps = ["LinearAlgebra"] +git-tree-sha1 = "48f038bfd83344065434089c2a79417f38715c41" +uuid = "708f8203-808e-40c0-ba2d-98a6953ed40d" +version = "1.4.2" + +[[deps.Rmath]] +deps = ["Random", "Rmath_jll"] +git-tree-sha1 = "852bd0f55565a9e973fcfee83a84413270224dc4" +uuid = "79098fc4-a85e-5d69-aa6a-4863f24498fa" +version = "0.8.0" + +[[deps.Rmath_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "58cdd8fb2201a6267e1db87ff148dd6c1dbd8ad8" +uuid = "f50d1b31-88e8-58de-be2c-1cc44531875f" +version = "0.5.1+0" + +[[deps.Roots]] +deps = ["Accessors", "CommonSolve", "Printf"] +git-tree-sha1 = "668e411c0616a70860249b4c96e5d35296631a1d" +uuid = "f2b01f46-fcfa-551c-844a-d8ac1e96c665" +version = "2.2.8" + + [deps.Roots.extensions] + RootsChainRulesCoreExt = "ChainRulesCore" + RootsForwardDiffExt = "ForwardDiff" + RootsIntervalRootFindingExt = "IntervalRootFinding" + RootsSymPyExt = "SymPy" + RootsSymPyPythonCallExt = "SymPyPythonCall" + + [deps.Roots.weakdeps] + ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" + ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" + IntervalRootFinding = "d2bf35a9-74e0-55ec-b149-d360ff49b807" + SymPy = "24249f21-da20-56a4-8eb1-6a02cf4ae2e6" + SymPyPythonCall = "bc8888f7-b21e-4b7c-a06a-5d9c9496438c" + +[[deps.RoundingEmulator]] +git-tree-sha1 = "40b9edad2e5287e05bd413a38f61a8ff55b9557b" +uuid = "5eaf0fd0-dfba-4ccb-bf02-d820a40db705" +version = "0.2.1" + +[[deps.RuntimeGeneratedFunctions]] +deps = ["ExprTools", "SHA", "Serialization"] +git-tree-sha1 = "86a8a8b783481e1ea6b9c91dd949cb32191f8ab4" +uuid = "7e49a35a-f44a-4d26-94aa-eba1b4ca6b47" +version = "0.5.15" + +[[deps.SHA]] +uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" +version = "0.7.0" + +[[deps.SIMD]] +deps = ["PrecompileTools"] +git-tree-sha1 = "fea870727142270bdf7624ad675901a1ee3b4c87" +uuid = "fdea26ae-647d-5447-a871-4b548cad5224" +version = "3.7.1" + +[[deps.SIMDTypes]] +git-tree-sha1 = "330289636fb8107c5f32088d2741e9fd7a061a5c" +uuid = "94e857df-77ce-4151-89e5-788b33177be4" +version = "0.1.0" + +[[deps.SLEEFPirates]] +deps = ["IfElse", "Static", "VectorizationBase"] +git-tree-sha1 = "456f610ca2fbd1c14f5fcf31c6bfadc55e7d66e0" +uuid = "476501e8-09a2-5ece-8869-fb82de89a1fa" +version = "0.6.43" + +[[deps.SSMProblems]] +deps = ["AbstractMCMC", "Distributions", "Random"] +git-tree-sha1 = "b00814e67e8aacda2073865a3832e6cc378ea504" +uuid = "26aad666-b158-4e64-9d35-0e672562fa48" +version = "0.5.1" + +[[deps.SciMLBase]] +deps = ["ADTypes", "Accessors", "Adapt", "ArrayInterface", "CommonSolve", "ConstructionBase", "Distributed", "DocStringExtensions", "EnumX", "FunctionWrappersWrappers", "IteratorInterfaceExtensions", "LinearAlgebra", "Logging", "Markdown", "Moshi", "PrecompileTools", "Preferences", "Printf", "RecipesBase", "RecursiveArrayTools", "Reexport", "RuntimeGeneratedFunctions", "SciMLOperators", "SciMLStructures", "StaticArraysCore", "Statistics", "SymbolicIndexingInterface"] +git-tree-sha1 = "c056c723b68700fec386dfde8c577089df720c8e" +uuid = "0bca4576-84f4-4d90-8ffe-ffa030f20462" +version = "2.108.0" + + [deps.SciMLBase.extensions] + SciMLBaseChainRulesCoreExt = "ChainRulesCore" + SciMLBaseMLStyleExt = "MLStyle" + SciMLBaseMakieExt = "Makie" + SciMLBasePartialFunctionsExt = "PartialFunctions" + SciMLBasePyCallExt = "PyCall" + SciMLBasePythonCallExt = "PythonCall" + SciMLBaseRCallExt = "RCall" + SciMLBaseZygoteExt = ["Zygote", "ChainRulesCore"] + + [deps.SciMLBase.weakdeps] + ChainRules = "082447d4-558c-5d27-93f4-14fc19e9eca2" + ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" + MLStyle = "d8e11817-5142-5d16-987a-aa16d5891078" + Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" + PartialFunctions = "570af359-4316-4cb7-8c74-252c00c2016b" + PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0" + PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d" + RCall = "6f49c342-dc21-5d91-9882-a32aef131414" + Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" + +[[deps.SciMLOperators]] +deps = ["Accessors", "ArrayInterface", "DocStringExtensions", "LinearAlgebra", "MacroTools"] +git-tree-sha1 = "aea915a39b547c48a18ee041120db1ae8df5a691" +uuid = "c0aeaf25-5076-4817-a8d5-81caf7dfa961" +version = "1.5.0" +weakdeps = ["SparseArrays", "StaticArraysCore"] + + [deps.SciMLOperators.extensions] + SciMLOperatorsSparseArraysExt = "SparseArrays" + SciMLOperatorsStaticArraysCoreExt = "StaticArraysCore" + +[[deps.SciMLStructures]] +deps = ["ArrayInterface"] +git-tree-sha1 = "566c4ed301ccb2a44cbd5a27da5f885e0ed1d5df" +uuid = "53ae85a6-f571-4167-b2af-e1d143709226" +version = "1.7.0" + +[[deps.ScientificTypesBase]] +git-tree-sha1 = "a8e18eb383b5ecf1b5e6fc237eb39255044fd92b" +uuid = "30f210dd-8aff-4c5f-94ba-8e64358c1161" +version = "3.0.0" + +[[deps.ScopedValues]] +deps = ["HashArrayMappedTries", "Logging"] +git-tree-sha1 = "7f44eef6b1d284465fafc66baf4d9bdcc239a15b" +uuid = "7e506255-f358-4e82-b7e4-beb19740aa63" +version = "1.4.0" + +[[deps.Scratch]] +deps = ["Dates"] +git-tree-sha1 = "9b81b8393e50b7d4e6d0a9f14e192294d3b7c109" +uuid = "6c6a2e73-6563-6170-7368-637461726353" +version = "1.3.0" + +[[deps.SentinelArrays]] +deps = ["Dates", "Random"] +git-tree-sha1 = "712fb0231ee6f9120e005ccd56297abbc053e7e0" +uuid = "91c51154-3ec4-41a3-a24f-3f23e20d615c" +version = "1.4.8" + +[[deps.Serialization]] +uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" +version = "1.11.0" + +[[deps.Setfield]] +deps = ["ConstructionBase", "Future", "MacroTools", "StaticArraysCore"] +git-tree-sha1 = "c5391c6ace3bc430ca630251d02ea9687169ca68" +uuid = "efcf1570-3423-57d1-acb7-fd33fddbac46" +version = "1.1.2" + +[[deps.ShaderAbstractions]] +deps = ["ColorTypes", "FixedPointNumbers", "GeometryBasics", "LinearAlgebra", "Observables", "StaticArrays"] +git-tree-sha1 = "818554664a2e01fc3784becb2eb3a82326a604b6" +uuid = "65257c39-d410-5151-9873-9b3e5be5013e" +version = "0.5.0" + +[[deps.SharedArrays]] +deps = ["Distributed", "Mmap", "Random", "Serialization"] +uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383" +version = "1.11.0" + +[[deps.ShiftedArrays]] +git-tree-sha1 = "503688b59397b3307443af35cd953a13e8005c16" +uuid = "1277b4bf-5013-50f5-be3d-901d8477a67a" +version = "2.0.0" + +[[deps.ShowCases]] +git-tree-sha1 = "7f534ad62ab2bd48591bdeac81994ea8c445e4a5" +uuid = "605ecd9f-84a6-4c9e-81e2-4798472b76a3" +version = "0.1.0" + +[[deps.Showoff]] +deps = ["Dates", "Grisu"] +git-tree-sha1 = "91eddf657aca81df9ae6ceb20b959ae5653ad1de" +uuid = "992d4aef-0814-514b-bc4d-f2e9a6c4116f" +version = "1.0.3" + +[[deps.SignedDistanceFields]] +deps = ["Random", "Statistics", "Test"] +git-tree-sha1 = "d263a08ec505853a5ff1c1ebde2070419e3f28e9" +uuid = "73760f76-fbc4-59ce-8f25-708e95d2df96" +version = "0.4.0" + +[[deps.SimpleChains]] +deps = ["ArrayInterface", "CPUSummary", "ChainRulesCore", "CloseOpenIntervals", "ForwardDiff", "HostCPUFeatures", "IfElse", "LayoutPointers", "LoopVectorization", "ManualMemory", "Polyester", "Random", "SIMDTypes", "SLEEFPirates", "Static", "StaticArrayInterface", "StaticArrays", "StrideArraysCore", "UnPack", "VectorizationBase", "VectorizedRNG"] +git-tree-sha1 = "a6ab9afaf404469f93346cced3030869e27c8cf0" +uuid = "de6bee2f-e2f4-4ec7-b6ed-219cc6f6e9e5" +version = "0.4.7" + +[[deps.SimpleTraits]] +deps = ["InteractiveUtils", "MacroTools"] +git-tree-sha1 = "be8eeac05ec97d379347584fa9fe2f5f76795bcb" +uuid = "699a6c99-e7fa-54fc-8d76-47d257e15c1d" +version = "0.9.5" + +[[deps.Sixel]] +deps = ["Dates", "FileIO", "ImageCore", "IndirectArrays", "OffsetArrays", "REPL", "libsixel_jll"] +git-tree-sha1 = "0494aed9501e7fb65daba895fb7fd57cc38bc743" +uuid = "45858cf5-a6b0-47a3-bbea-62219f50df47" +version = "0.1.5" + +[[deps.Sockets]] +uuid = "6462fe0b-24de-5631-8697-dd941f90decc" +version = "1.11.0" + +[[deps.SortingAlgorithms]] +deps = ["DataStructures"] +git-tree-sha1 = "64d974c2e6fdf07f8155b5b2ca2ffa9069b608d9" +uuid = "a2af1166-a08f-5f64-846c-94a0d3cef48c" +version = "1.2.2" + +[[deps.SparseArrays]] +deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"] +uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" +version = "1.11.0" + +[[deps.SparseConnectivityTracer]] +deps = ["ADTypes", "DocStringExtensions", "FillArrays", "LinearAlgebra", "Random", "SparseArrays"] +git-tree-sha1 = "7bd2b8981cc57adcf5cf1add282aba2713a7058f" +uuid = "9f842d2f-2579-4b1d-911e-f412cf18a3f5" +version = "1.0.0" +weakdeps = ["LogExpFunctions", "NNlib", "NaNMath", "SpecialFunctions"] + + [deps.SparseConnectivityTracer.extensions] + SparseConnectivityTracerLogExpFunctionsExt = "LogExpFunctions" + SparseConnectivityTracerNNlibExt = "NNlib" + SparseConnectivityTracerNaNMathExt = "NaNMath" + SparseConnectivityTracerSpecialFunctionsExt = "SpecialFunctions" + +[[deps.SparseInverseSubset]] +deps = ["LinearAlgebra", "SparseArrays", "SuiteSparse"] +git-tree-sha1 = "52962839426b75b3021296f7df242e40ecfc0852" +uuid = "dc90abb0-5640-4711-901d-7e5b23a2fada" +version = "0.1.2" + +[[deps.SparseMatrixColorings]] +deps = ["ADTypes", "DocStringExtensions", "LinearAlgebra", "PrecompileTools", "Random", "SparseArrays"] +git-tree-sha1 = "9de43e0b9b976f1019bf7a879a686c4514520078" +uuid = "0a514795-09f3-496d-8182-132a7b665d35" +version = "0.4.21" + + [deps.SparseMatrixColorings.extensions] + SparseMatrixColoringsCUDAExt = "CUDA" + SparseMatrixColoringsCliqueTreesExt = "CliqueTrees" + SparseMatrixColoringsColorsExt = "Colors" + + [deps.SparseMatrixColorings.weakdeps] + CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" + CliqueTrees = "60701a23-6482-424a-84db-faee86b9b1f8" + Colors = "5ae59095-9a9b-59fe-a467-6f913c188581" + +[[deps.SpecialFunctions]] +deps = ["IrrationalConstants", "LogExpFunctions", "OpenLibm_jll", "OpenSpecFun_jll"] +git-tree-sha1 = "41852b8679f78c8d8961eeadc8f62cef861a52e3" +uuid = "276daf66-3868-5448-9aa4-cd146d93841b" +version = "2.5.1" +weakdeps = ["ChainRulesCore"] + + [deps.SpecialFunctions.extensions] + SpecialFunctionsChainRulesCoreExt = "ChainRulesCore" + +[[deps.SplittablesBase]] +deps = ["Setfield", "Test"] +git-tree-sha1 = "e08a62abc517eb79667d0a29dc08a3b589516bb5" +uuid = "171d559e-b47b-412a-8079-5efa626c420e" +version = "0.1.15" + +[[deps.StableRNGs]] +deps = ["Random"] +git-tree-sha1 = "95af145932c2ed859b63329952ce8d633719f091" +uuid = "860ef19b-820b-49d6-a774-d7a799459cd3" +version = "1.0.3" + +[[deps.StackViews]] +deps = ["OffsetArrays"] +git-tree-sha1 = "be1cf4eb0ac528d96f5115b4ed80c26a8d8ae621" +uuid = "cae243ae-269e-4f55-b966-ac2d0dc13c15" +version = "0.1.2" + +[[deps.Static]] +deps = ["CommonWorldInvalidations", "IfElse", "PrecompileTools"] +git-tree-sha1 = "f737d444cb0ad07e61b3c1bef8eb91203c321eff" +uuid = "aedffcd0-7271-4cad-89d0-dc628f76c6d3" +version = "1.2.0" + +[[deps.StaticArrayInterface]] +deps = ["ArrayInterface", "Compat", "IfElse", "LinearAlgebra", "PrecompileTools", "Static"] +git-tree-sha1 = "96381d50f1ce85f2663584c8e886a6ca97e60554" +uuid = "0d7ed370-da01-4f52-bd93-41d350b8b718" +version = "1.8.0" +weakdeps = ["OffsetArrays", "StaticArrays"] + + [deps.StaticArrayInterface.extensions] + StaticArrayInterfaceOffsetArraysExt = "OffsetArrays" + StaticArrayInterfaceStaticArraysExt = "StaticArrays" + +[[deps.StaticArrays]] +deps = ["LinearAlgebra", "PrecompileTools", "Random", "StaticArraysCore"] +git-tree-sha1 = "cbea8a6bd7bed51b1619658dec70035e07b8502f" +uuid = "90137ffa-7385-5640-81b9-e52037218182" +version = "1.9.14" +weakdeps = ["ChainRulesCore", "Statistics"] + + [deps.StaticArrays.extensions] + StaticArraysChainRulesCoreExt = "ChainRulesCore" + StaticArraysStatisticsExt = "Statistics" + +[[deps.StaticArraysCore]] +git-tree-sha1 = "192954ef1208c7019899fbf8049e717f92959682" +uuid = "1e83bf80-4336-4d27-bf5d-d5a4f845583c" +version = "1.4.3" + +[[deps.StatisticalTraits]] +deps = ["ScientificTypesBase"] +git-tree-sha1 = "89f86d9376acd18a1a4fbef66a56335a3a7633b8" +uuid = "64bff920-2084-43da-a3e6-9bb72801c0c9" +version = "3.5.0" + +[[deps.Statistics]] +deps = ["LinearAlgebra"] +git-tree-sha1 = "ae3bb1eb3bba077cd276bc5cfc337cc65c3075c0" +uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" +version = "1.11.1" +weakdeps = ["SparseArrays"] + + [deps.Statistics.extensions] + SparseArraysExt = ["SparseArrays"] + +[[deps.StatsAPI]] +deps = ["LinearAlgebra"] +git-tree-sha1 = "9d72a13a3f4dd3795a195ac5a44d7d6ff5f552ff" +uuid = "82ae8749-77ed-4fe6-ae5f-f523153014b0" +version = "1.7.1" + +[[deps.StatsBase]] +deps = ["AliasTables", "DataAPI", "DataStructures", "LinearAlgebra", "LogExpFunctions", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "StatsAPI"] +git-tree-sha1 = "2c962245732371acd51700dbb268af311bddd719" +uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" +version = "0.34.6" + +[[deps.StatsFuns]] +deps = ["HypergeometricFunctions", "IrrationalConstants", "LogExpFunctions", "Reexport", "Rmath", "SpecialFunctions"] +git-tree-sha1 = "8e45cecc66f3b42633b8ce14d431e8e57a3e242e" +uuid = "4c63d2b9-4356-54db-8cca-17b64c39e42c" +version = "1.5.0" +weakdeps = ["ChainRulesCore", "InverseFunctions"] + + [deps.StatsFuns.extensions] + StatsFunsChainRulesCoreExt = "ChainRulesCore" + StatsFunsInverseFunctionsExt = "InverseFunctions" + +[[deps.StatsModels]] +deps = ["DataAPI", "DataStructures", "LinearAlgebra", "Printf", "REPL", "ShiftedArrays", "SparseArrays", "StatsAPI", "StatsBase", "StatsFuns", "Tables"] +git-tree-sha1 = "728d276a5adc2f1cbb800eec4b63d0a8221024b4" +uuid = "3eaba693-59b7-5ba5-a881-562e759f1c8d" +version = "0.7.5" + +[[deps.StrideArraysCore]] +deps = ["ArrayInterface", "CloseOpenIntervals", "IfElse", "LayoutPointers", "LinearAlgebra", "ManualMemory", "SIMDTypes", "Static", "StaticArrayInterface", "ThreadingUtilities"] +git-tree-sha1 = "f35f6ab602df8413a50c4a25ca14de821e8605fb" +uuid = "7792a7ef-975c-4747-a70f-980b88e8d1da" +version = "0.5.7" + +[[deps.StringManipulation]] +deps = ["PrecompileTools"] +git-tree-sha1 = "725421ae8e530ec29bcbdddbe91ff8053421d023" +uuid = "892a3eda-7b42-436c-8928-eab12a02cf0e" +version = "0.4.1" + +[[deps.StructArrays]] +deps = ["ConstructionBase", "DataAPI", "Tables"] +git-tree-sha1 = "8ad2e38cbb812e29348719cc63580ec1dfeb9de4" +uuid = "09ab397b-f2b6-538f-b94a-2f83cf4a842a" +version = "0.7.1" +weakdeps = ["Adapt", "GPUArraysCore", "KernelAbstractions", "LinearAlgebra", "SparseArrays", "StaticArrays"] + + [deps.StructArrays.extensions] + StructArraysAdaptExt = "Adapt" + StructArraysGPUArraysCoreExt = ["GPUArraysCore", "KernelAbstractions"] + StructArraysLinearAlgebraExt = "LinearAlgebra" + StructArraysSparseArraysExt = "SparseArrays" + StructArraysStaticArraysExt = "StaticArrays" + +[[deps.StyledStrings]] +uuid = "f489334b-da3d-4c2e-b8f0-e476e12c162b" +version = "1.11.0" + +[[deps.SuiteSparse]] +deps = ["Libdl", "LinearAlgebra", "Serialization", "SparseArrays"] +uuid = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9" + +[[deps.SuiteSparse_jll]] +deps = ["Artifacts", "Libdl", "libblastrampoline_jll"] +uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c" +version = "7.7.0+0" + +[[deps.Suppressor]] +deps = ["Logging"] +git-tree-sha1 = "6dbb5b635c5437c68c28c2ac9e39b87138f37c0a" +uuid = "fd094767-a336-5f1f-9728-57cf17d0bbfb" +version = "0.2.8" + +[[deps.SymbolicIndexingInterface]] +deps = ["Accessors", "ArrayInterface", "RuntimeGeneratedFunctions", "StaticArraysCore"] +git-tree-sha1 = "93104ca226670c0cb92ba8bc6998852ad55a2d4c" +uuid = "2efcf032-c050-4f8e-a9bb-153293bab1f5" +version = "0.3.43" +weakdeps = ["PrettyTables"] + + [deps.SymbolicIndexingInterface.extensions] + SymbolicIndexingInterfacePrettyTablesExt = "PrettyTables" + +[[deps.TOML]] +deps = ["Dates"] +uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" +version = "1.0.3" + +[[deps.TableTraits]] +deps = ["IteratorInterfaceExtensions"] +git-tree-sha1 = "c06b2f539df1c6efa794486abfb6ed2022561a39" +uuid = "3783bdb8-4a98-5b6b-af9a-565f29a5fe9c" +version = "1.0.1" + +[[deps.Tables]] +deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "OrderedCollections", "TableTraits"] +git-tree-sha1 = "f2c1efbc8f3a609aadf318094f8fc5204bdaf344" +uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" +version = "1.12.1" + +[[deps.Tar]] +deps = ["ArgTools", "SHA"] +uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" +version = "1.10.0" + +[[deps.TensorCore]] +deps = ["LinearAlgebra"] +git-tree-sha1 = "1feb45f88d133a655e001435632f019a9a1bcdb6" +uuid = "62fd8b95-f654-4bbd-a8a5-9c27f68ccd50" +version = "0.1.1" + +[[deps.TerminalLoggers]] +deps = ["LeftChildRightSiblingTrees", "Logging", "Markdown", "Printf", "ProgressLogging", "UUIDs"] +git-tree-sha1 = "f133fab380933d042f6796eda4e130272ba520ca" +uuid = "5d786b92-1e48-4d6f-9151-6b4477ca9bed" +version = "0.1.7" + +[[deps.Test]] +deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] +uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +version = "1.11.0" + +[[deps.ThreadingUtilities]] +deps = ["ManualMemory"] +git-tree-sha1 = "d969183d3d244b6c33796b5ed01ab97328f2db85" +uuid = "8290d209-cae3-49c0-8002-c8c24d57dab5" +version = "0.5.5" + +[[deps.TiffImages]] +deps = ["ColorTypes", "DataStructures", "DocStringExtensions", "FileIO", "FixedPointNumbers", "IndirectArrays", "Inflate", "Mmap", "OffsetArrays", "PkgVersion", "PrecompileTools", "ProgressMeter", "SIMD", "UUIDs"] +git-tree-sha1 = "02aca429c9885d1109e58f400c333521c13d48a0" +uuid = "731e570b-9d59-4bfa-96dc-6df516fadf69" +version = "0.11.4" + +[[deps.Tracy]] +deps = ["ExprTools", "LibTracyClient_jll", "Libdl"] +git-tree-sha1 = "91dbaee0f50faa4357f7e9fc69442c7b6364dfe5" +uuid = "e689c965-62c8-4b79-b2c5-8359227902fd" +version = "0.1.5" + + [deps.Tracy.extensions] + TracyProfilerExt = "TracyProfiler_jll" + + [deps.Tracy.weakdeps] + TracyProfiler_jll = "0c351ed6-8a68-550e-8b79-de6f926da83c" + +[[deps.TranscodingStreams]] +git-tree-sha1 = "0c45878dcfdcfa8480052b6ab162cdd138781742" +uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa" +version = "0.11.3" + +[[deps.Transducers]] +deps = ["Accessors", "ArgCheck", "BangBang", "Baselet", "CompositionsBase", "ConstructionBase", "DefineSingletons", "Distributed", "InitialValues", "Logging", "Markdown", "MicroCollections", "Requires", "SplittablesBase", "Tables"] +git-tree-sha1 = "7deeab4ff96b85c5f72c824cae53a1398da3d1cb" +uuid = "28d57a85-8fef-5791-bfe6-a80928e7c999" +version = "0.4.84" + + [deps.Transducers.extensions] + TransducersAdaptExt = "Adapt" + TransducersBlockArraysExt = "BlockArrays" + TransducersDataFramesExt = "DataFrames" + TransducersLazyArraysExt = "LazyArrays" + TransducersOnlineStatsBaseExt = "OnlineStatsBase" + TransducersReferenceablesExt = "Referenceables" + + [deps.Transducers.weakdeps] + Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" + BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e" + DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" + LazyArrays = "5078a376-72f3-5289-bfd5-ec5146d43c02" + OnlineStatsBase = "925886fa-5bf2-5e8e-b522-a9147a512338" + Referenceables = "42d2dcc6-99eb-4e98-b66c-637b7d73030e" + +[[deps.TriplotBase]] +git-tree-sha1 = "4d4ed7f294cda19382ff7de4c137d24d16adc89b" +uuid = "981d1d27-644d-49a2-9326-4793e63143c3" +version = "0.1.0" + +[[deps.Turing]] +deps = ["ADTypes", "AbstractMCMC", "AbstractPPL", "Accessors", "AdvancedHMC", "AdvancedMH", "AdvancedPS", "AdvancedVI", "BangBang", "Bijectors", "Compat", "DataStructures", "Distributions", "DistributionsAD", "DocStringExtensions", "DynamicPPL", "EllipticalSliceSampling", "ForwardDiff", "Libtask", "LinearAlgebra", "LogDensityProblems", "MCMCChains", "NamedArrays", "Optimization", "OptimizationOptimJL", "OrderedCollections", "Printf", "Random", "Reexport", "SciMLBase", "SpecialFunctions", "Statistics", "StatsAPI", "StatsBase", "StatsFuns"] +git-tree-sha1 = "ed944065575fd4a6d9d2b802bbd914b53f08bce8" +uuid = "fce5fe82-541a-59a6-adf8-730c64b5f9a0" +version = "0.40.1" + + [deps.Turing.extensions] + TuringDynamicHMCExt = "DynamicHMC" + TuringOptimExt = "Optim" + + [deps.Turing.weakdeps] + DynamicHMC = "bbc10e6e-7c05-544b-b16e-64fede858acb" + Optim = "429524aa-4258-5aef-a3af-852621145aeb" + +[[deps.UUIDs]] +deps = ["Random", "SHA"] +uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" +version = "1.11.0" + +[[deps.UnPack]] +git-tree-sha1 = "387c1f73762231e86e0c9c5443ce3b4a0a9a0c2b" +uuid = "3a884ed6-31ef-47d7-9d2a-63182c4928ed" +version = "1.0.2" + +[[deps.Unicode]] +uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" +version = "1.11.0" + +[[deps.UnicodeFun]] +deps = ["REPL"] +git-tree-sha1 = "53915e50200959667e78a92a418594b428dffddf" +uuid = "1cfade01-22cf-5700-b092-accc4b62d6e1" +version = "0.4.1" + +[[deps.UnicodePlots]] +deps = ["ColorSchemes", "ColorTypes", "Contour", "Crayons", "Dates", "LinearAlgebra", "MarchingCubes", "NaNMath", "PrecompileTools", "Printf", "SparseArrays", "StaticArrays", "StatsBase"] +git-tree-sha1 = "0087c82cf98f2c2bb7df350c02b0b1fc6ae087d6" +uuid = "b8865327-cd53-5732-bb35-84acbb429228" +version = "3.8.1" + + [deps.UnicodePlots.extensions] + FreeTypeExt = ["FileIO", "FreeType"] + ImageInTerminalExt = "ImageInTerminal" + IntervalSetsExt = "IntervalSets" + TermExt = "Term" + UnitfulExt = "Unitful" + + [deps.UnicodePlots.weakdeps] + FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" + FreeType = "b38be410-82b0-50bf-ab77-7b57e271db43" + ImageInTerminal = "d8c32880-2388-543b-8c61-d9f865259254" + IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953" + Term = "22787eb5-b846-44ae-b979-8e399b8463ab" + Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" + +[[deps.Unitful]] +deps = ["Dates", "LinearAlgebra", "Random"] +git-tree-sha1 = "6258d453843c466d84c17a58732dda5deeb8d3af" +uuid = "1986cc42-f94f-5a68-af5c-568840ba703d" +version = "1.24.0" +weakdeps = ["ConstructionBase", "ForwardDiff", "InverseFunctions", "Printf"] + + [deps.Unitful.extensions] + ConstructionBaseUnitfulExt = "ConstructionBase" + ForwardDiffExt = "ForwardDiff" + InverseFunctionsUnitfulExt = "InverseFunctions" + PrintfExt = "Printf" + +[[deps.UnsafeAtomics]] +git-tree-sha1 = "b13c4edda90890e5b04ba24e20a310fbe6f249ff" +uuid = "013be700-e6cd-48c3-b4a1-df204f14c38f" +version = "0.3.0" +weakdeps = ["LLVM"] + + [deps.UnsafeAtomics.extensions] + UnsafeAtomicsLLVM = ["LLVM"] + +[[deps.VectorizationBase]] +deps = ["ArrayInterface", "CPUSummary", "HostCPUFeatures", "IfElse", "LayoutPointers", "Libdl", "LinearAlgebra", "SIMDTypes", "Static", "StaticArrayInterface"] +git-tree-sha1 = "4ab62a49f1d8d9548a1c8d1a75e5f55cf196f64e" +uuid = "3d5dd08c-fd9d-11e8-17fa-ed2836048c2f" +version = "0.21.71" + +[[deps.VectorizedRNG]] +deps = ["Distributed", "Random", "SLEEFPirates", "UnPack", "VectorizationBase"] +git-tree-sha1 = "5ca83562ba95272d8709c6c91e31e23c3c4c9825" +uuid = "33b4df10-0173-11e9-2a0c-851a7edac40e" +version = "0.2.25" +weakdeps = ["Requires", "StaticArraysCore"] + + [deps.VectorizedRNG.extensions] + VectorizedRNGStaticArraysExt = ["StaticArraysCore"] + +[[deps.WebP]] +deps = ["CEnum", "ColorTypes", "FileIO", "FixedPointNumbers", "ImageCore", "libwebp_jll"] +git-tree-sha1 = "aa1ca3c47f119fbdae8770c29820e5e6119b83f2" +uuid = "e3aaa7dc-3e4b-44e0-be63-ffb868ccd7c1" +version = "0.1.3" + +[[deps.WoodburyMatrices]] +deps = ["LinearAlgebra", "SparseArrays"] +git-tree-sha1 = "c1a7aa6219628fcd757dede0ca95e245c5cd9511" +uuid = "efce3f68-66dc-5838-9240-27a6d6f5f9b6" +version = "1.0.0" + +[[deps.XZ_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "fee71455b0aaa3440dfdd54a9a36ccef829be7d4" +uuid = "ffd25f8a-64ca-5728-b0f7-c24cf3aae800" +version = "5.8.1+0" + +[[deps.Xorg_libX11_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Xorg_libxcb_jll", "Xorg_xtrans_jll"] +git-tree-sha1 = "b5899b25d17bf1889d25906fb9deed5da0c15b3b" +uuid = "4f6342f7-b3d2-589e-9d20-edeb45f2b2bc" +version = "1.8.12+0" + +[[deps.Xorg_libXau_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "aa1261ebbac3ccc8d16558ae6799524c450ed16b" +uuid = "0c0b7dd1-d40b-584c-a123-a41640f87eec" +version = "1.0.13+0" + +[[deps.Xorg_libXdmcp_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "52858d64353db33a56e13c341d7bf44cd0d7b309" +uuid = "a3789734-cfe1-5b06-b2d0-1dd0d9d62d05" +version = "1.1.6+0" + +[[deps.Xorg_libXext_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Xorg_libX11_jll"] +git-tree-sha1 = "a4c0ee07ad36bf8bbce1c3bb52d21fb1e0b987fb" +uuid = "1082639a-0dae-5f34-9b06-72781eeb8cb3" +version = "1.3.7+0" + +[[deps.Xorg_libXrender_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Xorg_libX11_jll"] +git-tree-sha1 = "7ed9347888fac59a618302ee38216dd0379c480d" +uuid = "ea2f1a96-1ddc-540d-b46f-429655e07cfa" +version = "0.9.12+0" + +[[deps.Xorg_libxcb_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Xorg_libXau_jll", "Xorg_libXdmcp_jll"] +git-tree-sha1 = "bfcaf7ec088eaba362093393fe11aa141fa15422" +uuid = "c7cfdc94-dc32-55de-ac96-5a1b8d977c5b" +version = "1.17.1+0" + +[[deps.Xorg_xtrans_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "a63799ff68005991f9d9491b6e95bd3478d783cb" +uuid = "c5fb5394-a638-5e4d-96e5-b29de1b5cf10" +version = "1.6.0+0" + +[[deps.Zlib_jll]] +deps = ["Libdl"] +uuid = "83775a58-1f1d-513f-b197-d71354ab007a" +version = "1.2.13+1" + +[[deps.Zstd_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "446b23e73536f84e8037f5dce465e92275f6a308" +uuid = "3161d3a3-bdf6-5164-811a-617609db77b4" +version = "1.5.7+1" + +[[deps.Zygote]] +deps = ["AbstractFFTs", "ChainRules", "ChainRulesCore", "DiffRules", "Distributed", "FillArrays", "ForwardDiff", "GPUArraysCore", "IRTools", "InteractiveUtils", "LinearAlgebra", "LogExpFunctions", "MacroTools", "NaNMath", "PrecompileTools", "Random", "SparseArrays", "SpecialFunctions", "Statistics", "ZygoteRules"] +git-tree-sha1 = "a29cbf3968d36022198bcc6f23fdfd70f7caf737" +uuid = "e88e6eb3-aa80-5325-afca-941959d7151f" +version = "0.7.10" + + [deps.Zygote.extensions] + ZygoteAtomExt = "Atom" + ZygoteColorsExt = "Colors" + ZygoteDistancesExt = "Distances" + ZygoteTrackerExt = "Tracker" + + [deps.Zygote.weakdeps] + Atom = "c52e3926-4ff0-5f6e-af25-54175e0327b1" + Colors = "5ae59095-9a9b-59fe-a467-6f913c188581" + Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7" + Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" + +[[deps.ZygoteRules]] +deps = ["ChainRulesCore", "MacroTools"] +git-tree-sha1 = "434b3de333c75fc446aa0d19fc394edafd07ab08" +uuid = "700de1a5-db45-46bc-99cf-38207098b444" +version = "0.2.7" + +[[deps.cuDNN]] +deps = ["CEnum", "CUDA", "CUDA_Runtime_Discovery", "CUDNN_jll"] +git-tree-sha1 = "8c20cd99f74552772a26712578db42a8a4200cec" +uuid = "02a925ec-e4fe-4b08-9a7e-0d78e3d38ccd" +version = "1.4.3" + +[[deps.demumble_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "6498e3581023f8e530f34760d18f75a69e3a4ea8" +uuid = "1e29f10c-031c-5a83-9565-69cddfc27673" +version = "1.3.0+0" + +[[deps.isoband_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] +git-tree-sha1 = "51b5eeb3f98367157a7a12a1fb0aa5328946c03c" +uuid = "9a68df92-36a6-505f-a73e-abb412b6bfb4" +version = "0.2.3+0" + +[[deps.libaom_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "4bba74fa59ab0755167ad24f98800fe5d727175b" +uuid = "a4ae2306-e953-59d6-aa16-d00cac43593b" +version = "3.12.1+0" + +[[deps.libass_jll]] +deps = ["Artifacts", "Bzip2_jll", "FreeType2_jll", "FriBidi_jll", "HarfBuzz_jll", "JLLWrappers", "Libdl", "Zlib_jll"] +git-tree-sha1 = "125eedcb0a4a0bba65b657251ce1d27c8714e9d6" +uuid = "0ac62f75-1d6f-5e53-bd7c-93b484bb37c0" +version = "0.17.4+0" + +[[deps.libblastrampoline_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" +version = "5.11.0+0" + +[[deps.libfdk_aac_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "646634dd19587a56ee2f1199563ec056c5f228df" +uuid = "f638f0a6-7fb0-5443-88ba-1cc74229b280" +version = "2.0.4+0" + +[[deps.libpng_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Zlib_jll"] +git-tree-sha1 = "07b6a107d926093898e82b3b1db657ebe33134ec" +uuid = "b53b4c65-9356-5827-b1ea-8c7a1a84506f" +version = "1.6.50+0" + +[[deps.libsixel_jll]] +deps = ["Artifacts", "JLLWrappers", "JpegTurbo_jll", "Libdl", "libpng_jll"] +git-tree-sha1 = "c1733e347283df07689d71d61e14be986e49e47a" +uuid = "075b6546-f08a-558a-be8f-8157d0f608a5" +version = "1.10.5+0" + +[[deps.libvorbis_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl", "Ogg_jll"] +git-tree-sha1 = "11e1772e7f3cc987e9d3de991dd4f6b2602663a5" +uuid = "f27f6e37-5d2b-51aa-960f-b287f2bc3b7a" +version = "1.3.8+0" + +[[deps.libwebp_jll]] +deps = ["Artifacts", "Giflib_jll", "JLLWrappers", "JpegTurbo_jll", "Libdl", "Libglvnd_jll", "Libtiff_jll", "libpng_jll"] +git-tree-sha1 = "4e4282c4d846e11dce56d74fa8040130b7a95cb3" +uuid = "c5f90fcd-3b7e-5836-afba-fc50a0988cb2" +version = "1.6.0+0" + +[[deps.nghttp2_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" +version = "1.59.0+0" + +[[deps.oneTBB_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "d5a767a3bb77135a99e433afe0eb14cd7f6914c3" +uuid = "1317d2d5-d96f-522e-a858-c73665f53c3e" +version = "2022.0.0+0" + +[[deps.p7zip_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" +version = "17.4.0+2" + +[[deps.x264_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "14cc7083fc6dff3cc44f2bc435ee96d06ed79aa7" +uuid = "1270edf5-f2f9-52d2-97e9-ab00b5d0237a" +version = "10164.0.1+0" + +[[deps.x265_jll]] +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "e7b67590c14d487e734dcb925924c5dc43ec85f3" +uuid = "dfaa095f-4041-5dcd-9319-2fabd8486b76" +version = "4.1.0+0" diff --git a/dev/Project.toml b/projects/Project.toml similarity index 100% rename from dev/Project.toml rename to projects/Project.toml diff --git a/dev/doubleMM.jl b/projects/doubleMM.jl similarity index 99% rename from dev/doubleMM.jl rename to projects/doubleMM.jl index 428a7eb..2c7c094 100644 --- a/dev/doubleMM.jl +++ b/projects/doubleMM.jl @@ -44,7 +44,7 @@ train_dataloader = MLUtils.DataLoader( σ_o = exp.(y_unc[:, 1] / 2) # assign the train_loader, otherwise it each time creates another version of synthetic data prob0 = HybridProblem(prob0_; train_dataloader) -#tmp = HVI.get_hybridproblem_ϕunc(prob0; scenario) +#tmp = HVI.get_hybridproblem_ϕq(prob0; scenario) #prob0.covar #------- pointwise hybrid model fit @@ -184,11 +184,11 @@ end #----------- HVI without strong prior on θmean #prob2 = HybridProblem(prob1o); # copy prob2 = HybridProblem(prob0o); # copy -function fstate_ϕunc(state) +function fstate_ϕq(state) u = state.u |> cpu #Main.@infiltrate_main - uc = interpreters.μP_ϕg_unc(u) - uc.unc.ρsM + uc = interpreters.ϕg_ϕq(u) + uc.ϕq.ρsM end n_epoch = 100 #n_epoch = 400 @@ -197,7 +197,7 @@ n_epoch = 100 HybridProblem(solver_post, n_MC = 12); #HybridProblem(solver_post, n_MC = 30); scenario, rng, maxiters = n_batches_in_epoch * n_epoch, - #callback = HVI.callback_loss_fstate(n_batches_in_epoch*5, fstate_ϕunc), + #callback = HVI.callback_loss_fstate(n_batches_in_epoch*5, fstate_ϕq), callback = callback_loss(n_batches_in_epoch * 5), ); prob2o = probo; @@ -270,9 +270,9 @@ end g_flux = g_luxs end -ζ_VIc = interpreters.μP_ϕg_unc(resopt.u |> Flux.cpu) +ζ_VIc = interpreters.ϕg_ϕq(resopt.u |> Flux.cpu) #ζMs_VI = g_flux(xM_gpu, ζ_VIc.ϕg |> Flux.gpu) |> Flux.cpu -ϕunc_VI = interpreters.unc(ζ_VIc.unc) +ϕunc_VI = interpreters.ϕq(ζ_VIc.ϕq) ϕunc_VI.ρsM exp.(ϕunc_VI.logσ2_ζP) exp.(ϕunc_VI.coef_logσ2_ζMs[1, :]) @@ -323,7 +323,7 @@ histogram(θsP) # (; ϕ, θP, resopt, interpreters) = solve(prob1o, solver_MC; scenario, # rng, callback = callback_loss(n_batches_in_epoch), maxiters = 14); # resopt.objective - # probo = prob3o = HybridProblem(prob2; ϕg = cpu_ca(ϕ).ϕg, θP = θP, ϕunc = cpu_ca(ϕ).unc) + # probo = prob3o = HybridProblem(prob2; ϕg = cpu_ca(ϕ).ϕg, θP = θP, ϕq = cpu_ca(ϕ).ϕq) solver_post2 = HybridPosteriorSolver(solver_post; n_MC = 30) #solver_post2 = HybridPosteriorSolver(solver_post; n_MC = 3) @@ -500,7 +500,7 @@ model = fsites(y_o; f = prob0.f_allsites, n_θP, n_θM, σ_o) # setup transformers and interpreters for forward prediction cor_ends = get_hybridproblem_cor_ends(prob; scenario) g, ϕg0 = get_hybridproblem_MLapplicator(prob; scenario) -ϕunc0 = get_hybridproblem_ϕunc(prob; scenario) +ϕunc0 = get_hybridproblem_ϕq(prob; scenario) (; transP, transM) = get_hybridproblem_transforms(prob; scenario) hpints = HybridProblemInterpreters(prob; scenario) (; ϕ, transPMs_batch, interpreters, get_transPMs, get_ca_int_PMs) = HVI.init_hybrid_params( diff --git a/dev/elbo.pdf b/projects/elbo.pdf similarity index 100% rename from dev/elbo.pdf rename to projects/elbo.pdf diff --git a/dev/elbo_boxplot.pdf b/projects/elbo_boxplot.pdf similarity index 100% rename from dev/elbo_boxplot.pdf rename to projects/elbo_boxplot.pdf diff --git a/projects/intermediate/doubleMM_chain_theta.jld2 b/projects/intermediate/doubleMM_chain_theta.jld2 new file mode 100644 index 0000000..e6b1ae6 Binary files /dev/null and b/projects/intermediate/doubleMM_chain_theta.jld2 differ diff --git a/projects/intermediate/doubleMM_chain_zeta.jld2 b/projects/intermediate/doubleMM_chain_zeta.jld2 new file mode 100644 index 0000000..cb2dea3 Binary files /dev/null and b/projects/intermediate/doubleMM_chain_zeta.jld2 differ diff --git a/projects/intermediate/doubleMM_chain_zeta_K1global.jld2 b/projects/intermediate/doubleMM_chain_zeta_K1global.jld2 new file mode 100644 index 0000000..e5c4e1b Binary files /dev/null and b/projects/intermediate/doubleMM_chain_zeta_K1global.jld2 differ diff --git a/projects/intermediate/doubleMM_chain_zeta_covarK2.jld2 b/projects/intermediate/doubleMM_chain_zeta_covarK2.jld2 new file mode 100644 index 0000000..cb2dea3 Binary files /dev/null and b/projects/intermediate/doubleMM_chain_zeta_covarK2.jld2 differ diff --git a/projects/intermediate/presentation/compare_hmc_hvi_sdMs_covarK2.png b/projects/intermediate/presentation/compare_hmc_hvi_sdMs_covarK2.png new file mode 100644 index 0000000..21a85ff Binary files /dev/null and b/projects/intermediate/presentation/compare_hmc_hvi_sdMs_covarK2.png differ diff --git a/projects/intermediate/presentation/compare_hmc_hvi_sites_covarK2.png b/projects/intermediate/presentation/compare_hmc_hvi_sites_covarK2.png new file mode 100644 index 0000000..c406ef4 Binary files /dev/null and b/projects/intermediate/presentation/compare_hmc_hvi_sites_covarK2.png differ diff --git a/projects/intermediate/presentation/compare_hmc_hvi_sites_y_covarK2.png b/projects/intermediate/presentation/compare_hmc_hvi_sites_y_covarK2.png new file mode 100644 index 0000000..e07dbe0 Binary files /dev/null and b/projects/intermediate/presentation/compare_hmc_hvi_sites_y_covarK2.png differ diff --git a/projects/intermediate/presentation/compare_hmc_hvi_sites_y_covarK2_bak.png b/projects/intermediate/presentation/compare_hmc_hvi_sites_y_covarK2_bak.png new file mode 100644 index 0000000..c427568 Binary files /dev/null and b/projects/intermediate/presentation/compare_hmc_hvi_sites_y_covarK2_bak.png differ diff --git a/projects/intermediate/presentation/compare_hmc_neglectcor_sites_covarK2.png b/projects/intermediate/presentation/compare_hmc_neglectcor_sites_covarK2.png new file mode 100644 index 0000000..64d6030 Binary files /dev/null and b/projects/intermediate/presentation/compare_hmc_neglectcor_sites_covarK2.png differ diff --git a/projects/intermediate/presentation/compare_hvi_indep_sites_covarK2.png b/projects/intermediate/presentation/compare_hvi_indep_sites_covarK2.png new file mode 100644 index 0000000..df64d5c Binary files /dev/null and b/projects/intermediate/presentation/compare_hvi_indep_sites_covarK2.png differ diff --git a/projects/intermediate/presentation/cor_hmc_K1global_covarK2.png b/projects/intermediate/presentation/cor_hmc_K1global_covarK2.png new file mode 100644 index 0000000..c106c65 Binary files /dev/null and b/projects/intermediate/presentation/cor_hmc_K1global_covarK2.png differ diff --git a/projects/intermediate/presentation/cor_hmc_covarK2.png b/projects/intermediate/presentation/cor_hmc_covarK2.png new file mode 100644 index 0000000..0947667 Binary files /dev/null and b/projects/intermediate/presentation/cor_hmc_covarK2.png differ diff --git a/projects/intermediate/presentation/cor_hvi_K1global_covarK2.png b/projects/intermediate/presentation/cor_hvi_K1global_covarK2.png new file mode 100644 index 0000000..b5f1c0b Binary files /dev/null and b/projects/intermediate/presentation/cor_hvi_K1global_covarK2.png differ diff --git a/projects/intermediate/presentation/cor_hvi_covarK2.png b/projects/intermediate/presentation/cor_hvi_covarK2.png new file mode 100644 index 0000000..32f4472 Binary files /dev/null and b/projects/intermediate/presentation/cor_hvi_covarK2.png differ diff --git a/projects/intermediate/presentation/cor_hvi_neglect_cor_covarK2.png b/projects/intermediate/presentation/cor_hvi_neglect_cor_covarK2.png new file mode 100644 index 0000000..086b00d Binary files /dev/null and b/projects/intermediate/presentation/cor_hvi_neglect_cor_covarK2.png differ diff --git a/projects/intermediate/probos.jld2 b/projects/intermediate/probos.jld2 new file mode 100644 index 0000000..62a13c1 Binary files /dev/null and b/projects/intermediate/probos.jld2 differ diff --git a/projects/intermediate/probos800_K1global.jld2 b/projects/intermediate/probos800_K1global.jld2 new file mode 100644 index 0000000..e2b7697 Binary files /dev/null and b/projects/intermediate/probos800_K1global.jld2 differ diff --git a/projects/intermediate/probos800_covarK2.jld2 b/projects/intermediate/probos800_covarK2.jld2 new file mode 100644 index 0000000..ef7e471 Binary files /dev/null and b/projects/intermediate/probos800_covarK2.jld2 differ diff --git a/projects/intermediate/probos800_covarK2_before250510.jld2 b/projects/intermediate/probos800_covarK2_before250510.jld2 new file mode 100644 index 0000000..d03d8d1 Binary files /dev/null and b/projects/intermediate/probos800_covarK2_before250510.jld2 differ diff --git a/projects/intermediate/probos800_neglect_cor.jld2 b/projects/intermediate/probos800_neglect_cor.jld2 new file mode 100644 index 0000000..23ee680 Binary files /dev/null and b/projects/intermediate/probos800_neglect_cor.jld2 differ diff --git a/projects/intermediate/probos800_omit_r0.jld2 b/projects/intermediate/probos800_omit_r0.jld2 new file mode 100644 index 0000000..52cbc35 Binary files /dev/null and b/projects/intermediate/probos800_omit_r0.jld2 differ diff --git a/projects/intermediate/probos_covarK2.jld2 b/projects/intermediate/probos_covarK2.jld2 new file mode 100644 index 0000000..7d9f7a7 Binary files /dev/null and b/projects/intermediate/probos_covarK2.jld2 differ diff --git a/projects/issue_allowscalar_Zygote.jl b/projects/issue_allowscalar_Zygote.jl new file mode 100644 index 0000000..608617d --- /dev/null +++ b/projects/issue_allowscalar_Zygote.jl @@ -0,0 +1,21 @@ +using UnPack, +using CUDA, cuDNN, MLDataDevices, GPUArraysCore +using ComponentArrays: ComponentArrays as CA +using Zygote + +tmp = gpu_device()(CA.ComponentVector(a=1, b=2:5)); + +tmpf = function(tmp) + GPUArraysCore.allowscalar() do + #a = tmp.a + a = tmp[Val(:a)] + #a = (UnPack).unpack(tmp, Val{:a}()) + #@macroexpand @unpack a,b = tmp + #@unpack a,b = tmp + #return(a) + end +end + +tmpf(tmp) +Zygote.gradient(tmpf, tmp) # triggers Scalar exception + diff --git a/dev/mwe_bijectors_gpu_elementwise.jl b/projects/mwe_bijectors_gpu_elementwise.jl similarity index 100% rename from dev/mwe_bijectors_gpu_elementwise.jl rename to projects/mwe_bijectors_gpu_elementwise.jl diff --git a/src/AbstractHybridProblem.jl b/src/AbstractHybridProblem.jl index 6c3b499..f7cc0d1 100644 --- a/src/AbstractHybridProblem.jl +++ b/src/AbstractHybridProblem.jl @@ -8,7 +8,7 @@ For a specific prob, provide functions that specify details - `get_hybridproblem_PBmodel` - `get_hybridproblem_neg_logden_obs` - `get_hybridproblem_par_templates` -- `get_hybridproblem_ϕunc` +- `get_hybridproblem_ϕq` - `get_hybridproblem_train_dataloader` (may use `construct_dataloader_from_synthetic`) - `get_hybridproblem_priors` - `get_hybridproblem_n_covar` @@ -24,7 +24,7 @@ optionally The initial value of parameters to estimate is spread - `ϕg`: parameter of the MLapplicator: returned by `get_hybridproblem_MLapplicator` - `ζP`: mean of the PBmodel parameters: returned by `get_hybridproblem_par_templates` -- `ϕunc`: additional parameters of the approximte posterior: returned by `get_hybridproblem_ϕunc` +- `ϕq`: additional parameters of the approximte posterior: returned by `get_hybridproblem_ϕq` """ abstract type AbstractHybridProblem end; @@ -77,17 +77,32 @@ Provide tuple of templates of ComponentVectors `θP` and `θM`. function get_hybridproblem_par_templates end """ - get_hybridproblem_ϕunc(::AbstractHybridProblem; scenario) + get_hybridproblem_ϕq(::AbstractHybridProblem; scenario) -Provide a ComponentArray of the initial additional parameters of the approximate posterior. -Defaults to zero correlation and log_σ2 of 1e-10. +Provide a ComponentArray of the non-ML parameters. Usually those +contain the means of the unconstrained scale population parameters, μP. """ -function get_hybridproblem_ϕunc(prob::AbstractHybridProblem; scenario) - FT = get_hybridproblem_float_type(prob; scenario) - cor_ends = get_hybridproblem_cor_ends(prob; scenario) - init_hybrid_ϕunc(cor_ends, zero(FT)) +function get_hybridproblem_ϕq(prob::AbstractHybridProblem; scenario) end + +""" + get_hybridproblem_θP(::AbstractHybridProblem; scenario) + +Provide current expectations of population level PBM parameters on +constrained original scale. +Defaults to inverse-transform of `ϕq.μP`. +""" +function get_hybridproblem_θP(prob::AbstractHybridProblem; scenario = Val(())) + ϕq = get_hybridproblem_ϕq(prob; scenario) + transP = get_hybridproblem_transforms(prob; scenario).transP + μP = ϕq[Val(:μP)]; + θP = if isempty(μP) + CA.ComponentVector{eltype(ϕq)}() + else + apply_preserve_axes(transP, μP) + end end + """ get_hybridproblem_transforms(::AbstractHybridProblem; scenario) @@ -183,7 +198,7 @@ function construct_dataloader_from_synthetic(rng::AbstractRNG, prob::AbstractHyb @assert size(y_o,2) == n_site @assert size(y_unc,2) == n_site i_sites = 1:n_site - train_loader = MLUtils.DataLoader((xM, xP, y_o, y_unc, i_sites); + train_loader = MLUtils.DataLoader((CA.getdata(xM), CA.getdata(xP), y_o, y_unc, i_sites); batchsize = n_batch, partial = false) return (train_loader) end @@ -260,7 +275,7 @@ end get_hybridproblem_priors(::AbstractHybridProblem; scenario) Return a dictionary of marginal prior distributions for components in `θP` and `θM`. -Defaults for each component `θ` to `Normal(θ, max(θ, 1.0))`. +Defaults for each component `θ` to `Normal(θ, max(θ, 1.0))` from parameter templates. """ function get_hybridproblem_priors(prob::AbstractHybridProblem; scenario = ()) pt = get_hybridproblem_par_templates(prob; scenario) diff --git a/src/ComponentArrayInterpreter.jl b/src/ComponentArrayInterpreter.jl index d73a972..5a33dda 100644 --- a/src/ComponentArrayInterpreter.jl +++ b/src/ComponentArrayInterpreter.jl @@ -181,9 +181,9 @@ function ComponentArrayInterpreter( n_dims::NTuple{N,<:Integer}, axes::NTuple{A,<:CA.AbstractAxis}, m_dims::NTuple{M,<:Integer}) where {N,A,M} axes_ext = ( - map(n_dim -> CA.Axis(i=1:n_dim), n_dims)..., + map(n_dim -> CA.Shaped1DAxis((n_dim,)), n_dims)..., axes..., - map(n_dim -> CA.Axis(i=1:n_dim), m_dims)...) + map(n_dim -> CA.Shaped1DAxis((n_dim,)), m_dims)...) ComponentArrayInterpreter(axes_ext) end @@ -202,7 +202,7 @@ function stack_ca_int( end function StaticComponentArrayInterpreter( axes::NTuple{A,<:CA.AbstractAxis}, n_dims::NTuple{N,<:Integer}) where {A,N} - axes_ext = (axes..., map(n_dim -> CA.Axis(i=1:n_dim), n_dims)...) + axes_ext = (axes..., map(n_dim -> CA.Shaped1DAxis((n_dim,)), n_dims)...) StaticComponentArrayInterpreter{axes_ext}() end @@ -214,7 +214,7 @@ function stack_ca_int( end function StaticComponentArrayInterpreter( n_dims::NTuple{N,<:Integer}, axes::NTuple{M,<:CA.AbstractAxis}) where {N,M} - axes_ext = (map(n_dim -> CA.Axis(i=1:n_dim), n_dims)..., axes...) + axes_ext = (map(n_dim -> CA.Shaped1DAxis((n_dim,)), n_dims)..., axes...) StaticComponentArrayInterpreter{axes_ext}() end @@ -248,6 +248,7 @@ _get_ComponentArrayInterpreter_axes(cai::ComponentArrayInterpreter) = cai.axes _axis_length(ax::CA.AbstractAxis) = lastindex(ax) - firstindex(ax) + 1 _axis_length(::CA.FlatAxis) = 0 _axis_length(::CA.UnitRange) = 0 +_axis_length(ax::CA.Shaped1DAxis) = length(ax) """ flatten1(cv::CA.ComponentVector) @@ -286,24 +287,25 @@ function get_positions(cai::AbstractComponentArrayInterpreter) keys_cv isa Tuple ? NamedTuple{keys_cv}(map(k -> CA.getdata(cv[k]), keys_cv)) : CA.getdata(cv) end -function tmpf(v; +# used in test_ComponentArrayInterpreter +function test_apply_cai(v; cv, cai::AbstractComponentArrayInterpreter=get_concrete(ComponentArrayInterpreter(cv))) cai(v) end -function tmpf1(v; cai) +function test_apply_cai1(v; cai) caic = get_concrete(cai) #caic(v) - Test.@inferred tmpf(v, cv=nothing, cai=caic) + Test.@inferred test_apply_cai(v, cv=nothing, cai=caic) end -function tmpf2(v; cai::AbstractComponentArrayInterpreter) +function test_apply_cai2(v; cai::AbstractComponentArrayInterpreter) caic = get_concrete(cai) #caic = cai cv = Test.@inferred caic(v) # inferred inside tmpf2 #cv = caic(v) # inferred inside tmpf2 - vv = tmpf(v; cv=nothing, cai=caic) + vv = test_apply_cai(v; cv=nothing, cai=caic) #vv = tmpf(v; cv) #cv.x #sum(cv) # not inferred on Union cv (axis not know) diff --git a/src/DoubleMM/DoubleMM.jl b/src/DoubleMM/DoubleMM.jl index 95a0757..5f14710 100644 --- a/src/DoubleMM/DoubleMM.jl +++ b/src/DoubleMM/DoubleMM.jl @@ -16,6 +16,9 @@ import StableRNGs import MLUtils import ChainRulesCore +using UnPack # @unpack used inside PBM + + export f_doubleMM, f_doubleMM_sites, xP_S1, xP_S2 include("f_doubleMM.jl") diff --git a/src/DoubleMM/f_doubleMM.jl b/src/DoubleMM/f_doubleMM.jl index a349731..f950ebb 100644 --- a/src/DoubleMM/f_doubleMM.jl +++ b/src/DoubleMM/f_doubleMM.jl @@ -50,10 +50,11 @@ function f_doubleMM(θc::CA.ComponentVector{ET}, x) where ET #θc = intθ1(θ) #using ComponentArrays: ComponentArrays as CA #r0, r1, K1, K2 = θc[(:r0, :r1, :K1, :K2)] # does not work on Zygote+GPU - (r0, r1, K1, K2) = map((:r0, :r1, :K1, :K2)) do par - # vector will be repeated when broadcasted by a matrix - CA.getdata(θc[par])::ET - end + # (r0, r1, K1, K2) = map((:r0, :r1, :K1, :K2)) do par + # # vector will be repeated when broadcasted by a matrix + # CA.getdata(θc[par])::ET + # end + @unpack r0, r1, K1, K2 = θc # r0 = θc[:r0] # r1 = θc[:r1] # K1 = θc[:K1] @@ -99,26 +100,39 @@ end """ function f_doubleMM_sites(θc::CA.ComponentMatrix, xPc::CA.ComponentMatrix) # extract several covariates from xP - ST = typeof(CA.getdata(xPc)[1:1,:]) # workaround for non-type-stable Symbol-indexing - S1 = (CA.getdata(xPc[:S1,:])::ST) - S2 = (CA.getdata(xPc[:S2,:])::ST) + # ST = typeof(CA.getdata(xPc)[1:1,:]) # workaround for non-type-stable Symbol-indexing + # S1 = (CA.getdata(xPc[:S1,:])::ST) + # S2 = (CA.getdata(xPc[:S2,:])::ST) + S1 = view(xPc, Val(:S1), :) + S2 = view(xPc, Val(:S2), :) + + # S1 = @view CA.getdata(xPc[Val(:S1),:]) + # S2 = @view CA.getdata(xPc[Val(:S2),:]) + is_valid = isfinite.(S1) .&& isfinite.(S2) # # extract the parameters as vectors that are row-repeated into a matrix - VT = typeof(CA.getdata(θc)[:,1]) # workaround for non-type-stable Symbol-indexing - #n_obs = size(S1, 1) - #rep_fac = HVI.ones_similar_x(xPc, n_obs) # to reshape into matrix, avoiding repeat - #is_dummy = isnan.(S1) .|| isnan.(S2) - is_valid = isfinite.(S1) .&& isfinite.(S2) - (r0, r1, K1, K2) = map((:r0, :r1, :K1, :K2)) do par - p1 = CA.getdata(θc[:, par]) ::VT - #Main.@infiltrate_main - # tmp = Zygote.gradient(p1 -> sum(repeat_rowvector_dummy(p1', is_dummy)), p1)[1] - #p1_mat = repeat_rowvector_dummy(p1', is_dummy) - p1_mat = is_valid .* p1' # places zeros in dummy positions, prevents gradients there - #repeat(p1', n_obs) # matrix: same for each concentration row in S1 - #(rep_fac .* p1') # move to computation below to save allocation - end + # VT = typeof(CA.getdata(θc)[:,1]) # workaround for non-type-stable Symbol-indexing + # #n_obs = size(S1, 1) + # #rep_fac = HVI.ones_similar_x(xPc, n_obs) # to reshape into matrix, avoiding repeat + # #is_dummy = isnan.(S1) .|| isnan.(S2) + + # (r0, r1, K1, K2) = map((:r0, :r1, :K1, :K2)) do par + # p1 = CA.getdata(θc[:, par]) ::VT + # #Main.@infiltrate_main + # # tmp = Zygote.gradient(p1 -> sum(repeat_rowvector_dummy(p1', is_dummy)), p1)[1] + # #p1_mat = repeat_rowvector_dummy(p1', is_dummy) + # p1_mat = is_valid .* p1' # places zeros in dummy positions, prevents gradients there + # #repeat(p1', n_obs) # matrix: same for each concentration row in S1 + # #(rep_fac .* p1') # move to computation below to save allocation + # end + # + r0 = is_valid .* CA.getdata(θc[:, Val(:r0)])' + r1 = is_valid .* CA.getdata(θc[:, Val(:r1)])' + K1 = is_valid .* CA.getdata(θc[:, Val(:K1)])' + K2 = is_valid .* CA.getdata(θc[:, Val(:K2)])' # + #, r1, K1, K2) = map((:r0, :r1, :K1, :K2)) do par + # each variable is a matrix (n_obs x n_site) r0 .+ r1 .* S1 ./ (K1 .+ S1) .* S2 ./ (K2 .+ S2) #(rep_fac .* r0') .+ (rep_fac .* r1') .* S1 ./ ((rep_fac .* K1') .+ S1) .* S2 ./ ((rep_fac .* K2') .+ S2) @@ -236,10 +250,9 @@ function HVI.get_hybridproblem_MLapplicator( # construct normal distribution from quantiles at unconstrained scale priors_dict = get_hybridproblem_priors(prob; scenario) (; θM) = get_hybridproblem_par_templates(prob; scenario) - priors = [priors_dict[k] for k in keys(θM)] + priors = Tuple(priors_dict[k] for k in keys(θM)) (; transM) = get_hybridproblem_transforms(prob; scenario) - lowers, uppers = HVI.get_quantile_transformed( - priors::AbstractVector{<:Distribution}, transM) + lowers, uppers = HVI.get_quantile_transformed(priors, transM) #n_site, n_batch = get_hybridproblem_n_site_and_batch(prob; scenario) g = if (:use_rangescaling ∈ scen) RangeScalingModelApplicator(g_nomag, lowers, uppers, eltype(ϕ_g0)) @@ -370,7 +383,7 @@ function HVI.get_hybridproblem_train_dataloader(prob::DoubleMMCase; scenario::Va # set the last two entries of the S1 drivers and observations of the second site NaN view(@view(xP[:S1,2]), 7:8) .= NaN y_o[7:8,2] .= NaN - train_loader = MLUtils.DataLoader((xM, xP, y_o, y_unc, i_sites); + train_loader = MLUtils.DataLoader((CA.getdata(xM), CA.getdata(xP), y_o, y_unc, i_sites); batchsize = n_batch, partial = false) else construct_dataloader_from_synthetic(rng, prob; scenario, n_batch, kwargs...) @@ -384,8 +397,6 @@ function HVI.gen_hybridproblem_synthetic(rng::AbstractRNG, prob::DoubleMMCase; n_covar = get_hybridproblem_n_covar(prob; scenario) n_θM = length(θM) FloatType = get_hybridproblem_float_type(prob; scenario) - par_templates = get_hybridproblem_par_templates(prob; scenario) - #XXTODO transform θMs_true xM, θMs_true0 = gen_cov_pred(rng, FloatType, n_covar_pc, n_covar, n_site, n_θM; rhodec = 8, is_using_dropout = false) int_θMs_sites = ComponentArrayInterpreter(θM, (n_site,)) @@ -397,7 +408,8 @@ function HVI.gen_hybridproblem_synthetic(rng::AbstractRNG, prob::DoubleMMCase; int_xP_sites = ComponentArrayInterpreter(int_xP1, (n_site,)) xP = int_xP_sites(vcat(repeat(xP_S1, 1, n_site), repeat(xP_S2, 1, n_site))) #xP[:S1,:] - θP = par_templates.θP + #θP = get_θP(prob) # for DoubleMMCase par_templates gives correct θP + θP = get_hybridproblem_θP(prob; scenario) y_true = f(θP, θMs_true', xP) σ_o = FloatType(0.01) #σ_o = FloatType(0.002) @@ -426,4 +438,15 @@ function HVI.get_hybridproblem_cor_ends(prob::DoubleMMCase; scenario::Val{scen}) end end +function HVI.get_hybridproblem_ϕq(prob::DoubleMMCase; scenario) + FT = get_hybridproblem_float_type(prob; scenario) + cor_ends = get_hybridproblem_cor_ends(prob; scenario) + ϕunc = init_hybrid_ϕunc(MeanHVIApproximationMat(), cor_ends, zero(FT)) + # for DoubleMMCase templates gives the correct values + θP = get_hybridproblem_par_templates(prob; scenario).θP + transP = get_hybridproblem_transforms(prob; scenario).transP + ϕq = HVI.update_μP_by_θP(ϕunc, θP, transP) +end + + diff --git a/src/HVIApproximation.jl b/src/HVIApproximation.jl new file mode 100644 index 0000000..7a6e45a --- /dev/null +++ b/src/HVIApproximation.jl @@ -0,0 +1,20 @@ +""" + AbstractHVIApproximation + +Provides a type hierarchy to distinguish different forms and +parameterizations of posterior approximations. +""" +abstract type AbstractHVIApproximation end + +abstract type AbstractMeanHVIApproximation <: AbstractHVIApproximation end + +# First implementation with one big sparse covariance matrix +struct MeanHVIApproximationMat <: AbstractMeanHVIApproximation end + +# Reimplementation with generating random numbers for each block separately +struct MeanHVIApproximation <: AbstractMeanHVIApproximation end + +# for benchmarking changes, before implementing them +struct MeanHVIApproximationDev <: AbstractMeanHVIApproximation end + + diff --git a/src/HybridProblem.jl b/src/HybridProblem.jl index 97cc62d..91c0a19 100644 --- a/src/HybridProblem.jl +++ b/src/HybridProblem.jl @@ -5,7 +5,7 @@ one struct. Fields: - `θP::ComponentVector`, `θM::ComponentVector`: parameter templates - `g::AbstractModelApplicator`, `ϕg::AbstractVector`: ML model and its parameters -- `ϕunc::ComponentVector`: parameters for the Covariance matrix of the approximate posterior +- `ϕq::ComponentVector`: parameters for the Covariance matrix of the approximate posterior - `f_batch`: Process-based model predicting for n_batch sites - `priors`: AbstractDict: Prior distributions for all PBM parameters on constrained scale - `py`: Likelihood function @@ -23,12 +23,12 @@ Fields: """ struct HybridProblem <: AbstractHybridProblem - θP::CA.ComponentVector + #θP::CA.ComponentVector θM::CA.ComponentVector f_batch::Any g::AbstractModelApplicator ϕg::Any # depends on framework - ϕunc::CA.ComponentVector + ϕq::CA.ComponentVector priors::AbstractDict py::Any # any callable transM::Stacked @@ -39,10 +39,13 @@ struct HybridProblem <: AbstractHybridProblem n_site::Int n_batch::Int pbm_covars::NTuple{_N, Symbol} where _N + approx::AbstractHVIApproximation #inner constructor to constrain the types function HybridProblem( - θP::CA.ComponentVector, θM::CA.ComponentVector, - g::AbstractModelApplicator, ϕg::AbstractVector, + θM::CA.ComponentVector, + ϕq::CA.ComponentVector, # = init_hybrid_ϕunc(approx, cor_ends, zero(eltype(θM))), + g::AbstractModelApplicator, + ϕg::AbstractVector, f_batch, priors::AbstractDict, py, @@ -53,24 +56,42 @@ struct HybridProblem <: AbstractHybridProblem n_covar::Int, n_site::Int, n_batch::Int, - cor_ends::NamedTuple = (P = [length(θP)], M = [length(θM)]), + cor_ends::NamedTuple = (P = [length(ϕq[Val(:μP)])], M = [length(θM)]), pbm_covars::NTuple{N,Symbol} = (), - ϕunc::CA.ComponentVector = init_hybrid_ϕunc(cor_ends, zero(eltype(θM))), + approx::AbstractHVIApproximation = MeanHVIApproximationMat() ) where N new( - θP, θM, f_batch, g, ϕg, ϕunc, priors, py, transM, transP, cor_ends, - train_dataloader, n_covar, n_site, n_batch, pbm_covars) + θM, f_batch, g, ϕg, ϕq, priors, py, transM, transP, cor_ends, + train_dataloader, n_covar, n_site, n_batch, pbm_covars, approx) end end -# function HybridProblem(θP::CA.ComponentVector, θM::CA.ComponentVector, -# # note no ϕg argument and g_chain unconstrained -# g_chain, f_batch, -# args...; rng = Random.default_rng(), kwargs...) -# # dispatches on type of g_chain -# g, ϕg = construct_ChainsApplicator(rng, g_chain, eltype(θM)) -# HybridProblem(θP, θM, g, ϕg, f_batch, args...; kwargs...) -# end +""" + init_hybrid_ϕq(θP, θM, transP; cor_ends) + +Initialize the non-ML parameter vector. +""" +function init_hybrid_ϕq( + approx::AbstractMeanHVIApproximation, + θP::CA.ComponentVector, + θM::CA.ComponentVector, + transP::Stacked, + cor_ends::NamedTuple = (P = [length(θP)], M = [length(θM)]), +) + FT = promote_type(eltype(θP), eltype(θM)) + ϕunc0 = init_hybrid_ϕunc(approx, cor_ends, zero(FT)) + ϕq = update_μP_by_θP(ϕunc0, θP, transP) +end + +""" + create_ϕq(θP, ϕunc, transP::Stacked) + +Add information on μP to ϕunc. +""" +function update_μP_by_θP(ϕq::CA.ComponentVector, θP::CA.ComponentVector, transP::Stacked) + μP = inverse(transP)(θP) + ϕq = CA.ComponentVector(ϕq; μP) +end """ HybridProblem(prob::AbstractHybridProblem; scenario = () @@ -78,8 +99,10 @@ end Gather all information from another `AbstractHybridProblem` with possible updating of some of the entries. """ -function HybridProblem(prob::AbstractHybridProblem; scenario = (), - θP = get_hybridproblem_par_templates(prob; scenario).θP, +function HybridProblem(prob::AbstractHybridProblem; scenario = Val(()), kwargs...) + update_hybridProblem(prob; scenario, kwargs...) +end +function update_hybridProblem(prob::AbstractHybridProblem; scenario, θM = get_hybridproblem_par_templates(prob; scenario).θM, g = get_hybridproblem_MLapplicator(prob; scenario)[1], ϕg = get_hybridproblem_MLapplicator(prob; scenario)[2], @@ -92,14 +115,36 @@ function HybridProblem(prob::AbstractHybridProblem; scenario = (), n_covar = get_hybridproblem_n_covar(prob; scenario), n_site = get_hybridproblem_n_site_and_batch(prob; scenario)[1], n_batch = get_hybridproblem_n_site_and_batch(prob; scenario)[2], - cor_ends = get_hybridproblem_cor_ends(prob; scenario), + cor_ends = nothing, pbm_covars = get_hybridproblem_pbmpar_covars(prob; scenario), - ϕunc = get_hybridproblem_ϕunc(prob; scenario), + ϕq = get_hybridproblem_ϕq(prob; scenario), + θP = nothing, + ϕunc = nothing, + approx::AbstractHVIApproximation = MeanHVIApproximationMat(), ) - HybridProblem(θP, θM, g, ϕg, f_batch, priors, py, transM, transP, train_dataloader, - n_covar, n_site, n_batch, cor_ends, pbm_covars, ϕunc) + cor_ends_new = if !isnothing(cor_ends) + # if new cor_ends was specified then re-initialize the ρsP and ρsM in ϕq + ϕunc0 = init_hybrid_ϕunc(approx, cor_ends, zero(eltype(ϕq))) + ϕq = CA.ComponentVector(;ϕq..., ρsP = ϕunc0.ρsP, ρsM = ϕunc0.ρsM) + cor_ends + else + get_hybridproblem_cor_ends(prob; scenario) + end + if !isnothing(θP) + ϕq = update_μP_by_θP(ϕq, θP, transP) + end + if !isnothing(ϕunc) + ϕq = CA.ComponentVector(ϕq; ϕunc...) + end + HybridProblem(θM, ϕq, g, ϕg, f_batch, priors, py, transM, transP, train_dataloader, + n_covar, n_site, n_batch, cor_ends_new, pbm_covars, approx) end +function HybridProblem(prob::HybridProblem; kwargs... ) + update_hybridProblem(prob; scenario = Val(()), kwargs..., approx = prob.approx) +end + + # """ # update(prob::HybridProblem; ...) @@ -110,7 +155,7 @@ end # θM::CA.ComponentVector = prob.θM, # g::AbstractModelApplicator = prob.g, # ϕg::AbstractVector = prob.ϕg, -# ϕunc::CA.ComponentVector = prob.ϕunc, +# ϕq::CA.ComponentVector = prob.ϕq, # f_batch = prob.f_batch, # f_allsites = prob.f_allsites, # priors::AbstractDict = prob.priors, @@ -126,16 +171,17 @@ end # n_site::Integer = prob.n_site, # n_batch::Integer = prob.n_batch, # ) where N -# HybridProblem(θP, θM, g, ϕg, f_batch, f_allsites, priors, py, transM, transP, -# train_dataloader, n_covar, n_site, n_batch, cor_ends, pbm_covars, ϕunc) +# HybridProblem(θM, ϕq, g, ϕg, f_batch, f_allsites, priors, py, transM, transP, +# train_dataloader, n_covar, n_site, n_batch, cor_ends, pbm_covars) # end function get_hybridproblem_par_templates(prob::HybridProblem; scenario = ()) - (; θP = prob.θP, θM = prob.θM) + θP = get_hybridproblem_θP(prob; scenario) + (; θP, θM = prob.θM) end -function get_hybridproblem_ϕunc(prob::HybridProblem; scenario = ()) - prob.ϕunc +function get_hybridproblem_ϕq(prob::HybridProblem; scenario = ()) + prob.ϕq end function get_hybridproblem_neg_logden_obs(prob::HybridProblem; scenario = ()) @@ -181,6 +227,7 @@ function get_hybridproblem_priors(prob::HybridProblem; scenario = ()) prob.priors end + # function get_hybridproblem_float_type(prob::HybridProblem; scenario = ()) # eltype(prob.θM) # end @@ -191,7 +238,7 @@ Get the inverse-transformation of lower and upper quantiles of a Vector of Distr This can be used to get proper confidence intervals at unconstrained (log) ζ-scale for priors on normal θ-scale for constructing a NormalScalingModelApplicator. """ -function get_quantile_transformed(priors::AbstractVector{<:Distribution}, trans; +function get_quantile_transformed(priors::Tuple, trans; q95 = (0.05, 0.95)) θq = ([quantile(d, q) for d in priors] for q in q95) lowers, uppers = inverse(trans).(θq) diff --git a/src/HybridSolver.jl b/src/HybridSolver.jl index 36a3751..aee018f 100644 --- a/src/HybridSolver.jl +++ b/src/HybridSolver.jl @@ -13,18 +13,19 @@ function CommonSolve.solve(prob::AbstractHybridProblem, solver::HybridPointSolve ad_backend_loss = AutoZygote(), epochs, is_omitting_NaNbatches = false, - is_omit_priors = false, + is_omit_priors::Val{omit_priors} = Val(false), kwargs... -) where is_infer +) where {is_infer, omit_priors} gdevs = isnothing(gdevs) ? get_gdev_MP(scenario) : gdevs - par_templates = get_hybridproblem_par_templates(prob; scenario) + pt = get_hybridproblem_par_templates(prob; scenario) g, ϕg0 = get_hybridproblem_MLapplicator(prob; scenario) FT = get_hybridproblem_float_type(prob; scenario) (; transP, transM) = get_hybridproblem_transforms(prob; scenario) - intϕ = ComponentArrayInterpreter(CA.ComponentVector( - ϕg=1:length(ϕg0), ϕP=par_templates.θP)) - #ϕ0_cpu = vcat(ϕg0, par_templates.θP .* FT(0.9)) # slightly disturb θP_true - ϕ0_cpu = vcat(ϕg0, apply_preserve_axes(inverse(transP), par_templates.θP)) + ϕq0 = get_hybridproblem_ϕq(prob; scenario) + ϕP0 = ϕq0[Val(:μP)] + intϕ = ComponentArrayInterpreter(CA.ComponentVector(ϕg=1:length(ϕg0), ϕP=ϕP0)) + #ϕ0_cpu = vcat(ϕg0, pt.θP .* FT(0.9)) # slightly disturb θP_true + ϕ0_cpu = vcat(ϕg0, ϕP0) n_site, n_batch = get_hybridproblem_n_site_and_batch(prob; scenario) train_loader = get_hybridproblem_train_dataloader(prob; scenario) #TODO provide different test data @@ -60,15 +61,19 @@ function CommonSolve.solve(prob::AbstractHybridProblem, solver::HybridPointSolve pbm_covars = get_hybridproblem_pbmpar_covars(prob; scenario) n_site_test = size(test_data[1],2) priors = get_hybridproblem_priors(prob; scenario) - priorsP = [priors[k] for k in keys(par_templates.θP)] - priorsM = [priors[k] for k in keys(par_templates.θM)] - #intP = ComponentArrayInterpreter(par_templates.θP) + priorsP = Tuple(priors[k] for k in keys(pt.θP)) + priorsM = Tuple(priors[k] for k in keys(pt.θM)) + zero_prior_logdensity = omit_priors ? 0f0 : get_zero_prior_logdensity( + priorsP, priorsM, pt.θP, pt.θM) + #intP = ComponentArrayInterpreter(pt.θP) loss_gf = get_loss_gf(g_dev, transM, transP, f_dev, py, intϕ; n_site_batch=n_batch, - cdev=infer_cdev(gdevs), pbm_covars, priorsP, priorsM, is_omit_priors,) + cdev=infer_cdev(gdevs), pbm_covars, + priorsP, priorsM, is_omit_priors, zero_prior_logdensity,) loss_gf_test = get_loss_gf(g_dev, transM, transP, ftest_dev, py, intϕ; n_site_batch=n_site_test, - cdev=infer_cdev(gdevs), pbm_covars, priorsP, priorsM, is_omit_priors,) + cdev=infer_cdev(gdevs), pbm_covars, + priorsP, priorsM, is_omit_priors, zero_prior_logdensity,) # call loss function once l1 = is_infer ? Test.@inferred(loss_gf(ϕ0_dev, first(train_loader_dev)...; is_testmode=true))[1] : @@ -155,6 +160,7 @@ end Perform the inversion of HVI Problem. Optional keyword arguments +- `prob`: The AbstractHybridProblem to solve. - `scenario`: Scenario to query prob, defaults to `Val(())`. - `rng`: Random generator, defaults to `Random.default_rng()`. - `gdevs`: `NamedTuple` `(;gdev_M, gdev_P)` functions to move @@ -168,9 +174,9 @@ Returns a `NamedTuple` of - `probo`: A copy of the HybridProblem, with updated optimized parameters - `interpreters`: TODO - `ϕ`: the optimized HVI parameters: a `ComponentVector` with entries - - `μP`: `ComponentVector` of the mean global PBM parameters at unconstrained scale - - `ϕg`: The MLmodel parameter vector, - - `unc`: `ComponentVector` of further uncertainty parameters + - `ϕg`: The ML model parameter vector, + - `ϕq`: `ComponentVector` of non-ML parameters, including + `μP`: `ComponentVector` of the mean global PBM parameters at unconstrained scale - `θP`: `ComponentVector` of the mean global PBM parameters at constrained scale - `resopt`: the structure returned by `Optimization.solve`. It can contain more information on convergence. @@ -180,27 +186,35 @@ function CommonSolve.solve(prob::AbstractHybridProblem, solver::HybridPosteriorS gdevs = get_gdev_MP(scenario), θmean_quant=0.0, is_inferred::Val{is_infer} = Val(false), + is_omit_priors::Val{omit_priors} = Val(false), + approx = prob.approx, kwargs... -) where {scen, is_infer} - par_templates = get_hybridproblem_par_templates(prob; scenario) - (; θP, θM) = par_templates +) where {scen, is_infer, omit_priors} + pt = get_hybridproblem_par_templates(prob; scenario) cor_ends = get_hybridproblem_cor_ends(prob; scenario) g, ϕg0 = get_hybridproblem_MLapplicator(prob; scenario) - ϕunc0 = get_hybridproblem_ϕunc(prob; scenario) (; transP, transM) = get_hybridproblem_transforms(prob; scenario) pbm_covars = get_hybridproblem_pbmpar_covars(prob; scenario) n_site, n_batch = get_hybridproblem_n_site_and_batch(prob; scenario) - hpints = HybridProblemInterpreters(prob; scenario) - (; ϕ, transPMs_batch, interpreters, get_transPMs, get_ca_int_PMs) = init_hybrid_params( - θP, θM, cor_ends, ϕg0, hpints; transP, transM, ϕunc0) - int_unc = interpreters.unc - int_μP_ϕg_unc = interpreters.μP_ϕg_unc + ϕq = get_hybridproblem_ϕq(prob; scenario) + (; ϕ, interpreters) = init_hybrid_params(ϕg0, ϕq) + int_ϕq = interpreters.ϕq + int_ϕg_ϕq = interpreters.ϕg_ϕq transMs = StackedArray(transM, n_batch) priors = get_hybridproblem_priors(prob; scenario) - priorsP = [priors[k] for k in keys(par_templates.θP)] - priorsM = [priors[k] for k in keys(par_templates.θM)] - # + priorsP = Tuple(priors[k] for k in keys(pt.θP)) + priorsM = Tuple(priors[k] for k in keys(pt.θM)) + zero_prior_logdensity = omit_priors ? 0f0 : get_zero_prior_logdensity( + priorsP, priorsM, pt.θP, pt.θM) train_loader = get_hybridproblem_train_dataloader(prob; scenario) + if first(train_loader)[1] isa CA.ComponentArray + @warn("ML model covariates (1) were provided as ComponentArray. " * + "Consider providing them as a plain array.") + end + if first(train_loader)[2] isa CA.ComponentArray + @warn("PBM drivers (2) were provided as ComponentArray. " * + "Consider providing them as a plain array.") + end if gdevs.gdev_M isa MLDataDevices.AbstractGPUDevice ϕ0_dev = gdevs.gdev_M(ϕ) g_dev = gdevs.gdev_M(g) # zygote fails if gdev is a CPUDevice, although should be non-op @@ -220,29 +234,35 @@ function CommonSolve.solve(prob::AbstractHybridProblem, solver::HybridPosteriorS py = get_hybridproblem_neg_logden_obs(prob; scenario) priors_θP_mean, priors_θMs_mean = construct_priors_θ_mean( - prob, ϕ0_dev.ϕg, keys(θM), θP, θmean_quant, g_dev, transM, transP; - scenario, get_ca_int_PMs, gdevs, pbm_covars) + prob, ϕ0_dev.ϕg, keys(pt.θM), pt.θP, θmean_quant, g_dev, transM, transP; + scenario, gdevs, pbm_covars) loss_elbo = get_loss_elbo( g_dev, transP, transMs, f_dev, py; solver.n_MC, solver.n_MC_cap, cor_ends, priors_θP_mean, priors_θMs_mean, - cdev=infer_cdev(gdevs), pbm_covars, θP, int_unc, int_μP_ϕg_unc, priorsP, priorsM,) + cdev=infer_cdev(gdevs), pbm_covars, pt.θP, int_ϕq, int_ϕg_ϕq, priorsP, priorsM, + is_omit_priors, zero_prior_logdensity, approx, + ) # test loss function once # tmp = first(train_loader_dev) # using ShareAdd # @usingany Cthulhu # @descend_code_warntype loss_elbo(ϕ0_dev, rng, first(train_loader_dev)...) - l0 = is_infer ? - (Test.@inferred loss_elbo(ϕ0_dev, rng, first(train_loader_dev)...; is_testmode=true)) : + # omit for type stability in AD + l0 = + #is_infer ? + # (Test.@inferred loss_elbo(ϕ0_dev, rng, first(train_loader_dev)...; is_testmode=true)) : loss_elbo(ϕ0_dev, rng, first(train_loader_dev)...; is_testmode=false) optf = Optimization.OptimizationFunction( (ϕ, data) -> first(loss_elbo(ϕ, rng, data...; is_testmode=false)), Optimization.AutoZygote()) optprob = OptimizationProblem(optf, CA.getdata(ϕ0_dev), train_loader_dev) res = Optimization.solve(optprob, solver.alg; kwargs...) - ϕc = interpreters.μP_ϕg_unc(res.u) - θP = !isempty(ϕc.μP) ? cpu_ca(apply_preserve_axes(transP, ϕc.μP)) : CA.ComponentVector{eltype(ϕc)}() - probo = HybridProblem(prob; ϕg=cpu_ca(ϕc).ϕg, θP=θP, ϕunc=cpu_ca(ϕc).unc) + ϕc = interpreters.ϕg_ϕq(cpu_device()(res.u)) + ϕq = ϕc[Val(:ϕq)]; + ϕg = ϕc[Val(:ϕg)]; + probo = HybridProblem(prob; ϕg, ϕq) + θP = get_hybridproblem_θP(probo) (; probo, interpreters, ϕ=ϕc, θP, resopt=res) end @@ -273,28 +293,31 @@ The loss function takes in addition to ϕ, data that changes with minibatch function get_loss_elbo(g, transP, transMs, f, py; n_MC, n_MC_mean = max(n_MC,20), n_MC_cap=n_MC, cor_ends, priors_θP_mean, priors_θMs_mean, cdev, pbm_covars, θP, - int_unc, int_μP_ϕg_unc, + int_ϕq, int_ϕg_ϕq, priorsP, priorsM, floss_penalty = zero_penalty_loss, + is_omit_priors, zero_prior_logdensity, approx, ) let g = g, transP = transP, transMs = transMs, f = f, py = py, n_MC = n_MC, n_MC_cap = n_MC_cap, n_MC_mean = n_MC_mean, cor_ends = cor_ends, - int_unc = get_concrete(int_unc), int_μP_ϕg_unc = get_concrete(int_μP_ϕg_unc), + int_ϕq = get_concrete(int_ϕq), int_ϕg_ϕq = get_concrete(int_ϕg_ϕq), priors_θP_mean = priors_θP_mean, priors_θMs_mean = priors_θMs_mean, cdev = cdev, pbm_covar_indices = get_pbm_covar_indices(θP, pbm_covars), trans_mP=StackedArray(transP, n_MC_mean), trans_mMs=StackedArray(transMs.stacked, n_MC_mean), - priorsP=priorsP, priorsM=priorsM, floss_penalty=floss_penalty + priorsP=priorsP, priorsM=priorsM, floss_penalty=floss_penalty, + is_omit_priors = is_omit_priors, zero_prior_logdensity = zero_prior_logdensity, + approx = approx function loss_elbo(ϕ, rng, xM, xP, y_o, y_unc, i_sites; is_testmode) - #ϕc = int_μP_ϕg_unc(ϕ) + #ϕc = int_ϕg_ϕq(ϕ) neg_elbo_gtf( rng, ϕ, g, f, py, xM, xP, y_o, y_unc, i_sites; - int_unc, int_μP_ϕg_unc, + int_ϕq, int_ϕg_ϕq, n_MC, n_MC_cap, n_MC_mean, cor_ends, priors_θP_mean, priors_θMs_mean, cdev, pbm_covar_indices, transP, transMs, trans_mP, trans_mMs, - priorsP, priorsM, floss_penalty, #ϕg = ϕc.ϕg, ϕunc = ϕc.unc, - is_testmode, + priorsP, priorsM, floss_penalty, #ϕg = ϕc.ϕg, ϕq = ϕc.ϕq, + is_testmode, is_omit_priors, zero_prior_logdensity, approx, ) end end @@ -323,14 +346,13 @@ function compute_elbo_components( θmean_quant=0.0, kwargs...) n_site, n_batch = get_hybridproblem_n_site_and_batch(prob; scenario) - par_templates = get_hybridproblem_par_templates(prob; scenario) - (; θP, θM) = par_templates + pt = get_hybridproblem_par_templates(prob; scenario) + (; θP, θM) = pt cor_ends = get_hybridproblem_cor_ends(prob; scenario) g, ϕg0 = get_hybridproblem_MLapplicator(prob; scenario) - ϕunc0 = get_hybridproblem_ϕunc(prob; scenario) + ϕq = get_hybridproblem_ϕq(prob; scenario) (; transP, transM) = get_hybridproblem_transforms(prob; scenario) - (; ϕ, transPMs_batch, interpreters, get_transPMs, get_ca_int_PMs) = init_hybrid_params( - θP, θM, cor_ends, ϕg0, n_batch; transP, transM, ϕunc0) + (; ϕ, interpreters) = init_hybrid_params(ϕg0, ϕq) if gdev isa MLDataDevices.AbstractGPUDevice ϕ0_dev = gdev(ϕ) g_dev = gdev(g) # zygote fails if gdev is a CPUDevice, although should be non-op @@ -351,7 +373,7 @@ function compute_elbo_components( py = get_hybridproblem_neg_logden_obs(prob; scenario) priors_θ_mean = construct_priors_θ_mean( prob, ϕ0_dev.ϕg, keys(θM), θP, θmean_quant, g_dev, transM; - scenario, get_ca_int_PMs, gdev, cdev, pbm_covars) + scenario, gdev, cdev, pbm_covars) neg_elbo_gtf_components( rng, ϕ0_dev, g_dev, transPMs_batch, f, py, xM, xP, y_o, y_unc, i_sites, interpreters; solver.n_MC, solver.n_MC_cap, cor_ends, priors_θ_mean) @@ -362,7 +384,7 @@ In order to let mean of θ stay close to initial point parameter estimates construct a prior on mean θ to a Normal around initial prediction. """ function construct_priors_θ_mean(prob, ϕg, keysθM, θP, θmean_quant, g_dev, transM, transP; - scenario::Val{scen}, get_ca_int_PMs, gdevs, pbm_covars, + scenario::Val{scen}, gdevs, pbm_covars, ) where {scen} iszero(θmean_quant) ? ([],[]) : begin @@ -389,7 +411,7 @@ function construct_priors_θ_mean(prob, ϕg, keysθM, θP, θmean_quant, g_dev, priors_θP_mean = map(priorsP, θP) do priorsP, θPi fit_narrow_normal(θPi, priorsP, θmean_quant) end - priorsM = [priors_dict[k] for k in keysθM] + priorsM = Tuple(priors_dict[k] for k in keysθM) i_par = 1 i_site = 1 priors_θMs_mean = map(Iterators.product(axes(θMs)...)) do (i_site, i_par) diff --git a/src/HybridVariationalInference.jl b/src/HybridVariationalInference.jl index 37dc8e8..8481078 100644 --- a/src/HybridVariationalInference.jl +++ b/src/HybridVariationalInference.jl @@ -29,7 +29,6 @@ import NaNMath # ignore missing observations in logDensity using DifferentiationInterface: DifferentiationInterface as DI import Zygote - export DoubleMM include("util.jl") @@ -41,6 +40,10 @@ VERSION >= v"1.11.0-DEV.469" && eval(Meta.parse("public Exp")) VERSION >= v"1.11.0-DEV.469" && eval(Meta.parse("public Logistic")) include("bijectors_utils.jl") +export AbstractHVIApproximation, AbstractMeanHVIApproximation +export MeanHVIApproximation, MeanHVIApproximationMat +include("HVIApproximation.jl") + export AbstractComponentArrayInterpreter, ComponentArrayInterpreter, StaticComponentArrayInterpreter export flatten1, get_concrete, get_positions, stack_ca_int, compose_interpreters @@ -62,7 +65,7 @@ include("PBMApplicator.jl") # include("GPUDataHandler.jl") export AbstractHybridProblem, get_hybridproblem_MLapplicator, get_hybridproblem_PBmodel, - get_hybridproblem_ϕunc, + get_hybridproblem_ϕq, get_hybridproblem_θP, get_hybridproblem_float_type, gen_hybridproblem_synthetic, get_hybridproblem_par_templates, get_hybridproblem_transforms, get_hybridproblem_train_dataloader, @@ -76,15 +79,10 @@ export AbstractHybridProblem, get_hybridproblem_MLapplicator, get_hybridproblem_ construct_dataloader_from_synthetic, gdev_hybridproblem_dataloader, gdev_hybridproblem_data, setup_PBMpar_interpreter, - get_gdev_MP + get_gdev_MP, + init_hybrid_ϕq include("AbstractHybridProblem.jl") -export AbstractHybridProblemInterpreters, HybridProblemInterpreters, - get_int_P, get_int_M, - get_int_Ms_batch, get_int_Ms_site, get_int_Mst_batch, get_int_Mst_site, - get_int_PMs_batch, get_int_PMs_site, get_int_PMst_batch, get_int_PMst_site -include("hybridprobleminterpreters.jl") - export HybridProblem export get_quantile_transformed include("HybridProblem.jl") @@ -112,7 +110,9 @@ export get_ca_starts, get_ca_ends, get_cor_count include("cholesky.jl") export neg_elbo_gtf, sample_posterior, predict_hvi, zero_penalty_loss +include("elbo_dev.jl") include("elbo.jl") +include("elbo2.jl") export init_hybrid_params, init_hybrid_ϕunc include("init_hybrid_params.jl") @@ -126,4 +126,6 @@ include("DoubleMM/DoubleMM.jl") export RRuleMonitor include("RRuleMonitor.jl") +include("chainrulescore.jl") + end diff --git a/src/PBMApplicator.jl b/src/PBMApplicator.jl index 5b0b04a..0a2afd5 100644 --- a/src/PBMApplicator.jl +++ b/src/PBMApplicator.jl @@ -258,13 +258,14 @@ function create_nsite_applicator(app::PBMPopulationApplicator, n_site) end function apply_model(app::PBMPopulationApplicator, θP::AbstractVector, θMs::AbstractMatrix, xP) - if (CA.getdata(θP) isa GPUArraysCore.AbstractGPUArray) && - (!(CA.getdata(app.θFixm) isa GPUArraysCore.AbstractGPUArray) || - !(CA.getdata(θMs) isa GPUArraysCore.AbstractGPUArray)) - error("concatenating GPUarrays with non-gpu arrays θFixm or θMs. " * - "May transfer PBMPopulationApplicator to gdev, " * - "or compute PBM on CPU.") - end + # error causes trouble in type inference in Zygote + # if (CA.getdata(θP) isa GPUArraysCore.AbstractGPUArray) && + # (!(CA.getdata(app.θFixm) isa GPUArraysCore.AbstractGPUArray) || + # !(CA.getdata(θMs) isa GPUArraysCore.AbstractGPUArray)) + # error("concatenating GPUarrays with non-gpu arrays θFixm or θMs. " * + # "May transfer PBMPopulationApplicator to gdev, " * + # "or compute PBM on CPU.") + # end # repeat θP and concatenate with # repeat is 2x slower for Vector and 100 times slower (with allocation) on GPU # app.isP on CPU is slightly faster than app.isP on GPU @@ -272,19 +273,32 @@ function apply_model(app::PBMPopulationApplicator, θP::AbstractVector, θMs::Ab #@benchmark CA.getdata(θP[app.isP]) #@benchmark CA.getdata(repeat(θP', size(θMs,1))) #@benchmark rep_fac .* CA.getdata(θP)' # + # call function with tailored rrule to handle case of empty θP to return CA not NoTanged + # but when returning a gradient of size (n_bach, 0) there are errors + # need to live with dynamic dispatch of Union type of Matrix and ZeroTangent + #local θ = concat_PMFix(θP, θMs, app) local θ = if !isempty(θP) - hcat(app.rep_fac .* CA.getdata(θP)', CA.getdata(θMs), CA.getdata(app.θFixm)) + hcat(app.rep_fac .* CA.getdata(θP)' , CA.getdata(θMs), CA.getdata(app.θFixm)) else hcat(CA.getdata(θMs), CA.getdata(app.θFixm)) end - #local θ = hcat(CA.getdata(θP[app.isP]), CA.getdata(θMs), app.θFixm) - #local θ = hcat(CA.getdata(repeat(θP', size(θMs,1))), CA.getdata(θMs), app.θFixm) - local θc = app.intθ(CA.getdata(θ)) + local θc = app.intθ(θ) local xPc = app.int_xP(CA.getdata(xP)) local pred_sites = app.fθpop(θc, xPc) return pred_sites end +# function concat_PMFix(θP, θMs, app) +# local θ = if !isempty(θP) +# hcat(app.rep_fac .* CA.getdata(θP)' , CA.getdata(θMs), CA.getdata(app.θFixm)) +# else +# hcat(CA.getdata(θMs), CA.getdata(app.θFixm)) +# end +# end + + + + struct PBMPopulationGlobalApplicator{MFT, IsT, IgT, IXT, F} <: AbstractPBMApplicator fθpop::F θFix::MFT # may be CuVector rather than Vector diff --git a/src/chainrulescore.jl b/src/chainrulescore.jl new file mode 100644 index 0000000..dce15e6 --- /dev/null +++ b/src/chainrulescore.jl @@ -0,0 +1,34 @@ +function ChainRulesCore.rrule(::typeof(as_ca), v::AbstractArray, int::AbstractComponentArrayInterpreter) + as_ca(v, int), + function rrule_as_ca_inner(Δ) + vb = CA.getdata(unthunk(Δ)) + vbr = reshape(vb, size(v)) + (ChainRulesCore.NoTangent(), vbr, ChainRulesCore.NoTangent()) + end +end + + +# function ChainRulesCore.rrule(::typeof(concat_PMFix), θP, θMs, app) +# nP = length(θP) +# isP = 1:nP +# isM = nP .+ 1:size(θMs,2) +# # +# concat_PMFix(θP, θMs, app), +# function rrule_concat_PMFix_empty(Δ) +# # when returning a gradient of size (n_bach, 0) there are errors +# # need to live with dynamic dispatch of Union type of Matrix and ZeroTangent +# ΔθP = isempty(θP) ? ChainRulesCore.ZeroTangent() : +# CA.ComponentArray(vec(sum(Δ[:,isP], dims=1)), CA.getaxes(θP)) +# ΔθMs = CA.ComponentArray(Δ[:, isM], CA.getaxes(θMs)) +# (ChainRulesCore.NoTangent(), ΔθP, ΔθMs, ChainRulesCore.NoTangent()) +# end +# end + +# function ChainRulesCore.rrule(::typeof(transform_and_logjac_ζ), ζP, ζMs; transP, transMs) +# transform_and_logjac_ζ(ζP, ζMs; transP, transMs), +# function rrule_test(Δ) +# Main.@infiltrate_main +# (ChainRulesCore.NoTangent(), ΔζP, ΔζMs) +# end +# end + diff --git a/src/cholesky.jl b/src/cholesky.jl index 539d2c5..47b4ce6 100644 --- a/src/cholesky.jl +++ b/src/cholesky.jl @@ -158,7 +158,7 @@ function transformU_cholesky1(v::AbstractVector; U = _transformU_cholesky1_getU(v; n, create_empty) # ? UpperTriangular has problems with AD (which tries to set elements in lower) #return U - return (UpperTriangular(U)) + _maybe_UpperTriangular(U) end function _transformU_cholesky1_getU(v::AbstractVector; @@ -173,13 +173,9 @@ function _transformU_cholesky1_getU(v::AbstractVector; U = U_scaled ./ sqrt.(sum(abs2, U_scaled, dims=1)) end -function transformU_cholesky1(v::GPUArraysCore.AbstractGPUVector; - n=invsumn(length(v)) + 1, create_empty = false) - U = _transformU_cholesky1_getU(v; n, create_empty) - # do not convert to UpperTrinangular on GPU, but full matrix - #return (UpperTriangular(U)) - return U -end +# convert to UpperTriangular, but not on GPU +_maybe_UpperTriangular(U::AbstractMatrix) = UpperTriangular(U) +_maybe_UpperTriangular(U::GPUArraysCore.AbstractGPUMatrix) = U # function transformU_block_cholesky1(v::CA.ComponentVector; # ns=(invsumn(length(v[k])) + 1 for k in keys(v)) # may pass for efficiency @@ -219,10 +215,11 @@ front(itr, n=1) = Iterators.take(itr, length(itr) - n) Return a Vector with ending positions of components in vc. Useful for providing information on correlactions among subranges in a vector. +For an empty vector Int[0] is returned. """ function get_ca_ends(vc::CA.ComponentVector) #(cumsum(length(vc[k]) for k in keys(vc))...,) - length(keys(vc)) == 0 ? Int[] : cumsum(length(vc[k])::Int for k in keys(vc)) + length(keys(vc)) == 0 ? Int[0] : cumsum(length(vc[k])::Int for k in keys(vc)) end @@ -253,8 +250,8 @@ end """ transformU_block_cholesky1(v::AbstractVector, cor_ends) -Transform a parameterization v of a blockdiagonal of upper triangular matrices -into the this matrix. +Transform a parameterization, `v`, of a blockdiagonal of upper triangular matrices +into a vector with a matrix for each block. `cor_ends` is an AbstractVector of Integers specifying the last column of each block. E.g. For a matrix with a 3x3, a 2x2, and another single-entry block, the blocks start at columns (3,5,6). It defaults to a single entire block. @@ -262,28 +259,60 @@ the blocks start at columns (3,5,6). It defaults to a single entire block. An correlation parameterization can parameterize a block of a single parameter, or an empty parameter block. To indicate the empty block, provide `cor_ends == [0]`. """ +function transformU_blocks_cholesky1( + v::AbstractVector{T}, cor_ends::AbstractVector{TI}=1:length(v)) where {T,TI<:Integer} + if isempty(cor_ends) # 1:0 + # assume a single parameter -> no correclation -> One() matrix and empty range + # 1-1-matrix with value 1 with the same type as v + v1 = v[1] + v1m = ChainRulesCore.@ignore_derivatives reshape(v[1:1] .* zero(v1) .+ one(v1), 1,1) + [_maybe_UpperTriangular(v1m)], (1:1 for i in 1:1) + elseif (cor_ends == [0]) + #no parameters at all (and also no correclation) -> empty matrix and empty range + [_maybe_UpperTriangular(reshape(v[1:0],0,0))], (1:0 for i in 1:1) + else + cor_counts = get_cor_counts(cor_ends) # number of correlation parameters + ranges = ChainRulesCore.@ignore_derivatives ( + begin + cor_start = (i == 1 ? one(TI) : cor_counts[i-1] + one(TI)) + cor_start:cor_counts[i] + end for i in 1:length(cor_counts) + ) + ranges_z = ChainRulesCore.@ignore_derivatives ( + begin + + cor_start = (i == 1 ? one(TI) : cor_ends[i-1] + one(TI)) + cor_start:cor_ends[i] + end for i in 1:length(cor_counts) + ) + [transformU_cholesky1(v[r]) for r in ranges], ranges_z + end +end + function transformU_block_cholesky1( v::AbstractVector{T}, cor_ends::AbstractVector{TI}=Int[]) where {T,TI<:Integer} - # (cor_ends == [0]) no parameters at all (and also no correclation) - if length(cor_ends) <= 1 # if there is only one block, return it - # for type stability create a BlockDiagonal of a single block - create_empty = (cor_ends == [0]) - return _create_blockdiag(v, [transformU_cholesky1(v; create_empty)]) - end - cor_counts = get_cor_counts(cor_ends) # number of correlation parameters - #@show cor_counts - ranges = ChainRulesCore.@ignore_derivatives ( - begin - cor_start = (i == 1 ? one(TI) : cor_counts[i-1] + one(TI)) - cor_start:cor_counts[i] - end for i in 1:length(cor_counts) - ) - #@show collect(ranges) - blocks = [transformU_cholesky1(v[r]) for r in ranges] + blocks, _ = transformU_blocks_cholesky1(v, cor_ends) + # # (cor_ends == [0]) no parameters at all (and also no correclation) + # if length(cor_ends) <= 1 # if there is only one block, return it + # # for type stability create a BlockDiagonal of a single block + # create_empty = (cor_ends == [0]) + # return _create_blockdiag(v, [transformU_cholesky1(v; create_empty)]) + # end + # cor_counts = get_cor_counts(cor_ends) # number of correlation parameters + # #@show cor_counts + # ranges = ChainRulesCore.@ignore_derivatives ( + # begin + # cor_start = (i == 1 ? one(TI) : cor_counts[i-1] + one(TI)) + # cor_start:cor_counts[i] + # end for i in 1:length(cor_counts) + # ) + # #@show collect(ranges) + # blocks = [transformU_cholesky1(v[r]) for r in ranges] U = _create_blockdiag(v, blocks) # v only for dispatch: plain matrix for gpu return (U) end + function _create_blockdiag(::AbstractArray{T}, blocks::AbstractArray) where {T} BlockDiagonal(blocks) end diff --git a/src/elbo.jl b/src/elbo.jl index 90d4ba5..7c919c5 100644 --- a/src/elbo.jl +++ b/src/elbo.jl @@ -7,7 +7,7 @@ expected value of the likelihood of observations. ## Arguments - `rng`: random number generator (ignored on CUDA, if ϕ is a AbstractGPUArray) - `ϕ`: flat vector of parameters - interpreted by interpreters.μP_ϕg_unc and interpreters.PMs + interpreted by interpreters.ϕg_ϕq and interpreters.PMs - `g`: machine learning model - `transPMs`: Transformations as generated by get_transPMs returned from init_hybrid_params - `f`: mechanistic model @@ -20,10 +20,10 @@ expected value of the likelihood of observations. - `y_unc`: observation uncertainty provided to py (same size as y_ob) - `i_sites`: indices of sites for current minibatch - `interpreters`: NamedTuple as generated by `gen_hybridproblem_synthetic` with entries: - - `μP_ϕg_unc`: extract components of parameter of + - `ϕg_ϕq`: extract components of parameter of 1) means of global PBM, 2) ML-weights, and 3) additional parameters of approximation q - `PMs`: assign components to PBM parameters 1 global, 2 matrix of n_site column vectors - - `int_unc` (can be omitted, if `μP_ϕg_unc(ϕ).unc` is already a ComponentVector) + - `int_ϕq` interpreter of components of ϕq - `n_MC`: number of MonteCarlo samples from the distribution of parameters to simulate using the mechanistic model f. """ @@ -31,8 +31,9 @@ function neg_elbo_gtf(args...; kwargs...) # TODO prior and penalty loss (;nLjoint, entropy_ζ, loss_penalty, nLy, neg_log_prior, neg_log_jac, - nLmean_θ) = neg_elbo_gtf_components(args...; kwargs...) - nL = nLjoint - entropy_ζ + loss_penalty + nLmean_θ + #nLmean_θ + ) = neg_elbo_gtf_components(args...; kwargs...) + nL = nLjoint - entropy_ζ + loss_penalty #+ nLmean_θ # if !isfinite(nL) # @show nL # @show nLjoint, entropy_ζ, loss_penalty, nLy, @@ -44,8 +45,8 @@ end function neg_elbo_gtf_components(rng, ϕ::AbstractVector{FT}, g, f, py, xM::AbstractMatrix, xP, y_ob, y_unc, i_sites::AbstractVector{<:Number}; - int_μP_ϕg_unc::AbstractComponentArrayInterpreter, - int_unc::AbstractComponentArrayInterpreter, + int_ϕg_ϕq::AbstractComponentArrayInterpreter, + int_ϕq::AbstractComponentArrayInterpreter, n_MC=12, n_MC_mean=n_MC, n_MC_cap=n_MC, cdev=cpu_device(), priors_θP_mean=[], @@ -59,24 +60,31 @@ function neg_elbo_gtf_components(rng, ϕ::AbstractVector{FT}, g, f, py, priorsP, priorsM, floss_penalty = zero_penalty_loss, is_testmode, + is_omit_priors, + zero_prior_logdensity, + approx::AbstractHVIApproximation, ) where {FT} n_MCr = isempty(priors_θP_mean) ? n_MC : max(n_MC, n_MC_mean) - ζsP, ζsMs, σ = generate_ζ(rng, g, ϕ, xM; n_MC=n_MCr, cor_ends, pbm_covar_indices, - int_unc, int_μP_ϕg_unc, is_testmode) + ζsP, ζsMs, σ = generate_ζ(approx, rng, g, ϕ, xM; n_MC=n_MCr, cor_ends, pbm_covar_indices, + int_ϕq, int_ϕg_ϕq, is_testmode) ζsP_cpu = cdev(ζsP) # fetch to CPU, because for <1000 sites (n_batch) this is faster ζsMs_cpu = cdev(ζsMs) # fetch to CPU, because for <1000 sites (n_batch) this is faster # # maybe: translate ζ once and supply to both neg_elbo and negloglik_meanθ - ϕc = int_μP_ϕg_unc(ϕ) + ϕc = int_ϕg_ϕq(ϕ) + VT= typeof(@view(ϕ[1:1])) + ϕg = CA.getdata(ϕc.ϕg)::VT + ϕq = CA.getdata(ϕc.ϕq)::VT loss_comps = neg_elbo_ζtf( ζsP_cpu[:,1:n_MC], ζsMs_cpu[:,:,1:n_MC], σ, f, py, xP, y_ob, y_unc; n_MC_cap, transP, transMs, priorsP, priorsM, - floss_penalty, ϕg = ϕc.ϕg, ϕunc = ϕc.unc,) + floss_penalty, ϕg, ϕq, is_omit_priors, zero_prior_logdensity,) # # maybe: provide trans_mP and trans_mMs with creating cost function - nLmean_θ = _compute_negloglik_meanθ(ζsP_cpu, ζsMs_cpu; - trans_mP, trans_mMs, priors_θP_mean, priors_θMs_mean, i_sites, ) - (;loss_comps..., nLmean_θ) + # not used any more and merging named tuples takes long + # nLmean_θ = _compute_negloglik_meanθ(ζsP_cpu, ζsMs_cpu; + # trans_mP, trans_mMs, priors_θP_mean, priors_θMs_mean, i_sites, ) + # (;loss_comps..., nLmean_θ) end function _compute_negloglik_meanθ(ζsP::AbstractMatrix{FT}, ζsMs; @@ -94,6 +102,20 @@ function _compute_negloglik_meanθ(ζsP::AbstractMatrix{FT}, ζsMs; convert(FT,nLmean_θ)::FT end +""" + get_zero_prior_logdensity(priorsP::Tuple, priorsM::Tuple, θP, θM) + +invoke logpdf of prior and sum, to infer return type and proper zero of prior density. +""" +function get_zero_prior_logdensity(priorsP::Tuple, priorsM::Tuple, θP, θM) + zd = get_zero_prior_logdensity(priorsM, θM) + isempty(priorsP) ? zd : zd + get_zero_prior_logdensity(priorsP, θP) +end +function get_zero_prior_logdensity(priors::Tuple, θ) + logpdf_t = (prior, θ) -> logpdf(prior, θ) + zero(sum(map(logpdf_t, priors, θ))) +end + """ Compute the neg_elbo for each sampled parameter vector (last dimension of ζs). - Transform and compute log-jac @@ -112,33 +134,14 @@ function neg_elbo_ζtf(ζsP, ζsMs, σ, f, py, xP, y_ob, y_unc; transP, transMs=StackedArray(transM, size(ζsMs, 2)), priorsP, priorsM, - floss_penalty, ϕg, ϕunc, -) + floss_penalty, ϕg, ϕq, + is_omit_priors::Val, + zero_prior_logdensity, +) n_MC = size(ζsP,2) - cdev = cpu_device() #TODO avoid the cdev - #ETPrior = isempty(priorsP) ? eltype(eltype(priorsM)) : promote_type(eltype(priorsP), eltype(eltype(priorsM))) - ETPrior = isempty(priorsP) ? eltype(ζsMs) : promote_type(eltype(ζsP), eltype(ζsMs)) f_sample = (ζP, ζMs) -> begin θP, θMs, logjac_i = transform_and_logjac_ζ(ζP, ζMs; transP, transMs) - logpdf_t = (prior, θ) -> logpdf(prior, θ)::eltype(θP) - logpdf_tv = (prior, θ::AbstractVector) -> begin - tmp = map(Base.Fix1(logpdf, prior), θ) - tmp::Vector{eltype(θ)} - end - #TODO avoid the cdev, but compute prior on GPU because transfer takes long - # but currently logpdf only works on CPU - # handle edge case of no global parameters, where priorsP is empty - nlP0 = isempty(priorsP) ? zero(ETPrior) : -sum(logpdf_t.(priorsP, cdev(θP))) - neg_log_prior_i = nlP0 - sum(map( - (priorMi, θMi) -> sum(logpdf_tv(priorMi, θMi)), priorsM, eachcol(cdev(θMs)))) - if !isfinite(neg_log_prior_i) - @show neg_log_prior_i, nlP0 - @show θMs - @show priorsM - error("inspect non-finite priors") - i_par = 2 - priorMi, θMi = priorsM[i_par], eachcol(cdev(θMs))[2] - end + # currently logpdf only works on CPU y_pred_i = f(θP, θMs, xP) #nLy1 = neg_logden_indep_normal(y_ob, y_pred_i, y_unc) # Main.@infiltrate_main @@ -147,15 +150,22 @@ function neg_elbo_ζtf(ζsP, ζsMs, σ, f, py, xP, y_ob, y_unc; # @usingany Cthulhu # @descend_code_warntype f(θP, θMs, xP) nLy_i = py(y_ob, y_pred_i, y_unc) - loss_penalty_i = convert(eltype(ζMs),floss_penalty(y_pred_i, θMs, θP, ϕg, ϕunc)) + loss_penalty_i = convert(eltype(nLy_i),floss_penalty(y_pred_i, θMs, θP, ϕg, ϕq)) + neg_log_prior_i = compute_priors_logdensity(priorsP, priorsM, θP, θMs, + is_omit_priors, zero_prior_logdensity) # make sure names to not match outer, otherwise Box type instability (nLy_i, neg_log_prior_i, -logjac_i, loss_penalty_i) #(nLy_i, 0.0, 0.0, 0.0) end # only Vector inferred, need to provide type hint # make that all components use the same Float type - #map_res = map(f_sample, eachcol(ζsP), eachslice(ζsMs; dims=3))::Vector{NTuple{4,eltype(ζsP)}} - map_res = map(f_sample, eachcol(ζsP), eachslice(ζsMs; dims=3))::Vector{Tuple{eltype(y_ob),ETPrior, eltype(ζsP), eltype(ζsP)}} + # Test.@inferred f_sample(first(eachcol(ζsP)), first(eachslice(ζsMs; dims=3))) + # Test.@inferred map(f_sample, eachcol(ζsP), eachslice(ζsMs; dims=3)) + #using ShareAdd + #@usingany Cthulhu + #@descend_code_warntype f_sample(first(eachcol(ζsP)), first(eachslice(ζsMs; dims=3))) + #map_res = Test.@inferred map(f_sample, eachcol(ζsP), eachslice(ζsMs; dims=3)) + map_res = map(f_sample, eachcol(ζsP), eachslice(ζsMs; dims=3)) nLys, neg_log_priors, neglogjacs, loss_penalties = vectuptotupvec(map_res) # For robustness may compute the expectation only on the n_smallest values # because its very sensitive to few large outliers @@ -190,8 +200,67 @@ function neg_elbo_ζtf(ζsP, ζsMs, σ, f, py, xP, y_ob, y_unc; (;nLjoint, entropy_ζ, loss_penalty, nLy, neg_log_prior, neg_log_jac) end +function compute_priors_logdensity(priorsP, priorsM, θP, θMs, + ::Val{omit_priors}, zero_prior_logdensity) where {omit_priors} + if omit_priors + zero_prior_logdensity + elseif (θP isa AbstractGPUArray) || (θMs isa AbstractGPUArray) + @warn("neg_elbo_ζtf: Cannot apply priors to gpu array. Piors are omitted. "* + "either compute PBM on CPU or omit priors.") + zero_prior_logdensity + else + compute_priors_logdensity(priorsP, priorsM, θP, θMs, zero_prior_logdensity) + end +end + +function compute_priors_logdensity(priorsP, priorsM, θP, θMs, zero_prior_logdensity) + logpdf_t = (prior, θ) -> logpdf(prior, θ)::eltype(θP) + function logpdf_tv_sum(prior, θ::AbstractVector{T}) where T + # logpdf_tv_sum_inner = let prior = prior + # function(θi) + # lp = logpdf(prior, θi) + # # TT = ChainRulesCore.@ignore_derivatives Base.return_types(logpdf, Tuple{typeof(prior), typeof(θi)}) + # # if TT != [typeof(lp)] + # # error("encountered unstable logpdf: $TT") + # # end + # lp + # end + # end + # sum(logpdf_tv_sum_inner, θ) + sum(θi -> logpdf(prior, θi), θ) + end + # handle edge case of no global parameters, where priorsP is empty + nlP0 = isempty(priorsP) ? zero_prior_logdensity : -sum(logpdf_t.(priorsP, θP)) + # fi = (priorMi, θMi) -> begin + # logpdf_tv_sum(priorMi, θMi) + # sum(logpdf_tv_sum(priorMi, θMi))::eltype(θMi) + # end + f_col = let priorsM=priorsM, θMs=θMs + function f_col_inner(i) + # TP = ChainRulesCore.@ignore_derivatives Base.return_types(getindex, Tuple{typeof(priorsM), typeof(i)}) + # if TP != [typeof(priorsM[i])] + # error("encountered unstable priorsM: $TP") + # end + logpdf_tv_sum(priorsM[i], θMs[:,i]) + #Tθ = Base.return_types(getindex, Tuple{typeof(θMs), Colon, typeof(i)}) + #TRET = Base.return_types(logpdf_tv_sum, Tuple{typeof(priorsM[i]), typeof(θMs[:,i])}) + end + end + # init keyword does not work with Zygote + #nlMs_sum = sum(f_col, 1:length(priorsM), init = zero(nlP0)) + nlMs_sum = sum(f_col, 1:length(priorsM))::typeof(nlP0) # not type inferred in julia 1.10 + neg_log_prior_i = nlP0 - nlMs_sum + if !isfinite(neg_log_prior_i) + @show neg_log_prior_i, nlP0 + @show θMs + @show priorsM + error("inspect non-finite priors") + end + neg_log_prior_i +end + """ - zero_penalty_loss(y_pred, θMs, θP, ϕg, ϕunc) + zero_penalty_loss(y_pred, θMs, θP, ϕg, ϕq) Add zero i.e. no additional loss terms during the HVI fit. @@ -208,11 +277,11 @@ Arguments - θMs::AbstractMatrix: site parameters - θP::AbstractVector: global parameters - ϕg: ML-model parameters, -- ϕunc::AbstractVector, additional parameters of the posterior +- ϕq::AbstractVector, additional parameters of the posterior """ function zero_penalty_loss( y_pred::AbstractMatrix, θMs::AbstractMatrix, θP::AbstractVector, - ϕg, ϕunc::AbstractVector) + ϕg, ϕq::AbstractVector) return zero(eltype(θMs)) end @@ -314,6 +383,7 @@ function sample_posterior(rng, prob::AbstractHybridProblem, xM::AbstractMatrix; scenario=Val(()), n_sample_pred=200, gdevs = get_gdev_MP(scenario), + approx = nothing, kwargs... ) n_site, n_batch = get_hybridproblem_n_site_and_batch(prob; scenario) @@ -321,31 +391,32 @@ function sample_posterior(rng, prob::AbstractHybridProblem, xM::AbstractMatrix; n_site_pred = is_predict_batch ? n_batch : n_site @assert size(xM, 2) == n_site_pred par_templates = get_hybridproblem_par_templates(prob; scenario) - (; θP, θM) = par_templates cor_ends = get_hybridproblem_cor_ends(prob; scenario) g, ϕg0 = get_hybridproblem_MLapplicator(prob; scenario) - ϕunc0 = get_hybridproblem_ϕunc(prob; scenario) + ϕq = get_hybridproblem_ϕq(prob; scenario) (; transP, transM) = get_hybridproblem_transforms(prob; scenario) pbm_covars = get_hybridproblem_pbmpar_covars(prob; scenario) - pbm_covar_indices = get_pbm_covar_indices(θP, pbm_covars) - hpints = HybridProblemInterpreters(prob; scenario) - (; ϕ, transPMs_batch, interpreters, get_transPMs) = init_hybrid_params( - θP, θM, cor_ends, ϕg0, hpints; transP, transM, ϕunc0) - int_μP_ϕg_unc = interpreters.μP_ϕg_unc - int_unc = interpreters.unc + pbm_covar_indices = get_pbm_covar_indices(par_templates.θP, pbm_covars) + (; ϕ, interpreters) = init_hybrid_params(ϕg0, ϕq) + int_ϕg_ϕq = interpreters.ϕg_ϕq + int_ϕq = interpreters.ϕq transMs = StackedArray(transM, n_batch) g_dev, ϕ_dev = gdevs.gdev_M(g), gdevs.gdev_M(ϕ) + if isnothing(approx) + approx = prob.approx # assuming has field approx, e.g. if its a HybridProblem + end (; θsP, θsMs, entropy_ζ) = sample_posterior(rng, g_dev, ϕ_dev, xM; - int_μP_ϕg_unc, int_unc, transP, transM, - n_sample_pred, cdev=infer_cdev(gdevs), cor_ends, pbm_covar_indices, kwargs...) - θsPc = ComponentArrayInterpreter(prob.θP, (n_sample_pred,))(θsP) - θsMsc = ComponentArrayInterpreter((n_site,), prob.θM, (n_sample_pred,))(θsMs) + int_ϕg_ϕq, int_ϕq, transP, transM, + n_sample_pred, cdev=infer_cdev(gdevs), cor_ends, pbm_covar_indices, approx, + kwargs...) + θsPc = ComponentArrayInterpreter(par_templates.θP, (n_sample_pred,))(θsP) + θsMsc = ComponentArrayInterpreter((n_site,), par_templates.θM, (n_sample_pred,))(θsMs) (; θsP=θsPc, θsMs=θsMsc, entropy_ζ) end function sample_posterior(rng, g, ϕ::AbstractVector, xM::AbstractMatrix; - int_μP_ϕg_unc::AbstractComponentArrayInterpreter, - int_unc::AbstractComponentArrayInterpreter, + int_ϕg_ϕq::AbstractComponentArrayInterpreter, + int_ϕq::AbstractComponentArrayInterpreter, transP, transM, n_sample_pred, cdev, @@ -353,9 +424,10 @@ function sample_posterior(rng, g, ϕ::AbstractVector, xM::AbstractMatrix; pbm_covar_indices, is_inferred::Val{is_infer} = Val(false), is_testmode, + approx::AbstractHVIApproximation, ) where is_infer - ζsP_gpu, ζsMs_gpu, σ = generate_ζ(rng, g, CA.getdata(ϕ), CA.getdata(xM); - int_μP_ϕg_unc, int_unc, + ζsP_gpu, ζsMs_gpu, σ = generate_ζ(approx, rng, g, CA.getdata(ϕ), CA.getdata(xM); + int_ϕg_ϕq, int_ϕq, n_MC=n_sample_pred, cor_ends, pbm_covar_indices, is_testmode) ζsP = cdev(ζsP_gpu) ζsMs = cdev(ζsMs_gpu) @@ -369,6 +441,7 @@ function sample_posterior(rng, g, ϕ::AbstractVector, xM::AbstractMatrix; (; θsP, θsMs, entropy_ζ) end + """ Generate samples of (inv-transformed) model parameters, ζ, and the vector of standard deviations, σ, i.e. the diagonal of the cholesky-factor. @@ -380,46 +453,49 @@ model. The output shape of size `(n_site x n_par x n_MC)` is tailored to iterating each MC sample and then transforming each parameter on block across sites. """ -function generate_ζ(rng, g, ϕ::AbstractVector{FT}, xM::MT; - int_μP_ϕg_unc::AbstractComponentArrayInterpreter, - int_unc::AbstractComponentArrayInterpreter, +function generate_ζ(approx::AbstractMeanHVIApproximation, rng::AbstractRNG, + g, ϕ::AbstractVector{FT}, xM::MT; + int_ϕg_ϕq::AbstractComponentArrayInterpreter, + int_ϕq::AbstractComponentArrayInterpreter, n_MC=3, cor_ends, pbm_covar_indices, is_testmode, ) where {FT,MT} # see documentation of neg_elbo_gtf - ϕc = int_μP_ϕg_unc(CA.getdata(ϕ)) - μ_ζP = CA.getdata(ϕc.μP) - ϕg = CA.getdata(ϕc.ϕg) + ϕc = int_ϕg_ϕq(CA.getdata(ϕ)) + #VT= typeof(@view(ϕ[1:1])) + ϕg = CA.getdata(ϕc[Val(:ϕg)]) + ϕq = CA.getdata(ϕc[Val(:ϕq)]) + ϕqc = int_ϕq(ϕq) + μ_ζP = CA.getdata(ϕqc[Val(:μP)]) # first pass: append μ_ζP_to covars, need ML prediction for magnitude of ζMs # TODO replace pbm_covar_indices by ComponentArray? dimensions to be type-inferred? xMP0 = _append_each_covars(xM, CA.getdata(μ_ζP), pbm_covar_indices) - μ_ζMs0 = g(xMP0, ϕg; is_testmode) - ζP_resids, ζMs_parfirst_resids, σ = sample_ζresid_norm(rng, μ_ζP, μ_ζMs0, ϕc.unc; n_MC, cor_ends, int_unc) + ϕm0 = g(xMP0, ϕg; is_testmode) + μ_ζMs0 = ϕm0 + ζP_resids, ζMs_parfirst_resids, σ = sample_ζresid_norm(approx, rng, ϕm0, ϕq; n_MC, cor_ends, int_ϕq) + ζsP = isempty(μ_ζP) ? ζP_resids : (μ_ζP .+ ζP_resids) # n_par x n_MC if pbm_covar_indices isa SA.SVector{0} # do not need to predict again but just add the residuals to μ_ζP and μ_ζMs #ζsP = μ_ζP .+ ζP_resids # n_par x n_MC # .+ on empty view does not work - ζsP = isempty(μ_ζP) ? ζP_resids : (μ_ζP .+ ζP_resids) # n_par x n_MC ζsMs = permutedims(μ_ζMs0 .+ ζMs_parfirst_resids, (2, 1, 3)) # n_site x n_par x n_MC - if any(ζsMs[:,2,:] .> 80.0) - @show ζsMs - @show ζMs_parfirst_resids - @show ϕc.unc.coef_logσ2_ζMs - error("encountered scaled residual outside envisoned range. Debug") - end + # if any(ζsMs[:,2,:] .> 80.0) + # @show ζsMs + # @show ζMs_parfirst_resids + # @show ϕc.ϕq.coef_logσ2_ζMs + # error("encountered scaled residual outside envisoned range. Debug") + # end else #rP, rMs = first(zip(eachcol(ζP_resids), eachslice(ζMs_parfirst_resids;dims=3))) - ζst = map(eachcol(ζP_resids), eachslice(ζMs_parfirst_resids; dims=3)) do rP, rMs - ζP = μ_ζP .+ rP + ζsMs_vec = map(eachcol(ζsP), eachslice(ζMs_parfirst_resids; dims=3)) do ζP, rMs # second pass: append ζP rather than μ_ζP to covars to xM xMP = _append_each_covars(xM, CA.getdata(ζP), pbm_covar_indices) - μ_ζMst = g(xMP, ϕg) + μ_ζMst = ϕm = g(xMP, ϕg; is_testmode) ζMs = (μ_ζMst .+ rMs)' # already transform to par-last form - ζP, ζMs + ζMs end # ζsP = stack(map(first, ζst); dims=1) # n_MC x n_par # ζsMs = stack(map(x -> x[2], ζst); dims=1) # n_MC x n_site x n_par - ζsP = stack(map(first, ζst)) # n_par x n_MC - ζsMs = stack(map(x -> x[2], ζst)) # n_site x n_par x n_MC + ζsMs = stack(ζsMs_vec) # n_site x n_par x n_MC end ζsP, ζsMs, σ end @@ -488,11 +564,15 @@ The output shape `(n_θ, n_site?, n_MC)` is tailored to adding `ζMs_parfirst_re ML-model predcitions of size `(n_θM, n_site)`. ## Arguments -* `int_unc`: Interpret vector as ComponentVector with components +* `int_ϕq`: Interpret vector as ComponentVector with components ρsP, ρsM, logσ2_ζP, coef_logσ2_ζMs(intercept + slope), """ -function sample_ζresid_norm(rng::Random.AbstractRNG, ζP::AbstractVector, ζMs::AbstractMatrix, - args...; n_MC, cor_ends, int_unc) +function sample_ζresid_norm(approx::AbstractHVIApproximation, rng::Random.AbstractRNG, + ϕm::AbstractMatrix, ϕq::AbstractVector, + args...; + n_MC, cor_ends, int_ϕq) + ζP = int_ϕq(CA.getdata(ϕq))[Val(:μP)] + ζMs = ϕm n_θP, n_θMs = length(ζP), length(ζMs) # intm_PMs_parfirst = !isnothing(intm_PMs_parfirst) ? intm_PMs_parfirst : begin # n_θM, n_site_batch = size(ζMs) @@ -500,49 +580,58 @@ function sample_ζresid_norm(rng::Random.AbstractRNG, ζP::AbstractVector, ζMs: # P = (n_MC, n_θP), Ms = (n_MC, n_θM, n_site_batch))) # end #urandn = _create_randn(rng, CA.getdata(ζP), n_MC, n_θP + n_θMs) - urandn = _create_randn(rng, CA.getdata(ζP), n_θP + n_θMs, n_MC) - sample_ζresid_norm(urandn, CA.getdata(ζP), CA.getdata(ζMs), args...; - cor_ends, int_unc=get_concrete(int_unc)) + #z = _create_randn(rng, CA.getdata(ζP), n_MC, n_θP) + zP = _create_randn(rng, CA.getdata(ζP), n_MC, n_θP) + zMs = _create_randn(rng, CA.getdata(ζP), n_MC, n_θMs) + sample_ζresid_norm(approx, zP, zMs, CA.getdata(ϕm), ϕq, args...; + cor_ends, + int_ϕq=get_concrete(int_ϕq) + ) end -function sample_ζresid_norm(urandn::AbstractMatrix, ζP::TP, ζMs::TM, - ϕunc::AbstractVector; - int_unc=get_concrete(ComponentArrayInterpreter(ϕunc)), +function sample_ζresid_norm(approx::MeanHVIApproximationMat, + zP::AbstractMatrix, zMs::AbstractMatrix, + ϕm::TM, ϕq::AbstractVector{T}; + int_ϕq=get_concrete(ComponentArrayInterpreter(ϕq)), cor_ends -) where {T,TP<:AbstractVector{T},TM<:AbstractMatrix{T}} - ϕuncc = int_unc(CA.getdata(ϕunc)) +) where {T,TM<:AbstractMatrix{T}} + ζMs = ϕm + ϕuncc = ϕqc = int_ϕq(CA.getdata(ϕq)) + ζP = ϕqc[Val(:μP)] n_θP, n_θMs, (n_θM, n_batch) = length(ζP), length(ζMs), size(ζMs) # do not create a UpperTriangular Matrix of an AbstractGÜUArray in transformU_cholesky1 - ρsP = isempty(ϕuncc.ρsP) ? similar(ϕuncc.ρsP) : ϕuncc.ρsP # required by zygote + ρsP = isempty(ϕuncc[Val(:ρsP)]) ? similar(ϕuncc[Val(:ρsP)]) : ϕuncc[Val(:ρsP)] # required by zygote UP = transformU_block_cholesky1(ρsP, cor_ends.P) - ρsM = isempty(ϕuncc.ρsM) ? similar(ϕuncc.ρsM) : ϕuncc.ρsM # required by zygote + ρsM = isempty(ϕuncc[Val(:ρsM)]) ? similar(ϕuncc[Val(:ρsM)]) : ϕuncc[Val(:ρsM)] # required by zygote # cholesky factor of the correlation: diag(UM' * UM) .== 1 # coefficients ρsM can be larger than 1, still yielding correlations <1 in UM' * UM UM = transformU_block_cholesky1(ρsM, cor_ends.M) - cf = ϕuncc.coef_logσ2_ζMs + cf = ϕuncc[Val(:coef_logσ2_ζMs)] logσ2_logMs = vec(cf[1, :] .+ cf[2, :] .* ζMs) - logσ2_ζP = vec(CA.getdata(ϕuncc.logσ2_ζP)) + logσ2_ζP = vec(CA.getdata(ϕuncc[Val(:logσ2_ζP)])) # CUDA cannot multiply BlockDiagonal * Diagonal, construct already those blocks σMs = reshape(exp.(logσ2_logMs ./ 2), n_θM, :) σP = exp.(logσ2_ζP ./ 2) # BlockDiagonal does work with CUDA, but not with combination of Zygote and CUDA # need to construct full matrix for CUDA - Uσ = _create_blockdiag(UP, UM, σP, σMs, n_batch) # inferred only BlockDiagonal - σ = diag(Uσ)::typeof(σP) # elements of the diagonal: standard deviations - n_MC = size(urandn, 2) # TODO transform urandn + Uσ, diagUσ = _compute_choleskyfactor(UP, UM, σP, σMs, n_batch) # inferred only BlockDiagonal + #diagUσ = diag(Uσ)::typeof(σP) # elements of the diagonal: standard deviations + n_MC = size(zP, 1) # is this multiplication efficient if Uσ is not concrete but only sumtype BlockDiagonal? - ζ_resids_parfirst = (Uσ' * urandn) #::typeof(urandn) # n_par x n_MC + urandn = hcat(zP, zMs) + ζ_resids_parfirst = (Uσ' * urandn') #::typeof(urandn) # n_par x n_MC + #ζ_resids_parfirst = (urandn * Uσ)' #::typeof(urandn) # n_par x n_MC #ζ_resids_parfirst = urandn' * Uσ # n_MC x n_par # need to handle empty(ζP) explicitly, otherwise Zygote tries to take gradient ζP_resids = isempty(ζP) ? ζ_resids_parfirst[1:0, :] : ζ_resids_parfirst[1:n_θP, :] ζMs_parfirst_resids = reshape(ζ_resids_parfirst[(n_θP+1):end, :], n_θM, n_batch, n_MC) - ζP_resids, ζMs_parfirst_resids, σ + ζP_resids, ζMs_parfirst_resids, diagUσ # #map(std, eachcol(ζ_resids_parfirst[:, 3:8])) # ζ_resid = transpose_mPMs_sitefirst(ζ_resids_parfirst; intm_PMs_parfirst) # #map(std, eachcol(ζ_resid[:, 3:8])) # all ~ 0.1 in sample_ζresid_norm cpu # #map(std, eachcol(ζ_resid[:, 2 + n_batch .+ (-1:5)])) # all ~ 100, except first two # # returns AbstractGPUuArrays to either continue on GPU or need to transfer to CPU - # ζ_resid, σ + # ζ_resid, diagUσ end """ @@ -571,6 +660,9 @@ function transpose_mPMs_sitefirst(Xt; # map(std, eachrow(tmp[3:8,:])) # _Ms = permutedims(Xtc.Ms, (1, 3, 2)) + #Main.@infiltrate_main + #tmp = Test.@inferred getindex(Xtc, Val(:Ms)) + #tmp2= Test.@inferred getindex(Xtc, Val(:P)) X_site_first = CA.ComponentVector(P=Xtc.P, Ms=permutedims(Xtc.Ms, (1, 3, 2))) reshape(CA.getdata(X_site_first), size(Xt))::typeof(CA.getdata(Xt)) # X_site_first = CA.ComponentVector( @@ -578,16 +670,35 @@ function transpose_mPMs_sitefirst(Xt; # reshape(CA.getdata(X_site_first), rev(size(Xt)))::typeof(CA.getdata(Xt)) end -function _create_blockdiag(UP::AbstractMatrix{T}, UM, σP, σMs, n_batch) where {T} +""" +Create Cholesky-factor of Covariance matrix. +from Cholesky-factors of correlation matrices (UP, UM) and diagonal sqrt(variances) (σP, σMs) +Return this factor and its diagonal +""" +function _compute_choleskyfactor(UP::AbstractMatrix{T}, UM, σP, σMs, n_batch) where {T} # v = if isempty(UP) # [UM * Diagonal(σMs[:, i]) for i in 1:n_batch] #::Vector{<:AbstractMatrix{T}} # else # [i == 0 ? UP * Diagonal(σP) : UM * Diagonal(σMs[:, i]) for i in 0:n_batch] #::Vector{<:AbstractMatrix{T}} # end - v = [i == 0 ? UP * Diagonal(σP) : UM * Diagonal(σMs[:, i]) for i in 0:n_batch] - BlockDiagonal(v) + Uσ_blocks = [i == 0 ? UP * Diagonal(σP) : UM * Diagonal(σMs[:, i]) for i in 0:n_batch] + # vcat not type stable + #Uσ_blocks = vcat([UP * Diagonal(σP)], [UM * Diagonal(σMs[:, i]) for i in 1:n_batch]) + Uσ = BlockDiagonal(Uσ_blocks) + # diag(Uσ) is a performance bottleneck, therefore construct explicitly + #diagUσ = [i == 0 ? diag(UP) .* σP : diag(UM) .* σMs[:, i] for i in 0:n_batch] + # not type stable diagUσM = reduce(vcat, Tuple(diag(UM) .* σMs[:, i] for i in 1:n_batch); init = σP[1:0]) + #diagUσM = reduce(vcat, [diag(UM) .* σMs[:, i] for i in 1:n_batch]; init = σMs[1:0]) + empty_arr = ChainRulesCore.@ignore_derivatives eltype(σMs)[] + #diagUσM = reduce(vcat, [diag(UM) .* σMs[:, i] for i in 1:n_batch]; init=empty_arr) + #diag U = ones -> diag Uσ = σ + # diagUσM = vcat([diag(UM) .* σMs[:, i] for i in 1:n_batch]...)::Vector{T} + # diagUσ = vcat(diag(UP) .* σP, diagUσM) + diagUσ = vcat(σP, vec(σMs)) + # diagUσ == diag(Uσ) + Uσ, diagUσ end -function _create_blockdiag( +function _compute_choleskyfactor( UP::GPUArraysCore.AbstractGPUMatrix{T}, UM, σP, σMs, n_batch) where {T} # using BlockDiagonal leads to Scalar operations downstream # v = [i == 0 ? UP * Diagonal(σP) : UM * Diagonal(σMs[:, i]) for i in 0:n_batch] @@ -600,13 +711,16 @@ function _create_blockdiag( # else # cat([i == 0 ? UP : UM for i in 0:n_batch]...; dims=(1, 2)) # end - U = cat([i == 0 ? UP : UM for i in 0:n_batch]...; dims=(1, 2)) + #U = cat([i == 0 ? UP : UM for i in 0:n_batch]...; dims=(1, 2)) + #U = cat(UP,[UM for i in 1:n_batch]...; dims=(1, 2)) # Zygote not work with generator + U = cat(UP,Tuple(UM for i in 1:n_batch)...; dims=(1, 2)) # Zygote not work with generator #Main.@infiltrate_main σD = Diagonal(vcat(σP, vec(σMs))) Uσ = U * σD # need for Zygote why? - # tmp = cat(Uσ; dims=(1,2)) - tmp = vcat(Uσ) + B = vcat(Uσ) + diagUσ = diag(B) + B, diagUσ end # TODO replace by KA.rand when it becomes available, see ones_similar @@ -626,7 +740,6 @@ Transform parameters and compute absolute of determinant of Jacobian of the tran function transform_and_logjac_ζ(ζP::AbstractVector, ζMs::AbstractMatrix; transP::Bijectors.Transform, transMs::StackedArray=StackedArray(transM, size(ζMs, 1))) - θP, logjac_P = Bijectors.with_logabsdet_jacobian(transP, ζP) θMs, logjac_M = Bijectors.with_logabsdet_jacobian(transMs, ζMs) # if !all(isfinite.(θMs)) # @show θMs @@ -640,8 +753,14 @@ function transform_and_logjac_ζ(ζP::AbstractVector, ζMs::AbstractMatrix; # due to sampling they might exceed the range θMs = min.(sqrt(floatmax(eltype(θMs))), θMs) θMs = max.(sqrt(floatmin(eltype(θMs))), θMs) - θP = min.(sqrt(floatmax(eltype(θP))), θP) - θP = max.(sqrt(floatmin(eltype(θP))), θP) + θP, logjac_P = if isempty(ζP) + ζP, zero(logjac_M) + else + θP, logjac_P = Bijectors.with_logabsdet_jacobian(transP, ζP) + θP = min.(sqrt(floatmax(eltype(θP))), θP) + θP = max.(sqrt(floatmin(eltype(θP))), θP) + θP, logjac_P + end θP, θMs, logjac_P + logjac_M end diff --git a/src/elbo2.jl b/src/elbo2.jl new file mode 100644 index 0000000..7561159 --- /dev/null +++ b/src/elbo2.jl @@ -0,0 +1,107 @@ +# Re-Implementation of MeanHVIApproximationVec where random numbers are +# generated for each block in the correlation matrix separately. +# +# Unfortunately, having many smaller matrix multiplications, the derivative +# computation is slower than with +# one big matrix multiplication of the big sparse blocked covariance matrix. +# As benchmarked 251121 for 20 sites in test_sample_zeta. +# Both on cpu and gpu +# +# For a large number of sites in a forward run across all sites +# this implementation is faster on gpu, but slower than the Vec +# implementation on CPU (that uses triangular and blocked matrices) +# +# Hence, currently, rather use the MeanHVIApproximationVec CPU implementation. +# for gradient on few sites (1.6ms cpu vs 5.4ms gpu) +# and forward runs for many sites (760mus cpu vs 439ms gpu unit!) + +function sample_ζresid_norm(app::MeanHVIApproximation, + zP::AbstractMatrix, zMs::AbstractMatrix, + ϕm::TM, ϕq::AbstractVector{T}; + int_ϕq=get_concrete(ComponentArrayInterpreter(ϕq)), + cor_ends +) where {T,TM<:AbstractMatrix{T}} + ζMs = ϕm + ϕunc = CA.getdata(ϕq) + ϕuncc = ϕqc = int_ϕq(ϕunc) + ζP = ϕqc[Val(:μP)] + n_θP, n_θMs, (n_θM, n_batch), n_MC = length(ζP), length(ζMs), size(ζMs), size(zP,1) + # do not create a UpperTriangular Matrix of an AbstractGÜUArray in transformU_cholesky1 + ρsP = isempty(ϕuncc[Val(:ρsP)]) ? similar(ϕuncc[Val(:ρsP)]) : ϕuncc[Val(:ρsP)] # required by zygote + UPs, rangesP = transformU_blocks_cholesky1(ρsP, cor_ends.P) + ρsM = isempty(ϕuncc[Val(:ρsM)]) ? similar(ϕuncc[Val(:ρsM)]) : ϕuncc[Val(:ρsM)] # required by zygote + # cholesky factor of the correlation: diag(UM' * UM) .== 1 + # coefficients ρsM can be larger than 1, still yielding correlations <1 in UM' * UM + UMs, rangesM = transformU_blocks_cholesky1(ρsM, cor_ends.M) + cf = ϕuncc[Val(:coef_logσ2_ζMs)] + logσ2_logMs = vec(cf[1, :] .+ cf[2, :] .* ζMs) + logσ2_ζP = vec(CA.getdata(ϕuncc[Val(:logσ2_ζP)])) + # CUDA cannot multiply BlockDiagonal * Diagonal, construct already those blocks + σMs = reshape(exp.(logσ2_logMs ./ 2), n_θM, :) + σP = exp.(logσ2_ζP ./ 2) + # create random numbers from U diag(σ) z = U (σ .* z) + # for each block separately + #Ui, ri = first(zip(UPs, rangesP)) + ζP1 = ChainRulesCore.@ignore_derivatives similar(CA.getdata(ϕunc), size(zP')) + #@benchmark typeof(zP .* ϕq[1:1]) # more allocations and more time + local ζP_resids = if isempty(ζP) + ζP1 # provide init of correct empty matrix type + else + mapreduce(vcat, UPs, rangesP) do Ui, ri + Diagonal(σP[ri]) * Ui' * zP[:,ri]' + end + end::typeof(ζP1) + # + #Ui, ri = first(zip(UMs, rangesM)) + zMs_subjects = reshape(zMs, (n_MC, n_θM, n_batch)) + #σM, zM = first(zip(eachcol(σMs), eachslice(zMs_subjects; dims=3))) + cat3 = (x,y) -> cat(x,y,dims=3) + # map across subjects (n_batch) + #ζMs_vec = map(eachcol(σMs), eachslice(zMs_subjects; dims=3)) do σM, zM + ζMs1 = ChainRulesCore.@ignore_derivatives similar(ϕunc, size(zMs_subjects[:,:,1]')) + fBlock = let UMs = UMs, rangesM = collect(rangesM) # without collect, type unstable + function fBlock_inner(σM, zM)::typeof(ζMs1) + # generator does not work with Zygote + # vcat(...) is not faster than mapreduce + # g = map( UMs, rangesM) do Ui, ri # n_θM, n_MC + # #(zM[:,ri]' * Ui * diagm(σM[ri]))' + # diagm(σM[ri]) * Ui' * zM[:, ri]' + # end + # vcat(g...) + mapreduce(vcat, UMs, rangesM) do Ui, ri # n_θM, n_MC + # (zM[:,ri]' * (Ui * Diagonal(σM[ri])))' + # Diagonal is faster than diagm and works with GPU + Diagonal(σM[ri]) * Ui' * zM[:, ri]' # transpose to not return adjoint + end + end + end + #ζMs1 = ChainRulesCore.@ignore_derivatives fBlock(σMs[:,1], zMs_subjects[:,:,1]) + #TMR = ChainRulesCore.@ignore_derivatives typeof(similar(ϕq, size(zMs))) + #TB = Base.infer_return_type(fBlock, (typeof(σMs[:,1]), typeof(zMs_subjects[:,:,1]))) + #ζMs_vec = map(fBlock, eachcol(σMs[:,2:end]), eachslice(zMs_subjects[:,:,2:end]; dims=3), init = ζMs1) + #ζMs_vec = map((σM, zM) -> fBlock(σM, zM)::TMR, eachcol(σMs), eachslice(zMs_subjects; dims=3)) + ζMs_vec = map((σM, zM) -> fBlock(σM, zM), eachcol(σMs), eachslice(zMs_subjects; dims=3)) + #zM = zMs_subjects[:,:,1] + #ζMs_vec = [fBlock(σMs[:,i], zM) for i in axes(σMs, 2)] + #ζMs_vec = [fBlock(σMs[:,1], zM)] + #ζMs_vec = [fBlock(σMs[:,1], zM) for i in 1:n_batch] + #ζMs_vec = [fBlock(σMs[:,1], zM) for i in axes(σMs, 2)] + #ζMs_vec = [fBlock(σM, zM) for (σM, zM) in zip(eachcol(σMs), eachslice(zMs_subjects; dims=3))] + # concatenate so that n_MC is last dimension + local ζMs_parfirst_resids = stack(ζMs_vec; dims = 2 ) # n_θM, n_batch, n_MC + #size(ζMs_parfirst_resids) + + # std(ζMs_parfirst_resids[1,1,:]) + # std(ζMs_parfirst_resids[1,end,:]) + # σzMs_stacked = reshape(σzMs, (n_θM, n_batch * n_MC)) + # ζMs_resids_stacked = mapreduce(vcat, UMs, rangesM) do Ui, ri + # #Ui * σzMs_stacked[ri, :] + # Uσ = Ui * σMs[ri,:] + # Uσ' * zMs[:,ri]' + # diagm(σMs[ri,:]) * Ui' * zMs[:,ri]' + # end + # ζMs_parfirst_resids = reshape(ζMs_resids_stacked, n_θM, n_batch, n_MC) + # + diagUσ = vcat(σP, vec(σMs)) + ζP_resids, ζMs_parfirst_resids, diagUσ +end diff --git a/src/elbo_dev.jl b/src/elbo_dev.jl new file mode 100644 index 0000000..e69de29 diff --git a/src/gf.jl b/src/gf.jl index a575238..df4e27b 100644 --- a/src/gf.jl +++ b/src/gf.jl @@ -86,8 +86,9 @@ function predict_point_hvi(rng, prob::AbstractHybridProblem; scenario=Val(()), xP = isnothing(xP) ? xP_dl : xP end y_pred, θMs, θP = gf(prob, xM, xP; scenario, gdevs, is_testmode, kwargs...) - θPc = ComponentArrayInterpreter(prob.θP)(θP) - θMsc = ComponentArrayInterpreter((size(θMs,1),), prob.θM)(θMs) + pt = get_hybridproblem_par_templates(prob) + θPc = ComponentArrayInterpreter(pt.θP)(θP) + θMsc = ComponentArrayInterpreter((size(θMs,1),), pt.θM)(θMs) (;y_pred, θMs=θMsc, θP=θPc) end @@ -120,13 +121,14 @@ function gf(prob::AbstractHybridProblem, xM::AbstractMatrix, xP::AbstractMatrix; else f_dev = f end - (; θP, θM) = get_hybridproblem_par_templates(prob; scenario) + pt = get_hybridproblem_par_templates(prob; scenario) (; transP, transM) = get_hybridproblem_transforms(prob; scenario) transMs = StackedArray(transM, n_site_pred) - intP = ComponentArrayInterpreter(θP) + intP = ComponentArrayInterpreter(pt.θP) pbm_covars = get_hybridproblem_pbmpar_covars(prob; scenario) pbm_covar_indices = CA.getdata(intP(1:length(intP))[pbm_covars]) - ζP = inverse(transP)(θP) + ϕq = get_hybridproblem_ϕq(prob; scenario) + ζP = ϕq[Val(:μP)]; gdev, cdev = gdevs.gdev_M, infer_cdev(gdevs) g_dev, ϕg_dev, xM_dev, ζP_dev = gdev(g), gdev(ϕg), gdev(CA.getdata(xM)), gdev(CA.getdata(ζP)) # most of the properties of prob are not type-inferred @@ -180,8 +182,8 @@ Provide a `transMs = StackedArray(transM, n_batch)` function gtrans(g, transMs, xMP, ϕg; cdev, is_testmode) # TODO remove after removing gf # predict the log of the parameters - ζMst = g(xMP, ϕg; is_testmode) - ζMs = ζMst' + ϕg = g(xMP, ϕg; is_testmode) + ζMs = ϕg' ζMs_cpu = cdev(ζMs) θMs = transMs(ζMs_cpu) if !all(isfinite.(θMs)) @@ -229,17 +231,20 @@ function get_loss_gf(g, transM, transP, f, py, intϕ(1:length(intϕ)).ϕP); cdev=cpu_device(), pbm_covars, n_site_batch, - priorsP, priorsM, floss_penalty = zero_penalty_loss, - is_omit_priors = false, - kwargs...) + floss_penalty = zero_penalty_loss, + priorsP, priorsM, + is_omit_priors::Val = Val(false), + zero_prior_logdensity, + kwargs...) let g = g, transM = transM, transP = transP, f = f, intϕ = get_concrete(intϕ), transMs = StackedArray(transM, n_site_batch), - is_omit_priors = is_omit_priors, cdev = cdev, pbm_covar_indices = CA.getdata(intP(1:length(intP))[pbm_covars]), - priorsP = priorsP, priorsM = priorsM, floss_penalty = floss_penalty, + zero_prior_logdensity = zero_prior_logdensity, is_omit_priors = is_omit_priors, + priorsP = priorsP, priorsM = priorsM, + floss_penalty = floss_penalty, cpu_dev = cpu_device() # real cpu, different form infer_cdev(gdevs) that maybe idenetity #, intP = get_concrete(intP) #inv_transP = inverse(transP), kwargs = kwargs @@ -272,36 +277,17 @@ function get_loss_gf(g, transM, transP, f, py, logpdf_tv = (prior, θ::AbstractVector) -> begin map(Base.Fix1(logpdf, prior), θ)::Vector{eltype(θP_pred)} end - #Main.@infiltrate_main - #Maybe: move priors to GPU, for now need to move θ to cpu - # currently does not work on gpu, moving to dpu has problems with gradient - # need to specify is_omit_priors if PBM is on GPU - neg_log_prior = if is_omit_priors - zero(nLy) - else - nLP = if isempty(θP_pred) - zero(nLy) - else - θP_pred_cpu = CA.getdata(θP_pred) - -sum(logpdf_t.(priorsP, θP_pred_cpu)) - end - θMs_pred_cpu = CA.getdata(θMs_pred) - nLM = -sum(map((priorMi, θMi) -> sum( - logpdf_tv(priorMi, θMi)), priorsM, eachcol(θMs_pred_cpu))) - nLP + nLM - end - # neg_log_prior = is_omit_priors ? zero(nLy) : - # (isempty() ? zero(nLy) : ) + - # -sum(map((priorMi, θMi) -> sum( - # logpdf_tv(priorMi, θMi)), priorsM, eachcol(θMs_pred_cpu))) - #neg_log_prior = min(sqrt(floatmax(neg_log_prior0)), neg_log_prior0) + neg_log_prior = + # @descend_code_warntype ( + compute_priors_logdensity(priorsP, priorsM, θP_pred, θMs_pred, + is_omit_priors, zero_prior_logdensity) if !isfinite(neg_log_prior) @info "loss_gf: encountered non-finite prior density" @show θP_pred, θMs_pred, ϕc.ϕP error("debug get_loss_gf") end - ϕunc = eltype(θP_pred)[] # no uncertainty parameters optimized - loss_penalty = floss_penalty(y_pred, θMs_pred, θP_pred, ϕc.ϕg, ϕunc) + ϕq = eltype(θP_pred)[] # no uncertainty parameters optimized + loss_penalty = floss_penalty(y_pred, θMs_pred, θP_pred, ϕc.ϕg, ϕq) #@show nLy, neg_log_prior, loss_penalty nLjoint_pen = nLy + neg_log_prior + loss_penalty return (;nLjoint_pen, y_pred, θMs_pred, θP_pred, nLy, neg_log_prior, loss_penalty) diff --git a/src/hybridprobleminterpreters.jl b/src/hybridprobleminterpreters.jl deleted file mode 100644 index cf39ea8..0000000 --- a/src/hybridprobleminterpreters.jl +++ /dev/null @@ -1,63 +0,0 @@ -abstract type AbstractHybridProblemInterpreters end - -struct HybridProblemInterpreters{AXP, AXM, NS, NB} <: AbstractHybridProblemInterpreters -end; - -const HPInts = HybridProblemInterpreters - -# function get_hybridproblem_statics(prob::AbstractHybridProblem, scenario) -# θP, θM = get_hybridproblem_par_templates(prob; scenario) -# NS, NB = get_hybridproblem_n_site_and_batch(prob; scenario) -# (CA.getaxes(θP), CA.getaxes(θM), NS, NB) -# end - -function HybridProblemInterpreters(prob::AbstractHybridProblem; scenario::Val) - # make sure interred get_hybridproblem_par_templates and n_site_and_n_batch - # error("'HybridProblemInterpreters(prob::AbstractHybridProblem; scenario)'", - # "is not inferred at caller level. Replace by ", - # "'HybridProblemInterpreters{get_hybridproblem_statics(prob; scenario)...}()'") - θP, θM = get_hybridproblem_par_templates(prob; scenario) - NS, NB = get_hybridproblem_n_site_and_batch(prob; scenario) - HybridProblemInterpreters{CA.getaxes(θP), CA.getaxes(θM), NS, NB}() -end - -function get_int_P(::HPInts{AXP}) where AXP - StaticComponentArrayInterpreter{AXP}() -end -function get_int_M(::HPInts{AXP,AXM}) where {AXP,AXM} - StaticComponentArrayInterpreter{AXM}() -end -function get_int_Ms_batch(ints::HPInts{AXP,AXM, NS, NB}) where {AXP,AXM,NS,NB} - StaticComponentArrayInterpreter(AXM, (NB,)) -end -function get_int_Mst_batch(ints::HPInts{AXP,AXM, NS, NB}) where {AXP,AXM,NS,NB} - StaticComponentArrayInterpreter((NB,), AXM) -end -function get_int_Ms_site(ints::HPInts{AXP,AXM, NS, NB}) where {AXP,AXM,NS,NB} - StaticComponentArrayInterpreter(AXM, (NS,)) -end -function get_int_Mst_site(ints::HPInts{AXP,AXM, NS, NB}) where {AXP,AXM,NS,NB} - StaticComponentArrayInterpreter((NS,), AXM) -end - -function get_int_PMs_batch(ints::HPInts{AXP,AXM, NS, NB}) where {AXP,AXM,NS,NB} - AX_MS = CA.getaxes(get_int_Ms_batch(ints)) - AX_PMs = compose_axes((;P=AXP, Ms=AX_MS)) - StaticComponentArrayInterpreter{(AX_PMs,)}() -end -function get_int_PMst_batch(ints::HPInts{AXP,AXM, NS, NB}) where {AXP,AXM,NS,NB} - AX_MS = CA.getaxes(get_int_Mst_batch(ints)) # note the t after Ms - AX_PMs = compose_axes((;P=AXP, Ms=AX_MS)) - StaticComponentArrayInterpreter{(AX_PMs,)}() -end -function get_int_PMs_site(ints::HPInts{AXP,AXM, NS, NB}) where {AXP,AXM,NS,NB} - AX_MS = CA.getaxes(get_int_Ms_site(ints)) - AX_PMs = compose_axes((;P=AXP, Ms=AX_MS)) - StaticComponentArrayInterpreter{(AX_PMs,)}() -end -function get_int_PMst_site(ints::HPInts{AXP,AXM, NS, NB}) where {AXP,AXM,NS,NB} - AX_MS = CA.getaxes(get_int_Mst_site(ints)) # note the t after Ms - AX_PMs = compose_axes((;P=AXP, Ms=AX_MS)) - StaticComponentArrayInterpreter{(AX_PMs,)}() -end - diff --git a/src/init_hybrid_params.jl b/src/init_hybrid_params.jl index a1567a0..bd9473b 100644 --- a/src/init_hybrid_params.jl +++ b/src/init_hybrid_params.jl @@ -22,61 +22,73 @@ Returns a NamedTuple of because this direction is used much more often. - `ϕunc0` initial uncertainty parameters, ComponentVector with format of `init_hybrid_ϕunc.` """ -function init_hybrid_params(θP::AbstractVector{FT}, θM::AbstractVector{FT}, - cor_ends::NamedTuple, ϕg::AbstractVector{FT}, hpints::HybridProblemInterpreters; - transP = elementwise(identity), transM = elementwise(identity), - ϕunc0 = init_hybrid_ϕunc(cor_ends, zero(FT))) where {FT} - n_θP = length(θP) - n_θM = length(θM) - @assert cor_ends.P[end] == n_θP - @assert cor_ends.M[end] == n_θM - n_ϕg = length(ϕg) - # check translating parameters - can match length? - _ = Bijectors.inverse(transP)(θP) - _ = Bijectors.inverse(transM)(θM) - ϕ = CA.ComponentVector(; - μP = apply_preserve_axes(inverse(transP), θP), - ϕg = ϕg, - unc = ϕunc0) - # - # get_transPMs = let transP = transP, transM = transM, n_θP = n_θP, n_θM = n_θM - # function get_transPMs_inner(n_site) - # transMs = ntuple(i -> transM, n_site) - # ranges = vcat( - # [1:n_θP], [(n_θP + i0 * n_θM) .+ (1:n_θM) for i0 in 0:(n_site - 1)]) - # transPMs = Stacked((transP, transMs...), ranges) - # transPMs - # end - # end - get_transPMs = transPMs_batch = Val(Symbol("deprecated , use stack_ca_int(intPMs)")) - #transPMs_batch = get_transPMs(n_batch) - # ranges = (P = 1:n_θP, ϕg = n_θP .+ (1:n_ϕg), unc = (n_θP + n_ϕg) .+ (1:length(ϕunc0))) - # inv_trans_gu = Stacked( - # (inverse(transP), elementwise(identity), elementwise(identity)), values(ranges)) - # ϕ = inv_trans_gu(CA.getdata(ϕt)) - get_ca_int_PMs = Val(Symbol("deprecated , use get_int_PMst_site(HybridProblemInterpreters(prob; scenario))")) - # get_ca_int_PMs = let - # function get_ca_int_PMs_inner(n_site) - # ComponentArrayInterpreter(CA.ComponentVector(; P = θP, - # Ms = CA.ComponentMatrix( - # zeros(n_θM, n_site), first(CA.getaxes(θM)), CA.Axis(i = 1:n_site)))) - # end - # end +function init_hybrid_params(ϕg::AbstractVector{FT}, ϕq::AbstractVector{FT}) where {FT} + ϕ = CA.ComponentVector(; ϕg, ϕq) interpreters = map(get_concrete, (; - μP_ϕg_unc = ComponentArrayInterpreter(ϕ), - PMs = get_int_PMst_batch(hpints), - unc = ComponentArrayInterpreter(ϕunc0) + ϕg_ϕq = ComponentArrayInterpreter(ϕ), + ϕq = ComponentArrayInterpreter(ϕq) )) - (; ϕ, transPMs_batch, interpreters, get_transPMs, get_ca_int_PMs) + (; ϕ, interpreters) end +# function init_hybrid_params_old(θP::AbstractVector{FT}, θM::AbstractVector{FT}, +# cor_ends::NamedTuple, ϕg::AbstractVector{FT}, hpints::HybridProblemInterpreters; +# transP = elementwise(identity), transM = elementwise(identity), +# ϕunc0 = init_hybrid_ϕunc(cor_ends, zero(FT))) where {FT} +# n_θP = length(θP) +# n_θM = length(θM) +# @assert cor_ends.P[end] == n_θP +# @assert cor_ends.M[end] == n_θM +# n_ϕg = length(ϕg) +# # check translating parameters - can match length? +# _ = Bijectors.inverse(transP)(θP) +# _ = Bijectors.inverse(transM)(θM) +# # TODO add and test θP +# ϕq = update_μP_by_θP(ϕunc0, θP, transP) +# ϕ = CA.ComponentVector(; ϕg, ϕq) +# # +# # get_transPMs = let transP = transP, transM = transM, n_θP = n_θP, n_θM = n_θM +# # function get_transPMs_inner(n_site) +# # transMs = ntuple(i -> transM, n_site) +# # ranges = vcat( +# # [1:n_θP], [(n_θP + i0 * n_θM) .+ (1:n_θM) for i0 in 0:(n_site - 1)]) +# # transPMs = Stacked((transP, transMs...), ranges) +# # transPMs +# # end +# # end +# get_transPMs = transPMs_batch = Val(Symbol("deprecated , use stack_ca_int(intPMs)")) +# #transPMs_batch = get_transPMs(n_batch) +# # ranges = (P = 1:n_θP, ϕg = n_θP .+ (1:n_ϕg), unc = (n_θP + n_ϕg) .+ (1:length(ϕunc0))) +# # inv_trans_gu = Stacked( +# # (inverse(transP), elementwise(identity), elementwise(identity)), values(ranges)) +# # ϕ = inv_trans_gu(CA.getdata(ϕt)) +# get_ca_int_PMs = Val(Symbol("deprecated , use get_int_PMst_site(HybridProblemInterpreters(prob; scenario))")) +# # get_ca_int_PMs = let +# # function get_ca_int_PMs_inner(n_site) +# # ComponentArrayInterpreter(CA.ComponentVector(; P = θP, +# # Ms = CA.ComponentMatrix( +# # zeros(n_θM, n_site), first(CA.getaxes(θM)), CA.Shaped1DAxis((n_site,))))) +# # end +# # end +# interpreters = map(get_concrete, +# (; +# ϕg_ϕq = ComponentArrayInterpreter(ϕ), +# PMs = get_int_PMst_batch(hpints), +# ϕq = ComponentArrayInterpreter(ϕq) +# )) +# (; ϕ, transPMs_batch, interpreters, get_transPMs, get_ca_int_PMs) +# end + """ - init_hybrid_ϕunc(cor_ends, ρ0=0f0; logσ2_ζP, coef_logσ2_ζMs, ρsP, ρsM) + init_hybrid_ϕunc(approx::AbstractHVIApproximation, cor_ends, ρ0=0f0; + logσ2_ζP, coef_logσ2_ζMs, ρsP, ρsM) Initialize vector of additional parameter of the approximate posterior. Arguments: +- `approx`: AbstractMeanHVIApproximation, which is used. Parametrization will + differ depending on the approximation. - `cor_ends`: NamedTuple with entries, `P`, and `M`, respectively with integer vectors of ending columns of parameters blocks - `ρ0`: default entry for ρsP and ρsM, defaults = 0f0. @@ -91,6 +103,7 @@ Returns a `ComponentVector` of of the correlation matrices of ζP and ζM, default to all entries `ρ0`, which defaults to zero. """ function init_hybrid_ϕunc( + approx::AbstractMeanHVIApproximation, cor_ends::NamedTuple, ρ0::FT = 0.0f0, coef_logσ2_logM::AbstractVector{FT} = FT[-10.0, 0.0]; diff --git a/src/util_ca.jl b/src/util_ca.jl index c378582..6d4989b 100644 --- a/src/util_ca.jl +++ b/src/util_ca.jl @@ -17,6 +17,12 @@ as in `ca`. function apply_preserve_axes(f, ca::CA.ComponentArray) CA.ComponentArray(f(CA.getdata(ca)), CA.getaxes(ca)) end +# special case of empty Sub-ComponentVector +# apply_preserve_axes(identity, CA.ComponentVector(a=1, b=CA.ComponentVector()).b) +function apply_preserve_axes(f, ca::AbstractArray) + @assert isempty(ca) + CA.ComponentVector() +end """ compose_axes(axtuples::NamedTuple) diff --git a/src/util_opt.jl b/src/util_opt.jl index 2baf742..311a46f 100644 --- a/src/util_opt.jl +++ b/src/util_opt.jl @@ -1,23 +1,25 @@ """ create a function (state, l) -> false that prints iter and loss each moditer """ -callback_loss = (moditer) -> let iter = 1, moditer = moditer +callback_loss = (moditer) -> let moditer = moditer function (state, l) - if iter % moditer == 1 - println("$iter, $l") + if state.iter % moditer == 1 + println("$(state.iter), $l") end - iter = iter + 1 + # if state.iter >= 892 + # println("$(state.iter)") + # error("stacktrace") + # end return false end end -callback_loss_fstate = (moditer, fstate) -> let iter = 1, moditer = moditer, fstate = fstate +callback_loss_fstate = (moditer, fstate) -> let moditer = moditer, fstate = fstate function (state, l) - if iter % moditer == 1 + if state.iter % moditer == 1 res_state = fstate(state) - println("$iter, $l, $res_state") + println("$(state.iter), $l, $res_state") end - iter = iter + 1 return false end end diff --git a/test/Project.toml b/test/Project.toml index 0832140..c78503d 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -27,5 +27,6 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" StatsFuns = "4c63d2b9-4356-54db-8cca-17b64c39e42c" Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed" Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" cuDNN = "02a925ec-e4fe-4b08-9a7e-0d78e3d38ccd" diff --git a/test/runtests.jl b/test/runtests.jl index 52c7e2c..0d110ed 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -15,8 +15,6 @@ const GROUP = get(ENV, "GROUP", "All") # defined in in CI.yml @time @safetestset "test_util_gpu" include("test_util_gpu.jl") #@safetestset "test" include("test/test_ComponentArrayInterpreter.jl") @time @safetestset "test_ComponentArrayInterpreter" include("test_ComponentArrayInterpreter.jl") - #@safetestset "test" include("test/test_hybridprobleminterpreters.jl") - @time @safetestset "test_hybridprobleminterpreters" include("test_hybridprobleminterpreters.jl") #@safetestset "test" include("test/test_PBMApplicator.jl") @time @safetestset "test_PBMApplicator" include("test_PBMApplicator.jl") #@safetestset "test" include("test/test_ModelApplicator.jl") diff --git a/test/test_ComponentArrayInterpreter.jl b/test/test_ComponentArrayInterpreter.jl index 9c2d6ae..8173ddf 100644 --- a/test/test_ComponentArrayInterpreter.jl +++ b/test/test_ComponentArrayInterpreter.jl @@ -254,13 +254,13 @@ end; v = collect(1:length(cai)) cv = cai(v) - cv2 = @inferred CP.tmpf(v; cv) # cai by keyword argument + cv2 = @inferred CP.test_apply_cai(v; cv) # cai by keyword argument #cv2 = @inferred CP.tmpf(v; cv=nothing, cai = cai0) # not inferred - cv2 = CP.tmpf(v; cv=nothing, cai = cai0) # not inferred - cv2 = @inferred CP.tmpf1(v; cai = get_concrete(cai0)) # cai by keyword argument + cv2 = CP.test_apply_cai(v; cv=nothing, cai = cai0) # not inferred + cv2 = @inferred CP.test_apply_cai1(v; cai = get_concrete(cai0)) # cai by keyword argument #cv2 = @inferred CP.tmpf1(v; cai = cai0) # inside function does not infer - cv2 = CP.tmpf1(v; cai = cai0) # get_concrete inside function does not infer outside - cv2 = @inferred CP.tmpf2(v; cai=cai0) # only when specifying return type + cv2 = CP.test_apply_cai1(v; cai = cai0) # get_concrete inside function does not infer outside + cv2 = @inferred CP.test_apply_cai2(v; cai=cai0) # only when specifying return type # () -> begin # #cv2 = @code_warntype CP.tmpf(cai0) # Any # #cv2 = @code_warntype CP.tmpf(cai) # ok diff --git a/test/test_HybridProblem.jl b/test/test_HybridProblem.jl index c7bb04e..7505d41 100644 --- a/test/test_HybridProblem.jl +++ b/test/test_HybridProblem.jl @@ -1,6 +1,7 @@ using Test using HybridVariationalInference using HybridVariationalInference: HybridVariationalInference as CP +using UnPack using StableRNGs using Random using Statistics @@ -19,9 +20,12 @@ using Suppressor using Functors + cdev = cpu_device() -#scenario = Val((:default,)) +#problems with last(()) scenario = Val(()) +#scenario = Val((:default, )) +#scenario = Val((:MeanHVIApproxMat,)) #scenario = Val((:covarK2,)) #scen = CP._val_value(scenario) @@ -69,26 +73,33 @@ function construct_problem(; scenario::Val{scen}) where scen # end # end train_dataloader = MLUtils.DataLoader( - (xM, xP, y_o, y_unc, i_sites), batchsize=n_batch, partial=false) + (CA.getdata(xM), CA.getdata(xP), y_o, y_unc, i_sites), batchsize=n_batch, partial=false) θall = vcat(θP, θM) priors_dict = Dict{Symbol, Distribution}( keys(θall) .=> fit.(LogNormal, θall, QuantilePoint.(θall .* 3, 0.95))) priors_dict[:r1] = fit(Normal, θall.r1, qp_uu(3 * θall.r1), Val(:mode)) # not transformed to log-scale # scale (0,1) outputs MLmodel to normal distribution fitted to priors translated to ζ - priorsM = [priors_dict[k] for k in keys(θM)] + priorsM = Tuple(priors_dict[k] for k in keys(θM)) lowers, uppers = get_quantile_transformed(priorsM, transM) - app, ϕg0 = construct_ChainsApplicator(rng, g_chain) + + app, ϕg0 = construct_ChainsApplicator(rng, g_chain, FT) g_chain_scaled = NormalScalingModelApplicator(app, lowers, uppers, FT) #g_chain_scaled = app - #ϕunc0 = init_hybrid_ϕunc(cor_ends, zero(FT)) pbm_covars = (:covarK2 ∈ scen) ? (:K2,) : () f_batch = PBMSiteApplicator( f_doubleMM; θP, θM, θFix=CA.ComponentVector{FT}(), xPvec=xP[:,1]) - HybridProblem(θP, θM, g_chain_scaled, ϕg0, + ϕunc0 = init_hybrid_ϕunc(MeanHVIApproximation(), cor_ends, zero(FT)) + ϕq = CP.update_μP_by_θP(ϕunc0, θP, transP) + approx = if (:MeanHVIApproxBlocks ∈ scen) + MeanHVIApproximation() + else + MeanHVIApproximationMat() + end + HybridProblem(θM, ϕq, g_chain_scaled, ϕg0, f_batch, priors_dict, py, transM, transP, train_dataloader, n_covar, n_site, n_batch, - cor_ends, pbm_covars, + cor_ends, pbm_covars, approx, #ϕunc0, ) end @@ -104,9 +115,7 @@ end function test_f_doubleMM(θ::AbstractVector{ET}, x; intθ1) where ET # extract parameters not depending on order, i.e whether they are in θP or θM θc = intθ1(θ) - (r0, r1, K1, K2) = map((:r0, :r1, :K1, :K2)) do par - CA.getdata(θc[par])::ET - end + @unpack r0, r1, K1, K2 = θc r0 .+ r1 .* x.S1 ./ (K1 .+ x.S1) .* x.S2 ./ (K2 .+ x.S2) end y = @inferred test_f_doubleMM(CA.getdata(θ2), xP1; intθ1 = int_θdoubleMM) @@ -114,7 +123,6 @@ end # @descend_code_warntype test_f_doubleMM(CA.getdata(θ2), xP1) end -#scenario = Val((:default,)) test_without_flux = (scenario) -> begin #scen = CP._val_value(scenario) gdev = @suppress gpu_device() @@ -149,21 +157,26 @@ test_without_flux = (scenario) -> begin intϕ = ComponentArrayInterpreter(CA.ComponentVector( ϕg=1:length(ϕg0), ϕP=par_templates.θP)) priors = get_hybridproblem_priors(prob; scenario) - priorsP = [priors[k] for k in keys(par_templates.θP)] - priorsM = [priors[k] for k in keys(par_templates.θM)] + priorsP = Tuple(priors[k] for k in keys(par_templates.θP)) + priorsM = Tuple(priors[k] for k in keys(par_templates.θM)) # slightly disturb θP_true p = p0 = vcat(ϕg0, par_templates.θP .* convert(eltype(ϕg0), 0.8)) # Pass the site-data for the batches as separate vectors wrapped in a tuple + zero_prior_logdensity = CP.get_zero_prior_logdensity( + priorsP, priorsM, par_templates.θP, par_templates.θM) loss_gf = get_loss_gf(g, transM, transP, f, py, intϕ; - pbm_covars, n_site_batch = n_batch, priorsP, priorsM, + pbm_covars, n_site_batch = n_batch, priorsP, priorsM, zero_prior_logdensity, ) (_xM, _xP, _y_o, _y_unc, _i_sites) = first(train_loader) #l1 = loss_gf(p0, _xM, _xP, _y_o, _y_unc, _i_sites; is_testmode = false) + #using ShareAdd + #@usingany Cthulhu l1 = @inferred ( # @descend_code_warntype ( - loss_gf(p0, _xM, _xP, _y_o, _y_unc, _i_sites; is_testmode = true)) + loss_gf(p0, _xM, _xP, _y_o, _y_unc, _i_sites; is_testmode = true) + ) tld = first(train_loader) gr = Zygote.gradient(p -> loss_gf(p, tld...; is_testmode = false)[1], CA.getdata(p0)) @test gr[1] isa Vector @@ -187,6 +200,8 @@ test_without_flux = (scenario) -> begin end end +#test_without_flux(Val((:MeanHVIApproximation,))) # not used in loss_gf +#scenario=Val((:default,)) test_without_flux(Val((:default,))) test_without_flux(Val((:covarK2,))) @@ -194,7 +209,8 @@ import CUDA, cuDNN using GPUArraysCore import Flux -gdev = gpu_device() +#CUDA.device!(2) # TODO remove after GPU 0 becomes available again +gdev = gpu_device() #methods(CP.vec2uutri) test_with_flux = (scenario) -> begin @@ -239,9 +255,7 @@ test_with_flux = (scenario) -> begin ) θPt = get_hybridproblem_par_templates(prob; scenario).θP @test θP.r0 < 1.5 * θPt.r0 - @test exp(ϕ.μP.K2) == θP.K2 < 1.5 * θP.K2 - θP - prob.θP + @test exp(ϕ.ϕq.μP.K2) == θP.K2 < 1.5 * θP.K2 n_sample_pred = 12 (; y, θsP, θsMs, entropy_ζ) = predict_hvi(rng, probo; scenario, n_sample_pred); _,_,y_obs,_ = get_hybridproblem_train_dataloader(prob; scenario).data @@ -269,46 +283,56 @@ test_with_flux_gpu = (scenario) -> begin solver = HybridPosteriorSolver(; alg=Adam(0.02), n_MC=3) n_site, n_batch = get_hybridproblem_n_site_and_batch(prob; scenario = scenf) n_batches_in_epoch = n_site ÷ n_batch - (; ϕ, θP, resopt) = solve(prob, solver; scenario = scenf, rng, + (; probo, ϕ, resopt) = solve(prob, solver; scenario = scenf, rng, #maxiters = 37, # smallest value by trial and error #maxiters = 20 # too small so that it yields error epochs = 2, θmean_quant = 0.01, # test constraining mean to initial prediction is_inferred = Val(true), gdevs = (; gdev_M=gpu_device(), gdev_P=identity),); - @test CA.getdata(ϕ) isa GPUArraysCore.AbstractGPUVector - #@test cdev(ϕ.unc.ρsM)[1] > 0 # too few iterations in test -> may fail + @test resopt.u isa GPUArraysCore.AbstractGPUVector + @test !(CA.getdata(ϕ) isa GPUArraysCore.AbstractGPUVector) + #@test cdev(ϕ.ϕq.ρsM)[1] > 0 # too few iterations in test -> may fail # solver = HybridPosteriorSolver(; alg=Adam(0.02), n_MC=3) - (; ϕ, θP, resopt, probo) = solve(prob, solver; scenario = scenf, + (; probo, ϕ, resopt) = solve(prob, solver; scenario = scenf, #maxiters = 37, epochs = 2, gdevs = (; gdev_M=gpu_device(), gdev_P=identity), is_inferred = Val(true), ); - @test cdev(ϕ.unc.ρsM)[1] > 0 - @test probo.ϕunc == cdev(ϕ.unc) + @test cdev(ϕ.ϕq.ρsM)[1] > 0 + @test probo.ϕq == cdev(ϕ.ϕq) n_sample_pred = 22 (; y, θsP, θsMs) = predict_hvi( rng, probo; scenario = scenf, n_sample_pred, is_inferred=Val(true)); - (_xM, _xP, _y_o, _y_unc, _i_sites) = get_hybridproblem_train_dataloader(prob; scenario).data + (_xM, _xP, _y_o, _y_unc, _i_sites) = get_hybridproblem_train_dataloader( + prob; scenario).data @test size(y) == (size(_y_o)..., n_sample_pred) - @test size(θsP) == (size(probo.θP,1), n_sample_pred) + @test size(θsP) == ( + length(get_hybridproblem_par_templates(probo).θP), n_sample_pred) test_correlation = () -> begin n_epoch = 20 # requires - (; ϕ, θP, resopt, probo) = solve(prob, solver; scenario = scenf, + (; ϕ, resopt, probo) = solve(prob, solver; scenario = scenf, maxiters = n_batches_in_epoch * n_epoch, gdevs = (; gdev_M=gpu_device(), gdev_P=identity), callback = callback_loss(n_batches_in_epoch*5) ); - @test cdev(ϕ.unc.ρsM)[1] > 0 - @test probo.ϕunc == cdev(ϕ.unc) + @test cdev(ϕ.ϕq.ρsM)[1] > 0 + @test probo.ϕq == cdev(ϕ.ϕq) # predict using problem and its associated dataloader n_sample_pred = 201 (; y, θsP, θsMs) = predict_hvi(rng, probo; scenario = scenf, n_sample_pred); # to inspect correlations among θP and θMs construct ComponentVector - hpints = HybridProblemInterpreters(prob; scenario) + # TODO redo get_int_PMst_site + # get_ca_int_PMs = let + # function get_ca_int_PMs_inner(n_site) + # ComponentArrayInterpreter(CA.ComponentVector(; P = θP, + # Ms = CA.ComponentMatrix( + # zeros(n_θM, n_site), first(CA.getaxes(θM)), CA.Shaped1DAxis((n_site,))))) + # end + # end int_mPMs = stack_ca_int(Val((n_sample_pred,)), get_int_PMst_site(hpints)) θs = int_mPMs(CP.flatten_hybrid_pars(θsP, θsMs)) mean_θ = CA.ComponentVector(vec(mean(CA.getdata(θs), dims=1)), last(CA.getaxes(θs))) @@ -326,38 +350,44 @@ test_with_flux_gpu = (scenario) -> begin cr[is,is] end end; - @testset "HybridPosteriorSolver also f on gpu $(last(CP._val_value(scenario)))" begin - scenf = Val((CP._val_value(scenario)..., :use_Flux, :use_gpu, :omit_r0, :f_on_gpu)) - rng = StableRNG(111) - probg = HybridProblem(DoubleMM.DoubleMMCase(); scenario = scenf); - # put Applicator to gpu (θFix) - # moved to solve and predict_hvi - # probg = HybridProblem( - # probg, - # f_batch = gdev(probg.f_batch), - # f_allsites = gdev(probg.f_allsites)) - #prob = CP.update(probg, transM = identity, transP = identity); - solver = HybridPosteriorSolver(; alg=Adam(0.02), n_MC=3) - n_site, n_batch = get_hybridproblem_n_site_and_batch(probg; scenario = scenf) - n_batches_in_epoch = n_site ÷ n_batch - (; ϕ, θP, resopt, probo) = solve(probg, solver; scenario = scenf, rng, - #maxiters = 37, # smallest value by trial and error - #maxiters = 20, # too small so that it yields error - epochs = 1, - #θmean_quant = 0.01, # TODO make possible on gpu - gdevs = (; gdev_M=gpu_device(), gdev_P=gpu_device()), - is_inferred = Val(true), - ); - @test CA.getdata(ϕ) isa GPUArraysCore.AbstractGPUVector - n_sample_pred = 11 - (; y, θsP, θsMs) = predict_hvi( - rng, probo; scenario = scenf, n_sample_pred,is_inferred = Val(true)); - # @test cdev(ϕ.unc.ρsM)[1] > 0 # too few iterations - end; + # allowscalar and indescing into ComponentArray does not work + if !(:useSitePBM ∈ typeof(scenario).parameters[1]) + @testset "HybridPosteriorSolver also f on gpu $(last(CP._val_value(scenario)))" begin + scenf = Val((CP._val_value(scenario)..., :use_Flux, :use_gpu, :omit_r0, :f_on_gpu)) + rng = StableRNG(111) + probg = HybridProblem(DoubleMM.DoubleMMCase(); scenario = scenf); + # put Applicator to gpu (θFix) + # moved to solve and predict_hvi + # probg = HybridProblem( + # probg, + # f_batch = gdev(probg.f_batch), + # f_allsites = gdev(probg.f_allsites)) + #prob = CP.update(probg, transM = identity, transP = identity); + solver = HybridPosteriorSolver(; alg=Adam(0.02), n_MC=3) + n_site, n_batch = get_hybridproblem_n_site_and_batch(probg; scenario = scenf) + n_batches_in_epoch = n_site ÷ n_batch + (; ϕ, θP, resopt, probo) = solve(probg, solver; scenario = scenf, rng, + #maxiters = 37, # smallest value by trial and error + #maxiters = 20, # too small so that it yields error + epochs = 1, + #θmean_quant = 0.01, # TODO make possible on gpu + gdevs = (; gdev_M=gpu_device(), gdev_P=gpu_device()), + is_inferred = Val(true), + is_omit_priors = Val(true), # cannot evaluate on gpu + ); + @test resopt.u isa GPUArraysCore.AbstractGPUVector + n_sample_pred = 11 + (; y, θsP, θsMs) = predict_hvi( + rng, probo; scenario = scenf, n_sample_pred,is_inferred = Val(true)); + # @test cdev(ϕ.ϕq.ρsM)[1] > 0 # too few iterations + end; + end end # if gdev isa MLDataDevices.AbstractGPUDevice end # test_with flux +#test_with_flux_gpu(Val((:MeanHVIApproxBlocks,))) # do not test any more, its slower +#scenario = Val(()) test_with_flux_gpu(Val((:default,))) test_with_flux_gpu(Val((:covarK2,))) -test_with_flux_gpu(Val((:default,:useSitePBM))) +test_with_flux_gpu(Val((:useSitePBM,))) diff --git a/test/test_cholesky_structure.jl b/test/test_cholesky_structure.jl index 2369194..1d98b49 100644 --- a/test/test_cholesky_structure.jl +++ b/test/test_cholesky_structure.jl @@ -193,19 +193,24 @@ end; @test U[1:3, 4:4] ≈ zeros(3, 1) gr1 = Zygote.gradient(v -> sum(CP.transformU_block_cholesky1(v, cor_ends)), v)[1]; # works nice # degenerate case of no correlations for one parameter - vc0 = CA.ComponentVector{Float32}() - cor_ends0 = @inferred get_ca_ends(vc0) + vc1 = CA.ComponentVector{Float32}(a=1) + cor_ends1 = @inferred get_ca_ends(vc1) + @test cor_ends1 == [1] #@descend_code_warntype get_ca_ends(vc0) - ρ0 = collect(1f0:get_cor_count(cor_ends0)) + ρ0 = collect(1f0:get_cor_count(cor_ends1)) #ns=(CP.invsumn(length(v[k])) + 1 for k in keys(v)) #collect(ns) - U = @inferred TEmpty CP.transformU_block_cholesky1(CA.getdata(ρ0), cor_ends0) - #U = @inferred UT CP.transformU_block_cholesky1(CA.getdata(ρ0), cor_ends0) + U = @inferred TEmpty CP.transformU_block_cholesky1(CA.getdata(ρ0), cor_ends1) + #U = @inferred UT CP.transformU_block_cholesky1(CA.getdata(ρ0), cor_ends1) + @test U isa BlockDiagonal @test diag(U) == [1f0] - gr1 = Zygote.gradient(v -> sum(CP.transformU_block_cholesky1(ρ0, cor_ends0)), v)[1]; # works nice + gr1 = Zygote.gradient(v -> sum(CP.transformU_block_cholesky1(ρ0, cor_ends1)), v)[1]; # works nice # # degenerate case of no correlations for zero parameters - U = @inferred TEmpty CP.transformU_block_cholesky1(CA.getdata(ρ0), [0]) + vc0 = CA.ComponentVector{Float32}() + cor_ends0 = @inferred get_ca_ends(vc0) + @test cor_ends0 == [0] + U = @inferred TEmpty CP.transformU_block_cholesky1(CA.getdata(ρ0), cor_ends0) @test U == [;;] gr1 = Zygote.gradient(v -> sum(CP.transformU_block_cholesky1(ρ0, [length(v)])), v[1:0])[1]; @test isnothing(gr1) @@ -223,14 +228,15 @@ end; @test cdev(U[1:3, 4:4]) ≈ zeros(3, 1) gr1 = Zygote.gradient(v -> sum(CP.transformU_block_cholesky1(v, cor_ends)), v)[1] # works nice # - cor_ends0 = Int64[] - ρ0 = ggdev(collect(1f0:get_cor_count(cor_ends0))) - U = @inferred CP.transformU_block_cholesky1(ρ0, cor_ends0) - #U = @inferred UT CP.transformU_block_cholesky1(ρ0, cor_ends0) + cor_ends1 = Int[1] + ρ0 = ggdev(collect(1f0:get_cor_count(cor_ends1))) + U = @inferred CP.transformU_block_cholesky1(ρ0, cor_ends1) + #U = @inferred UT CP.transformU_block_cholesky1(ρ0, cor_ends1) @test U isa GPUArraysCore.AbstractGPUArray @test cdev(diag(U)) == [1f0] # - U = @inferred CP.transformU_block_cholesky1(CA.getdata(ρ)[1:0], [0]) + cor_ends0 = Int[0] + U = @inferred CP.transformU_block_cholesky1(CA.getdata(ρ)[1:0], cor_ends0) @test U isa GPUArraysCore.AbstractGPUArray @test cdev(U) == [;;] end diff --git a/test/test_doubleMM.jl b/test/test_doubleMM.jl index 60a36e1..ec29691 100644 --- a/test/test_doubleMM.jl +++ b/test/test_doubleMM.jl @@ -204,8 +204,8 @@ end f2 = create_nsite_applicator(f, n_site) py = get_hybridproblem_neg_logden_obs(prob; scenario) priors = get_hybridproblem_priors(prob; scenario) - priorsP = [priors[k] for k in keys(par_templates.θP)] - priorsM = [priors[k] for k in keys(par_templates.θM)] + priorsP = Tuple(priors[k] for k in keys(par_templates.θP)) + priorsM = Tuple(priors[k] for k in keys(par_templates.θM)) intϕ = ComponentArrayInterpreter(CA.ComponentVector( ϕg = 1:length(ϕg0), ϕP = par_templates.θP)) @@ -222,10 +222,12 @@ end pbm_covars = get_hybridproblem_pbmpar_covars(prob; scenario) #loss_gf = get_loss_gf(g, transM, f, intϕ; gdev = identity) + zero_prior_logdensity = CP.get_zero_prior_logdensity( + priorsP, priorsM, par_templates.θP, par_templates.θM) loss_gf = get_loss_gf(g, transM, transP, f, py, intϕ; - pbm_covars, n_site_batch = n_batch, priorsP, priorsM) + pbm_covars, n_site_batch = n_batch, priorsP, priorsM, zero_prior_logdensity) loss_gf_site = get_loss_gf(g, transM, transP, f2, py, intϕ; - pbm_covars, n_site_batch = n_site, priorsP, priorsM) + pbm_covars, n_site_batch = n_site, priorsP, priorsM, zero_prior_logdensity) nLjoint = @inferred first(loss_gf(p0, first(train_loader)...; is_testmode=true)) (xM_batch, xP_batch, y_o_batch, y_unc_batch, i_sites_batch) = first(train_loader) # @usingany Cthulhu diff --git a/test/test_elbo.jl b/test/test_elbo.jl index 04128d6..79d218f 100644 --- a/test/test_elbo.jl +++ b/test/test_elbo.jl @@ -28,8 +28,11 @@ const prob = DoubleMM.DoubleMMCase() scenario = Val((:default,)) #scenario = Val((:covarK2,)) +const approx = MeanHVIApproximationMat() +#const approx = MeanHVIApproximation() + test_scenario = (scenario) -> begin - probc = HybridProblem(prob; scenario); + probc = HybridProblem(prob; scenario, approx); FT = get_hybridproblem_float_type(probc; scenario) par_templates = get_hybridproblem_par_templates(probc; scenario) int_P, int_M = map(ComponentArrayInterpreter, par_templates) @@ -71,20 +74,17 @@ test_scenario = (scenario) -> begin # transP = elementwise(exp) # transM = Stacked(elementwise(identity), elementwise(exp)) #transM = Stacked(elementwise(identity), elementwise(exp), elementwise(exp)) # test mismatch - ϕunc0 = init_hybrid_ϕunc(cor_ends, zero(FT)) - hpints = HybridProblemInterpreters(probc; scenario) - (; ϕ, transPMs_batch, interpreters, get_transPMs, get_ca_int_PMs) = init_hybrid_params( - θP_true, θMs_true[:, 1], cor_ends, ϕg0, hpints; transP, transM) - int_unc = interpreters.unc - int_μP_ϕg_unc = interpreters.μP_ϕg_unc - - # @descend_code_warntype init_hybrid_params(θP_true, θMs_true[:, 1], cor_ends, ϕg0, n_batch; transP, transM) - # @descend_code_warntype CA.ComponentVector(nt) + ϕq0 = init_hybrid_ϕq(approx, par_templates.θP, par_templates.θM, transP, cor_ends) + # ϕunc0 = init_hybrid_ϕunc(cor_ends, zero(FT)) + # ϕq0 = CP.update_μP_by_θP(ϕunc0, θP_true, transP) + (; ϕ, interpreters) = init_hybrid_params(ϕg0, ϕq0) + int_ϕq = interpreters.ϕq + int_ϕg_ϕq = interpreters.ϕg_ϕq ϕ_ini = ϕ - transform_tools = nothing # TODO remove - # transform_tools = @inferred CP.setup_transform_ζ( - # transP, transM, get_int_PMst_batch(hpints)) - int_PMs = get_int_PMst_batch(hpints) + # transform_tools = nothing # TODO remove + # # transform_tools = @inferred CP.setup_transform_ζ( + # # transP, transM, get_int_PMst_batch(hpints)) + # int_PMs = get_int_PMst_batch(hpints) if ggdev isa MLDataDevices.AbstractGPUDevice scenario_flux = Val((CP._val_value(scenario)..., :use_Flux, :use_gpu)) @@ -97,15 +97,15 @@ test_scenario = (scenario) -> begin ζsP, ζsMs, σ = @inferred ( # @descend_code_warntype ( CP.generate_ζ( - rng, g, ϕ_ini, xM[:, 1:n_batch]; + approx, rng, g, ϕ_ini, xM[:, 1:n_batch]; n_MC, cor_ends, pbm_covar_indices, - int_unc=interpreters.unc, int_μP_ϕg_unc=interpreters.μP_ϕg_unc, is_testmode = false) + int_ϕq=interpreters.ϕq, int_ϕg_ϕq=interpreters.ϕg_ϕq, is_testmode = false) ) @testset "generate_ζ $(last(CP._val_value(scenario)))" begin # xMtest = vcat(xM, xM[1:1,:]) # ζ, σ = CP.generate_ζ( - # rng, g, ϕ_ini, xMtest[:, 1:n_batch], map(get_concrete, interpreters); + # approx, rng, g, ϕ_ini, xMtest[:, 1:n_batch], map(get_concrete, interpreters); # n_MC = 8, cor_ends, pbm_covar_indices) @test ζsP isa AbstractMatrix @test ζsMs isa AbstractArray @@ -114,9 +114,9 @@ test_scenario = (scenario) -> begin gr = Zygote.gradient( ϕ -> begin _ζsP, _ζsMs, _σ = CP.generate_ζ( - rng, g, ϕ, xM[:, 1:n_batch]; + approx, rng, g, ϕ, xM[:, 1:n_batch]; n_MC=8, cor_ends, pbm_covar_indices, - int_unc=interpreters.unc, int_μP_ϕg_unc=interpreters.μP_ϕg_unc, + int_ϕq=interpreters.ϕq, int_ϕg_ϕq=interpreters.ϕg_ϕq, is_testmode = true) sum(_ζsP) + sum(_ζsMs) + sum(_σ) end, CA.getdata(ϕ_ini)) @@ -127,27 +127,31 @@ test_scenario = (scenario) -> begin # can only test distribution if g is not repeated @testset "generate_ζ check sd residuals $(last(CP._val_value(scenario)))" begin # prescribe very different uncertainties - ϕunc_true = copy(probc.ϕunc) sd_ζP_true = [0.2,20] sd_ζMs_a_true = [0.1,2] # sd at_variance at θ==0 logσ2_ζMs_b_true = [-0.3,+0.2] # slope of log_variance with θ ρsP_true = [+0.8] ρsM_true = [-0.6] - ϕunc_true.logσ2_ζP = (log ∘ abs2).(sd_ζP_true) - ϕunc_true.coef_logσ2_ζMs[1,:] = (log ∘ abs2).(sd_ζMs_a_true) - ϕunc_true.coef_logσ2_ζMs[2,:] = logσ2_ζMs_b_true - # note that the parameterization contains a transformation that - # here only inverted for the single correlation case - ϕunc_true.ρsP = CP.compute_cholcor_coefficient_single.(ρsP_true) - ϕunc_true.ρsM = CP.compute_cholcor_coefficient_single.(ρsM_true) + ϕunc_true = CA.ComponentVector{eltype(probc.ϕq)}(; + logσ2_ζP = (log ∘ abs2).(sd_ζP_true), + coef_logσ2_ζMs = vcat( + (log ∘ abs2).(sd_ζMs_a_true)', + logσ2_ζMs_b_true', + ), + # note that the parameterization contains a transformation that + # here only inverted for the single correlation case + ρsP = CP.compute_cholcor_coefficient_single.(ρsP_true), + ρsM = CP.compute_cholcor_coefficient_single.(ρsM_true), + ) # check that ρsM_true = -0.6 recovered with params ϕunc_true.ρsM = -0.75 UC = CP.transformU_cholesky1(ϕunc_true.ρsM); Σ = UC' * UC @test Σ[1,2] ≈ ρsM_true[1] - probd = HybridProblem(probc; ϕunc=ϕunc_true); + ϕq_true = CA.ComponentVector(; probc.ϕq..., ϕunc_true...) + probd = HybridProblem(probc; ϕq = ϕq_true); - _ϕ = vcat(ϕ_ini.μP, probc.ϕg, probd.ϕunc) + _ϕ = vcat(probd.ϕg, probd.ϕq) #hcat(ϕ_ini, ϕ, _ϕ)[1:4,:] #hcat(ϕ_ini, ϕ, _ϕ)[(end-20):end,:] n_predict = 10_000 #8_000 @@ -155,9 +159,9 @@ test_scenario = (scenario) -> begin _ζsP, _ζsMs, _σ = @inferred ( # @descend_code_warntype ( CP.generate_ζ( - rng, g, _ϕ, xM_batch; + approx, rng, g, _ϕ, xM_batch; n_MC = n_predict, cor_ends, pbm_covar_indices, - int_unc=interpreters.unc, int_μP_ϕg_unc=interpreters.μP_ϕg_unc, + int_ϕq=interpreters.ϕq, int_ϕg_ϕq=interpreters.ϕg_ϕq, is_testmode = true) ) ζMs_g = g(xM_batch, probc.ϕg)' # have been generated with no scaling @@ -173,7 +177,7 @@ test_scenario = (scenario) -> begin #scatterplot(ζMs_g[:,1], mMs[:,1]) #scatterplot(ζMs_g[:,2], mMs[:,2]) @test cor(ζMs_g[:,1], mMs[:,1]) > 0.9 - @test cor(ζMs_g[:,2], mMs[:,2]) > 0.7 + @test cor(ζMs_g[:,2], mMs[:,2]) > 0.6 map(axes(mMs,2)) do ipar #@show ipar @test isapprox(mMs[:,ipar], ζMs_g[:,ipar]; rtol=0.1) @@ -214,7 +218,7 @@ test_scenario = (scenario) -> begin @testset "predict_hvi check sd" begin # test if uncertainty and reshaping is propagated # here inverse the predicted θs and then test distribution - probcu = HybridProblem(probc, ϕunc=ϕunc_true); + probcu = HybridProblem(probc, ϕq=ϕq_true); n_sample_pred = 10_000 #2_400 #n_sample_pred = 400 (; y, θsP, θsMs, entropy_ζ) = predict_hvi(rng, probcu; scenario, n_sample_pred); @@ -241,9 +245,9 @@ test_scenario = (scenario) -> begin ζsP_d, ζsMs_d, σ_d = @inferred ( # @descend_code_warntype ( CP.generate_ζ( - rng, g_gpu, ϕ, xMg_batch; + approx, rng, g_gpu, ϕ, xMg_batch; n_MC, cor_ends, pbm_covar_indices, - int_unc=interpreters.unc, int_μP_ϕg_unc=interpreters.μP_ϕg_unc, + int_ϕq=interpreters.ϕq, int_ϕg_ϕq=interpreters.ϕg_ϕq, is_testmode = true)) @test ζsP_d isa Union{GPUArraysCore.AbstractGPUMatrix, LinearAlgebra.Adjoint{FT,<:GPUArraysCore.AbstractGPUMatrix}} @@ -255,9 +259,9 @@ test_scenario = (scenario) -> begin gr = Zygote.gradient( ϕ -> begin _ζsP, _ζsMs, _σ = CP.generate_ζ( - rng, g_gpu, ϕ, xMg_batch; + approx, rng, g_gpu, ϕ, xMg_batch; n_MC, cor_ends, pbm_covar_indices, - int_unc=interpreters.unc, int_μP_ϕg_unc=interpreters.μP_ϕg_unc, + int_ϕq=interpreters.ϕq, int_ϕg_ϕq=interpreters.ϕg_ϕq, is_testmode = false) sum(_ζsP) + sum(_ζsMs) + sum(_σ) end, CA.getdata(ϕ)) @@ -343,17 +347,23 @@ test_scenario = (scenario) -> begin #@descend_code_warntype ( neg_elbo_gtf(rng, ϕ_ini, g, f, py, xM[:, i_sites], xP[:, i_sites], y_o[:, i_sites], y_unc[:, i_sites], i_sites; - int_unc, int_μP_ϕg_unc, + int_ϕq, int_ϕg_ϕq, cor_ends, pbm_covar_indices, transP, transMs, priorsP, priorsM, - is_testmode = true) + is_testmode = true, + is_omit_priors = Val(false), zero_prior_logdensity=zero(eltype(ϕ_ini)), + approx, + ) ) @test cost isa Float64 gr = Zygote.gradient( ϕ -> neg_elbo_gtf(rng, ϕ, g, f, py, xM[:, i_sites], xP[:, i_sites], y_o[:, i_sites], y_unc[:, i_sites], i_sites; - int_unc, int_μP_ϕg_unc, + int_ϕq, int_ϕg_ϕq, cor_ends, pbm_covar_indices, transP, transMs, priorsP, priorsM, - is_testmode = false), + is_testmode = false, + is_omit_priors = Val(false), zero_prior_logdensity=zero(eltype(ϕ_ini)), + approx, + ), CA.getdata(ϕ_ini)) @test gr[1] isa Vector end @@ -369,18 +379,22 @@ test_scenario = (scenario) -> begin #@descend_code_warntype ( neg_elbo_gtf(rng, ϕ, g_gpu, f, py, xMg_batch, xP_batch, y_o[:, i_sites], y_unc[:, i_sites], i_sites; - int_unc, int_μP_ϕg_unc, + int_ϕq, int_ϕg_ϕq, n_MC=3, cor_ends, pbm_covar_indices, transP, transMs, priorsP, priorsM, is_testmode = true, + is_omit_priors = Val(false), zero_prior_logdensity=zero(eltype(ϕ_ini)), + approx, ) ) @test cost isa Float64 gr = Zygote.gradient( ϕ -> neg_elbo_gtf(rng, ϕ, g_gpu, f, py, xMg_batch, xP_batch, y_o[:, i_sites], y_unc[:, i_sites], i_sites; - int_unc, int_μP_ϕg_unc, + int_ϕq, int_ϕg_ϕq, n_MC=3, cor_ends, pbm_covar_indices, transP, transMs, priorsP, priorsM, is_testmode = false, + is_omit_priors = Val(false), zero_prior_logdensity=zero(eltype(ϕ_ini)), + approx, ), ϕ) @test gr[1] isa GPUArraysCore.AbstractGPUVector @@ -398,11 +412,12 @@ test_scenario = (scenario) -> begin #Cthulhu.@descend_code_warntype ( @inferred ( sample_posterior(rng, g, ϕ_ini, xM; - int_μP_ϕg_unc, int_unc, + int_ϕg_ϕq, int_ϕq, transP, transM, cdev = identity, n_sample_pred, cor_ends, pbm_covar_indices, is_testmode = true, + approx, ) ) @test θsP isa AbstractMatrix @@ -425,12 +440,14 @@ test_scenario = (scenario) -> begin #Cthulhu.@descend_code_warntype ( @inferred ( sample_posterior(rng, g_gpu, ϕ_ini_g, xMg; - int_μP_ϕg_unc, int_unc, + int_ϕg_ϕq, int_ϕq, transP, transM, #cdev = cpu_device(), cdev = identity, # do not transfer to CPU n_sample_pred, cor_ends, pbm_covar_indices, - is_testmode = true) + is_testmode = true, + approx, + ) ) # this variant without the problem, does not attach axes @test θsP isa AbstractMatrix diff --git a/test/test_hybridprobleminterpreters.jl b/test/test_hybridprobleminterpreters.jl deleted file mode 100644 index dc18c06..0000000 --- a/test/test_hybridprobleminterpreters.jl +++ /dev/null @@ -1,80 +0,0 @@ -using Test -using HybridVariationalInference -using HybridVariationalInference: HybridVariationalInference as CP -using ComponentArrays: ComponentArrays as CA - -using MLDataDevices, GPUArraysCore -import Zygote - -# import CUDA, cuDNN -using Suppressor - -gdev = Suppressor.@suppress gpu_device() # not loaded CUDA -cdev = cpu_device() - -scenario = Val((:default,)) -prob = DoubleMM.DoubleMMCase() - -ints = @inferred HybridProblemInterpreters(prob; scenario) -θP, θM = @inferred get_hybridproblem_par_templates(prob; scenario) -NS, NB = @inferred get_hybridproblem_n_site_and_batch(prob; scenario) - -@testset "HybridProblemInterpreters" begin - @test (@inferred get_int_P(ints)(CA.getdata(θP))) == θP - @test (@inferred get_int_M(ints)(CA.getdata(θM))) == θM - # - int_Ms_batch = get_concrete(ComponentArrayInterpreter(θM, (NB,))) - ms_vec = 1:length(int_Ms_batch) - @test (@inferred get_int_Ms_batch(ints)(ms_vec)) == int_Ms_batch(ms_vec) - int_Mst_batch = get_concrete(ComponentArrayInterpreter((NB,), θM)) - @test (@inferred get_int_Mst_batch(ints)(ms_vec)) == int_Mst_batch(ms_vec) - # - int_Ms_site = get_concrete(ComponentArrayInterpreter(θM, (NS,))) - ms_vec = 1:length(int_Ms_site) - @test (@inferred get_int_Ms_site(ints)(ms_vec)) == int_Ms_site(ms_vec) - int_Mst_site = get_concrete(ComponentArrayInterpreter((NS,), θM)) - @test (@inferred get_int_Mst_site(ints)(ms_vec)) == int_Mst_site(ms_vec) - # - pms_ca = CA.ComponentVector(P = θP, Ms = int_Ms_batch(1:length(int_Ms_batch))) - pms_vec = CA.getdata(pms_ca) - #int_PMs_batch = get_concrete(ComponentArrayInterpreter(pms_ca)) - @test (@inferred get_int_PMs_batch(ints)(pms_vec)) == pms_ca - pmst_ca = CA.ComponentVector(P = θP, Ms = int_Mst_batch(1:length(int_Mst_batch))) - pmst_vec = CA.getdata(pmst_ca) - @test (@inferred get_int_PMst_batch(ints)(pmst_vec)) == pmst_ca - # - pms_ca = CA.ComponentVector(P = θP, Ms = int_Ms_site(1:length(int_Ms_site))) - pms_vec = CA.getdata(pms_ca) - @test (@inferred get_int_PMs_site(ints)(pms_vec)) == pms_ca - pmst_ca = CA.ComponentVector(P = θP, Ms = int_Mst_site(1:length(int_Mst_site))) - pmst_vec = CA.getdata(pmst_ca) - @test (@inferred get_int_PMst_site(ints)(pmst_vec)) == pmst_ca -end; - -@testset "stack_ca_int" begin - int_Mst_batch = get_int_Mst_batch(ints) - pmst_ca = CA.ComponentVector(P = θP, Ms = int_Mst_batch(1:length(int_Mst_batch))) - n_pred = 5 - mmst_vec = repeat(CA.getdata(pmst_ca)', n_pred) # column per parameter - int_PMst_batch = @inferred get_int_PMst_batch(ints) - intm_PMst_batch = @inferred stack_ca_int(Val((n_pred,)), int_PMst_batch) - mmst = @inferred intm_PMst_batch(mmst_vec) - @test size(mmst[1, :Ms]) == (NB, length(θM)) - @test all(mmst[:, :P][:, :r0] .== pmst_ca.P.r0) - # - # note the use of Val here -> arrays interpreted will by Any outside the context - @testset "stack_ca_int not inferred outside" begin - tmpf = (mmst_vec; - intm_PMst_batch = @inferred stack_ca_int(Val((size(mmst_vec,1),)), int_PMst_batch) - ) -> begin - # good practise to help inference by providing a hint to the eltype - (@inferred intm_PMst_batch(mmst_vec))::CA.ComponentMatrix{eltype(mmst_vec),typeof(mmst_vec)} - end - res = tmpf(mmst_vec) - @test_broken @inferred tmpf(mmst_vec) - # but supplying the extended array, its inferred in this context - intm_PMst_batch2 = @inferred stack_ca_int(Val((size(mmst_vec,1),)), int_PMst_batch) - @inferred tmpf(mmst_vec; intm_PMst_batch = intm_PMst_batch2) - end -end - diff --git a/test/test_missingdriver.jl b/test/test_missingdriver.jl index d24c871..36ec2df 100644 --- a/test/test_missingdriver.jl +++ b/test/test_missingdriver.jl @@ -92,7 +92,7 @@ function test_driverNaN(scenario::Val{scen}) where scen #callback = callback_loss(100), # output during fitting #callback = callback_loss(10), # output during fitting epochs = 2, - is_omit_priors = (:f_on_gpu ∈ scen), # prior computation does not work on gpu + is_omit_priors = Val(:f_on_gpu ∈ scen), # prior computation does not work on gpu scenario, ); @test all(isfinite.(ϕ)) diff --git a/test/test_no_globals.jl b/test/test_no_globals.jl index d3acaa6..719c373 100644 --- a/test/test_no_globals.jl +++ b/test/test_no_globals.jl @@ -19,14 +19,15 @@ using Lux # in order to load extension function test_no_globals(scenario::Val{scen}) where scen scenario = Val((scen..., :no_globals)) prob = HybridProblem(DoubleMM.DoubleMMCase(); scenario); - @test isempty(prob.θP) + θP0, θM0 = get_hybridproblem_par_templates(prob) + @test isempty(θP0) solver_point = HybridPointSolver(; alg=Adam(0.02)) rng = StableRNG(111) (;ϕ, resopt, probo) = solve(prob, solver_point; rng, #callback = callback_loss(100), # output during fitting #callback = callback_loss(10), # output during fitting epochs = 2, - is_omit_priors = (:f_on_gpu ∈ scen), # prior computation does not work on gpu + is_omit_priors = Val(:f_on_gpu ∈ scen), # prior computation does not work on gpu scenario, ); @test all(isfinite.(ϕ)) @@ -41,11 +42,11 @@ function test_no_globals(scenario::Val{scen}) where scen solver = HybridPosteriorSolver(; alg=Adam(0.02), n_MC=3) (; probo, interpreters) = solve(prob, solver; rng, #callback = callback_loss(10), # output during fitting - is_omit_priors = (:f_on_gpu ∈ scen), # prior computation does not work on gpu + is_omit_priors = Val(:f_on_gpu ∈ scen), # prior computation does not work on gpu epochs = 2, scenario, ); - @test all(isfinite.(probo.θP)) + @test all(isfinite.(CP.get_hybridproblem_θP(probo))) n_sample_pred = 12 (; y, θsP, θsMs, entropy_ζ) = predict_hvi(rng, probo; scenario, n_sample_pred); @test size(y) == (size(y_pred)..., n_sample_pred) diff --git a/test/test_sample_zeta.jl b/test/test_sample_zeta.jl index 6fc601f..86991fc 100644 --- a/test/test_sample_zeta.jl +++ b/test/test_sample_zeta.jl @@ -20,152 +20,213 @@ ggdev = Suppressor.@suppress gpu_device() cdev = cpu_device() prob = DoubleMM.DoubleMMCase() -scenario = Val((:default,)) - -n_θM, n_θP = length.(values(get_hybridproblem_par_templates(prob; scenario))) - -(; xM, θP_true, θMs_true, xP, y_true, y_o -) = gen_hybridproblem_synthetic(rng, prob; scenario) -n_site, n_batch = get_hybridproblem_n_site_and_batch(prob; scenario) - -FT = get_hybridproblem_float_type(prob; scenario) - -# set to 0.02 rather than zero for debugging non-zero correlations -cor_ends = (P=1:n_θP, M=[n_θM]) -ρsP = zeros(FT, get_cor_count(cor_ends.P)) .+ FT(0.02) -ρsM = zeros(FT, get_cor_count(cor_ends.M)) .+ FT(0.02) - -ϕunc = CA.ComponentVector(; - logσ2_ζP=fill(FT(-10.0), n_θP), - coef_logσ2_ζMs=reduce(hcat, (FT[-10.0, 0.0] for _ in 1:n_θM)), - ρsP, - ρsM) - -θ_true = θ = CA.ComponentVector(; - P=θP_true, - Ms=θMs_true) -transPMs = elementwise(exp) # all parameters on LogNormal scale -ζ_true = inverse(transPMs)(θ_true) -ϕ_true = vcat(ζ_true, CA.ComponentVector(unc=ϕunc)) -ϕ_cpu = vcat(ζ_true .+ FT(0.01), CA.ComponentVector(unc=ϕunc)) - -interpreters = (; pmu=ComponentArrayInterpreter(ϕ_true), - unc=ComponentArrayInterpreter(ϕ_true.unc) -) #, M=int_θM, PMs=int_θPMs) - -n_MC = 3 - -@testset "transpose_Ms_sitefirst" begin - x_true = collect(1:8) - tmp = Iterators.take(enumerate(Iterators.repeated(x_true)), n_MC) - collect(tmp) - Xt = permutedims(stack(map(tmp) do (i, x) - 10 .* i .+ x - end)) - _nP = 2; _nM = 3; _nsite = 2 - intm_PMs_parfirst = ComponentArrayInterpreter( - P = (n_MC, _nP), Ms = (n_MC, _nM, _nsite)) - Xtc = intm_PMs_parfirst(Xt) - # - X = @inferred CP.transpose_mPMs_sitefirst(Xt, _nP, _nM, _nsite, n_MC) - # using Cthulhu - # @descend_code_warntype CP.transpose_mPMs_sitefirst(Xt, _nP, _nM, _nsite, n_MC) - intm_PMs_sitefirst = ComponentArrayInterpreter( - P = (n_MC, _nP), Ms = (n_MC, _nsite, _nM)) - Xc = intm_PMs_sitefirst(X) - @test Xc.P == Xtc.P - @test Xc.Ms[:,1,:] == Xtc.Ms[:,:,1] # first site - @test Xc.Ms[:,2,:] == Xtc.Ms[:,:,2] - @test Xc.Ms[:,:,2] == Xtc.Ms[:,2,:] # second parameter -end; - -@testset "sample_ζresid_norm" begin - ϕ = CA.getdata(ϕ_cpu) - ϕc = interpreters.pmu(ϕ) - ϕc.unc.coef_logσ2_ζMs[1,:] .= (log ∘ abs2).((0.1, 100.0)) - ϕc.unc.ρsM .= 0.0 - int_unc = get_concrete(ComponentArrayInterpreter(ϕc.unc)) - n_MC_pred = 300 # larger n_MC to test σ2 - n_site_batch = size(ϕc.Ms,2) - ζP_resids, ζMs_parfirst_resids, σ = @inferred CP.sample_ζresid_norm(rng, ϕc.P, ϕc.Ms, ϕc.unc; - n_MC=n_MC_pred, cor_ends, int_unc) - # ζ_resid, σ = @inferred CP.sample_ζresid_norm(rng, ϕc.P, ϕc.Ms, ϕc.unc; - # n_MC, cor_ends, int_unc = interpreters.unc) - #@usingany Cthulhu - #@descend_code_warntype CP.sample_ζresid_norm(rng, ϕc.P, ϕc.Ms, ϕc.unc; n_MC, cor_ends, int_unc = get_concrete(interpreters.unc)) - #@descend_code_warntype CP.sample_ζresid_norm(rng, ϕc.P, ϕc.Ms, ϕc.unc; n_MC, cor_ends, int_unc = interpreters.unc) - #@test size(ζ_resid) == (length(ϕc.P) + n_site * n_θM, n_MC) - n_θM = size(ϕc.Ms,1) - @test size(ζP_resids) == (n_θP, n_MC_pred) - @test size(ζMs_parfirst_resids) == (n_θM, n_site_batch, n_MC_pred) - gr = Zygote.gradient(ϕc -> begin - ζP_resids, ζMs_parfirst_resids, σ = CP.sample_ζresid_norm( - rng, ϕc.P, ϕc.Ms, ϕc.unc; - n_MC, cor_ends, int_unc) - sum(ζP_resids) + sum(ζMs_parfirst_resids) - end, ϕc)[1] - @test length(gr) == length(ϕ) - # - n_θM, n_site_batch = size(ϕc.Ms) - # intm_PMs = ComponentArrayInterpreter( - # P = (n_MC_pred, n_θP), Ms = (n_MC_pred, n_site_batch, n_θM)) - # xc = intm_PMs(ζ_resid) - # isapprox(std(xc.Ms[:,1,1]), 0.1, rtol = 0.1) # site 1 parameter 1 - # isapprox(std(xc.Ms[:,:,1]), 0.1, rtol = 0.1) # parameter 1 - # isapprox(std(xc.Ms[:,:,2]), 100.1, rtol = 0.1) # parameter 2 - isapprox(std(ζMs_parfirst_resids[1,1,:]), 0.1, rtol = 0.1) # site 1 parameter 1 - isapprox(std(ζMs_parfirst_resids[1,:,:]), 0.1, rtol = 0.1) # parameter 1 - isapprox(std(ζMs_parfirst_resids[2,:,:]), 100.1, rtol = 0.1) # parameter 2 - - # - if ggdev isa MLDataDevices.AbstractGPUDevice - @testset "sample_ζresid_norm gpu" begin - ϕcd = CP.apply_preserve_axes(ggdev, ϕc); # semicolon necessary - @test CA.getdata(ϕcd) isa GPUArraysCore.AbstractGPUArray - #ζP, ζMs, ϕunc = ϕc.P, ϕc.Ms, ϕc.unc - #urandn = CUDA.randn(length(ϕc.P) + length(ϕc.Ms), n_MC) |> gpu - #include(joinpath(@__DIR__, "uncNN", "elbo.jl")) # callback_loss - #ζ_resid, σ = sample_ζresid_norm(urandn, ϕc.P, ϕc.Ms, ϕc.unc; n_MC) - #Zygote.gradient(ϕc -> sum(sample_ζresid_norm(urandn, ϕc.P, ϕc.Ms, ϕc.unc; n_MC)[1]), ϕc)[1]; - ζP_resids, ζMs_parfirst_resids, σ = @inferred CP.sample_ζresid_norm( - rng, CA.getdata(ϕcd.P), CA.getdata(ϕcd.Ms), CA.getdata(ϕcd.unc); - n_MC = n_MC_pred, cor_ends, int_unc) - #@descend_code_warntype CP.sample_ζresid_norm(rng, CA.getdata(ϕcd.P), CA.getdata(ϕcd.Ms), CA.getdata(ϕcd.unc); n_MC = n_MC_pred, cor_ends, int_unc) - @test ζP_resids isa GPUArraysCore.AbstractGPUArray - @test ζMs_parfirst_resids isa GPUArraysCore.AbstractGPUArray - @test size(ζP_resids) == (n_θP, n_MC_pred) - @test size(ζMs_parfirst_resids) == (n_θM, n_site_batch, n_MC_pred) - # Zygote gradient for many sites, use fewer sites here - n_site_few = 20 - ϕcd_few = CA.ComponentVector(; P = ϕcd.P, Ms = ϕcd.Ms[:,1:n_site_few], unc = ϕcd.unc); - gr = Zygote.gradient(ϕc -> begin - ζP_resids, ζMs_parfirst_resids, σ = CP.sample_ζresid_norm( - rng, CA.getdata(ϕc.P), CA.getdata(ϕc.Ms), CA.getdata(ϕc.unc); - n_MC, cor_ends, int_unc) - sum(ζP_resids) + sum(ζMs_parfirst_resids) - end, ϕcd_few)[1]; # semicolon required - # gr = Zygote.gradient( - # ϕc -> sum(CP.sample_ζresid_norm( - # rng, CA.getdata(ϕc.P), CA.getdata(ϕc.Ms), CA.getdata(ϕc.unc); - # n_MC, cor_ends, int_unc)[1]), ϕcd_few)[1]; # need semicolon - # @test CA.getdata(gr) isa GPUArraysCore.AbstractGPUArray - # CP.apply_preserve_axes(cdev, gr) - # - isapprox(std(ζMs_parfirst_resids[1,1,:]), 0.1, rtol = 0.1) # site 1 parameter 1 - isapprox(std(ζMs_parfirst_resids[1,:,:]), 0.1, rtol = 0.1) # parameter 1 - isapprox(std(ζMs_parfirst_resids[2,:,:]), 100.1, rtol = 0.1) # parameter 2 + +# scenario = Val((:no_globals,)) +# scenario = Val((:default,)) + +function test_with_scenario(scenario) + n_θP, n_θM = length.(values(get_hybridproblem_par_templates(prob; scenario))) + + (; xM, θP_true, θMs_true, xP, y_true, y_o + ) = gen_hybridproblem_synthetic(rng, prob; scenario) + n_site, n_batch = get_hybridproblem_n_site_and_batch(prob; scenario) + + FT = get_hybridproblem_float_type(prob; scenario) + + # set to 0.02 rather than zero for debugging non-zero correlations + #cor_ends = (P=1:n_θP, M=[n_θM]) # need to tell that its zero parameters instead of 1 + cor_ends = (P=(n_θP == 0 ? [0] : 1:n_θP), M=[n_θM]) + ρsP = zeros(FT, get_cor_count(cor_ends.P)) .+ FT(0.02) + ρsM = zeros(FT, get_cor_count(cor_ends.M)) .+ FT(0.02) + (; transP, transM) = get_hybridproblem_transforms(prob; scenario) + + ϕq = CA.ComponentVector(; + logσ2_ζP=fill(FT(-10.0), n_θP), + coef_logσ2_ζMs=reduce(hcat, (FT[-10.0, 0.0] for _ in 1:n_θM)), + ρsP, + ρsM, + ) + + ϕq_true = CP.update_μP_by_θP(ϕq, θP_true, transP) + ϕq = CA.ComponentVector(ϕq_true; μP = ϕq_true.μP .+ FT(0.01)) + + θ_true = θ = CA.ComponentVector(; + P=θP_true, + Ms=θMs_true) + ϕ_true = CA.ComponentVector(Ms = θMs_true, ϕq=ϕq_true) + ϕ_cpu = CA.ComponentVector(Ms = θMs_true .+ FT(0.01), ϕq=ϕq) + + interpreters = (; pmu=ComponentArrayInterpreter(ϕ_true), + ϕq=ComponentArrayInterpreter(ϕq) + ) #, M=int_θM, PMs=int_θPMs) + + n_MC = 3 + + @testset "transpose_Ms_sitefirst $(last(CP._val_value(scenario)))" begin + x_true = collect(1:8) + tmp = Iterators.take(enumerate(Iterators.repeated(x_true)), n_MC) + collect(tmp) + Xt = permutedims(stack(map(tmp) do (i, x) + 10 .* i .+ x + end)) + _nP = 2; _nM = 3; _nsite = 2 + intm_PMs_parfirst = ComponentArrayInterpreter( + P = (n_MC, _nP), Ms = (n_MC, _nM, _nsite)) + Xtc = intm_PMs_parfirst(Xt) + # + X = @inferred CP.transpose_mPMs_sitefirst(Xt, _nP, _nM, _nsite, n_MC) + # using Cthulhu + # @descend_code_warntype CP.transpose_mPMs_sitefirst(Xt, _nP, _nM, _nsite, n_MC) + intm_PMs_sitefirst = ComponentArrayInterpreter( + P = (n_MC, _nP), Ms = (n_MC, _nsite, _nM)) + Xc = intm_PMs_sitefirst(X) + #@test Xc.P == @inferred Xtc[:P] # need to use Val for type stability + @test Xc.P == @inferred Xtc[Val(:P)] + @test Xc.Ms[:,1,:] == Xtc.Ms[:,:,1] # first site + @test Xc.Ms[:,2,:] == Xtc.Ms[:,:,2] + @test Xc.Ms[:,:,2] == Xtc.Ms[:,2,:] # second parameter + end; + + # approx = MeanHVIApproximation() + # approx = MeanHVIApproximationMat() + # approx = CP.MeanHVIApproximationDev() + function test_sample_ζresid_norm(approx) + ϕc = copy(ϕ_cpu) + ϕc.ϕq.coef_logσ2_ζMs[1,:] .= (log ∘ abs2).((0.1, 100.0)) + ϕc.ϕq.ρsM .= 0.0 + int_ϕq = get_concrete(ComponentArrayInterpreter(ϕc.ϕq)) + n_MC_pred = 300 # larger n_MC to test σ2 + n_site_batch = size(ϕc.Ms,2) + #rng = StableRNG(111) + # @inferred gives any, while Cthulhu inferres concrete type + # ζP_resids, ζMs_parfirst_resids, σ = @inferred CP.sample_ζresid_norm(approx, rng, ϕc.Ms, ϕc.ϕq; + # n_MC=n_MC_pred, cor_ends, int_ϕq) + # @inferred first(CP.sample_ζresid_norm(approx, rng, ϕc.Ms, ϕc.ϕq; + # n_MC=n_MC_pred, cor_ends, int_ϕq)) + # ζP_resids, ζMs_parfirst_resids, σ = CP.sample_ζresid_norm(approx, rng, ϕc.P, ϕc.Ms, ϕc.ϕq; + # n_MC=n_MC_pred, cor_ends, int_ϕq) + ζP_resids, ζMs_parfirst_resids, σ = @inferred CP.sample_ζresid_norm(approx, rng, ϕc.Ms, ϕc.ϕq; + n_MC=n_MC_pred, cor_ends, int_ϕq) + #@code_warntype CP.sample_ζresid_norm(approx, rng, ϕc.Ms, ϕc.ϕq; n_MC=n_MC_pred, cor_ends, int_ϕq) + #@usingany Cthulhu + #@descend_code_warntype CP.sample_ζresid_norm(approx, rng, ϕc.Ms, ϕc.ϕq; n_MC=n_MC_pred, cor_ends, int_ϕq) + #@test size(ζ_resid) == (length(ϕc.P) + n_site * n_θM, n_MC) + n_θM = size(ϕc.Ms,1) + @test size(ζP_resids) == (n_θP, n_MC_pred) + @test size(ζMs_parfirst_resids) == (n_θM, n_site_batch, n_MC_pred) + gr = + Zygote.gradient(ϕc -> begin + ζP_resids, ζMs_parfirst_resids, σ = CP.sample_ζresid_norm( + approx, rng, ϕc.Ms, ϕc.ϕq; + n_MC, cor_ends, int_ϕq) + sum(ζP_resids) + sum(ζMs_parfirst_resids) + end, ϕc)[1] + @test length(gr) == length(ϕc) + # + n_θM, n_site_batch = size(ϕc.Ms) + # intm_PMs = ComponentArrayInterpreter( + # P = (n_MC_pred, n_θP), Ms = (n_MC_pred, n_site_batch, n_θM)) + # xc = intm_PMs(ζ_resid) + # isapprox(std(xc.Ms[:,1,1]), 0.1, rtol = 0.1) # site 1 parameter 1 + # isapprox(std(xc.Ms[:,:,1]), 0.1, rtol = 0.1) # parameter 1 + # isapprox(std(xc.Ms[:,:,2]), 100.1, rtol = 0.1) # parameter 2 + isapprox(std(ζMs_parfirst_resids[1,1,:]), 0.1, rtol = 0.1) # site 1 parameter 1 + isapprox(std(ζMs_parfirst_resids[1,:,:]), 0.1, rtol = 0.1) # parameter 1 + isapprox(std(ζMs_parfirst_resids[2,:,:]), 100.1, rtol = 0.1) # parameter 2 + # + if ggdev isa MLDataDevices.AbstractGPUDevice + @testset "sample_ζresid_norm gpu" begin + ϕcd = CP.apply_preserve_axes(ggdev, ϕc); # semicolon necessary + @test CA.getdata(ϕcd) isa GPUArraysCore.AbstractGPUArray + #ζP, ζMs, ϕq = ϕc.P, ϕc.Ms, ϕc.ϕq + #urandn = CUDA.randn(length(ϕc.P) + length(ϕc.Ms), n_MC) |> gpu + #include(joinpath(@__DIR__, "uncNN", "elbo.jl")) # callback_loss + #ζ_resid, σ = sample_ζresid_norm(urandn, ϕc.Ms, ϕc.ϕq; n_MC) + #Zygote.gradient(ϕc -> sum(sample_ζresid_norm(urandn, ϕc.Ms, ϕc.ϕq; n_MC)[1]), ϕc)[1]; + # @inferred first(CP.sample_ζresid_norm( + # approx, rng, CA.getdata(ϕcd.Ms), CA.getdata(ϕcd.ϕq); + # n_MC = n_MC_pred, cor_ends, int_ϕq)) + # ζP_resids, ζMs_parfirst_resids, σ = CP.sample_ζresid_norm( + # approx, rng, CA.getdata(ϕcd.Ms), CA.getdata(ϕcd.ϕq); + # n_MC = n_MC_pred, cor_ends, int_ϕq) + ζP_resids, ζMs_parfirst_resids, σ = @inferred CP.sample_ζresid_norm( + approx, rng, CA.getdata(ϕcd.Ms), CA.getdata(ϕcd.ϕq); + n_MC = n_MC_pred, cor_ends, int_ϕq) + #@descend_code_warntype CP.sample_ζresid_norm(rng, CA.getdata(ϕcd.Ms), CA.getdata(ϕcd.ϕq); n_MC = n_MC_pred, cor_ends, int_ϕq) + @test ζP_resids isa GPUArraysCore.AbstractGPUArray + @test ζMs_parfirst_resids isa GPUArraysCore.AbstractGPUArray + @test size(ζP_resids) == (n_θP, n_MC_pred) + @test size(ζMs_parfirst_resids) == (n_θM, n_site_batch, n_MC_pred) + # Zygote gradient for many sites, use fewer sites here + n_site_few = 20 + # replacing Ms in ComponentVector by different length does not work on GPU + # using workaround by NamedTuples, results in ScalarIndexing, need explicit + # ϕcd_few = CA.ComponentVector(ϕcd; Ms = ϕcd.Ms[:,1:n_site_few]); + ϕcd_few = CA.ComponentVector(Ms = ϕcd.Ms[:,1:n_site_few], ϕq = ϕcd.ϕq); + #@usingany BenchmarkTools + gr = + #@profview Zygote.gradient(ϕc -> begin # type stable, most time spent in mapreduce + #@benchmark Zygote.gradient(ϕc -> begin # many small allocs + Zygote.gradient(ϕc -> begin + ζP_resids, ζMs_parfirst_resids, σ = CP.sample_ζresid_norm( + approx, rng, CA.getdata(ϕc.Ms), CA.getdata(ϕc.ϕq); + n_MC, cor_ends, int_ϕq) + sum(ζP_resids) + sum(ζMs_parfirst_resids) + end, ϕcd_few)[1]; # semicolon required + # + isapprox(std(ζMs_parfirst_resids[1,1,:]), 0.1, rtol = 0.1) # site 1 parameter 1 + isapprox(std(ζMs_parfirst_resids[1,:,:]), 0.1, rtol = 0.1) # parameter 1 + isapprox(std(ζMs_parfirst_resids[2,:,:]), 100.1, rtol = 0.1) # parameter 2 + () -> begin + CP.sample_ζresid_norm( + #@benchmark CP.sample_ζresid_norm( + approx, rng, ϕc.Ms, ϕc.ϕq; + n_MC, cor_ends, int_ϕq) + # + CP.sample_ζresid_norm( + #@benchmark CP.sample_ζresid_norm( + approx, rng, ϕcd.Ms, ϕcd.ϕq; + n_MC, cor_ends, int_ϕq) + # + ϕc_few = CA.ComponentVector(ϕc; Ms = ϕc.Ms[:,1:n_site_few]); + Zygote.gradient(ϕc -> begin + #@benchmark Zygote.gradient(ϕc -> begin # many small allocs + ζP_resids, ζMs_parfirst_resids, σ = CP.sample_ζresid_norm( + approx, rng, ϕc.Ms, ϕc.ϕq; + n_MC, cor_ends, int_ϕq) + sum(ζP_resids) + sum(ζMs_parfirst_resids) + end, ϕc_few)[1] + Zygote.gradient(ϕc -> begin # many small allocs + #@benchmark Zygote.gradient(ϕc -> begin # many small allocs + ζP_resids, ζMs_parfirst_resids, σ = CP.sample_ζresid_norm( + approx, rng, CA.getdata(ϕc.Ms), CA.getdata(ϕc.ϕq); + n_MC, cor_ends, int_ϕq) + sum(ζP_resids) + sum(ζMs_parfirst_resids) + end, ϕcd_few)[1] + end + + end end end + + + @testset "sample_ζresid_norm MeanHVIApproximationMat $(last(CP._val_value(scenario)))" begin + approx = MeanHVIApproximationMat() + test_sample_ζresid_norm(approx) + end + + @testset "sample_ζresid_norm MeanHVIApproximation $(last(CP._val_value(scenario)))" begin + approx = MeanHVIApproximation() + test_sample_ζresid_norm(approx) + end +end + +@testset "default scenario" begin + scenario = Val((:default,)) + test_with_scenario(scenario) end -# @testset "generate_ζ" begin -# ϕ = CA.getdata(ϕ_cpu) -# n_sample_pred = 200 -# intm_PMs_gen = ComponentArrayInterpreter(CA.ComponentVector(; θP_true, -# θMs=CA.ComponentMatrix( -# zeros(n_θM, n_site), first(CA.getaxes(θMs_true)), CA.Axis(i=1:n_sample_pred)))) -# int_μP_ϕg_unc=ComponentArrayInterpreter(ϕ_true) -# interpreters = (; PMs = intm_PMs_gen, μP_ϕg_unc = int_μP_ϕg_unc ) -# ζs, _ = CP.generate_ζ(rng, g, ϕ, xM, interpreters; n_MC=n_sample_pred) - -# end; +@testset "noglobals scenario" begin + scenario = Val((:no_globals,)) + test_with_scenario(scenario) +end