Add hermitic enforcer and gradient test

This commit is contained in:
Deaglan Bartlett 2024-06-11 14:52:48 +02:00
parent c1924ab758
commit 81d0e70965
10 changed files with 414 additions and 113 deletions

2
.gitignore vendored
View file

@ -162,3 +162,5 @@ cython_debug/
# Borg # Borg
*allocation_stats_0.txt *allocation_stats_0.txt
*timing_stats_0.txt *timing_stats_0.txt
*fft_wisdom
tests/*.h5

View file

@ -95,7 +95,6 @@ class VelocityBORGLikelihood(borg.likelihood.BaseLikelihood):
# Initialise cosmological parameters # Initialise cosmological parameters
cpar = utils.get_cosmopar(self.ini_file) cpar = utils.get_cosmopar(self.ini_file)
self.fwd.setCosmoParams(cpar) self.fwd.setCosmoParams(cpar)
# self.fwd_vel.setCosmoParams(cpar)
self.fwd_param.setCosmoParams(cpar) self.fwd_param.setCosmoParams(cpar)
self.updateCosmology(cpar) self.updateCosmology(cpar)
myprint(f"Original cosmological parameters: {self.fwd.getCosmoParams()}") myprint(f"Original cosmological parameters: {self.fwd.getCosmoParams()}")
@ -138,7 +137,6 @@ class VelocityBORGLikelihood(borg.likelihood.BaseLikelihood):
cpar = state['cosmology'] cpar = state['cosmology']
cpar.omega_q = 1. - cpar.omega_m - cpar.omega_k cpar.omega_q = 1. - cpar.omega_m - cpar.omega_k
self.fwd.setCosmoParams(cpar) self.fwd.setCosmoParams(cpar)
# self.fwd_vel.setCosmoParams(cpar)
self.fwd_param.setCosmoParams(cpar) self.fwd_param.setCosmoParams(cpar)
@ -159,14 +157,13 @@ class VelocityBORGLikelihood(borg.likelihood.BaseLikelihood):
cpar.omega_q = 1. - cpar.omega_m - cpar.omega_k cpar.omega_q = 1. - cpar.omega_m - cpar.omega_k
self.fwd.setCosmoParams(cpar) self.fwd.setCosmoParams(cpar)
# self.fwd_vel.setCosmoParams(cpar)
self.fwd_param.setCosmoParams(cpar) self.fwd_param.setCosmoParams(cpar)
# Compute growth rate # # Compute growth rate
cosmology = borg.cosmo.Cosmology(cosmo) # cosmology = borg.cosmo.Cosmology(cosmo)
f = cosmology.gplus(self.af) # dD / da # f = cosmology.gplus(self.af) # dD / da
f *= self.af / cosmology.d_plus(self.af) # f = dlnD / dlna # f *= self.af / cosmology.d_plus(self.af) # f = dlnD / dlna
self.f = f # self.f = f
def generateMBData(self) -> None: def generateMBData(self) -> None:
""" """
@ -249,9 +246,6 @@ class VelocityBORGLikelihood(borg.likelihood.BaseLikelihood):
bulk_flow = jnp.array([self.fwd_param.getModelParam('nullforward', 'bulk_flow_x'), bulk_flow = jnp.array([self.fwd_param.getModelParam('nullforward', 'bulk_flow_x'),
self.fwd_param.getModelParam('nullforward', 'bulk_flow_y'), self.fwd_param.getModelParam('nullforward', 'bulk_flow_y'),
self.fwd_param.getModelParam('nullforward', 'bulk_flow_z')]) self.fwd_param.getModelParam('nullforward', 'bulk_flow_z')])
# v = forwards.dens2vel_linear(output_density, self.f,
# self.fwd.getOutputBoxModel().L[0], self.smooth_R)
# v = v + self.bulk_flow.reshape((3, 1, 1, 1))
v = output_velocity + self.bulk_flow.reshape((3, 1, 1, 1)) v = output_velocity + self.bulk_flow.reshape((3, 1, 1, 1))
omega_m = self.fwd.getCosmoParams().omega_m omega_m = self.fwd.getCosmoParams().omega_m
@ -276,6 +270,7 @@ class VelocityBORGLikelihood(borg.likelihood.BaseLikelihood):
self.interp_order, self.interp_order,
self.bias_epsilon self.bias_epsilon
) )
# lkl = (output_density**2).sum()
if not jnp.isfinite(lkl): if not jnp.isfinite(lkl):
lkl = self.bignum lkl = self.bignum
@ -364,7 +359,7 @@ class VelocityBORGLikelihood(borg.likelihood.BaseLikelihood):
state["BORG_final_density"][:] = self.delta state["BORG_final_density"][:] = self.delta
@partial(jax.jit, static_argnames=['L_BOX', 'interp_order', 'bias_epsilon']) # @partial(jax.jit, static_argnames=['L_BOX', 'interp_order', 'bias_epsilon'])
def vel2like(cz_obs, v, MB_field, MB_pos, r, r_hMpc, sig_mu, sig_v, omega_m, muA, alpha, L_BOX, X_MIN, interp_order, bias_epsilon): def vel2like(cz_obs, v, MB_field, MB_pos, r, r_hMpc, sig_mu, sig_v, omega_m, muA, alpha, L_BOX, X_MIN, interp_order, bias_epsilon):
""" """
Jitted part of dens2like Jitted part of dens2like
@ -420,6 +415,13 @@ def vel2like(cz_obs, v, MB_field, MB_pos, r, r_hMpc, sig_mu, sig_v, omega_m, muA
lkl_ind = jnp.log(p_cz) - scale / 2 - 0.5 * jnp.log(2 * np.pi * sig_v**2) lkl_ind = jnp.log(p_cz) - scale / 2 - 0.5 * jnp.log(2 * np.pi * sig_v**2)
lkl = - lkl_ind.sum() lkl = - lkl_ind.sum()
# # DELETE THIS
# p_cz = jnp.trapz(p_r / p_r_norm, r, axis=1)
# lkl_ind = jnp.log(p_cz) - 0.5 * jnp.log(2 * np.pi * sig_v**2)
# lkl = - lkl_ind.sum()
# lkl = los_density.sum()
# lkl = (MB_field**2).sum()
return lkl return lkl
@ -454,6 +456,7 @@ def build_gravity_model(state: borg.likelihood.MarkovState, box: borg.forward.Bo
# Setup forward model # Setup forward model
chain = borg.forward.ChainForwardModel(box) chain = borg.forward.ChainForwardModel(box)
chain.addModel(borg.forward.models.HermiticEnforcer(box))
# CLASS transfer function # CLASS transfer function
chain @= borg.forward.model_lib.M_PRIMORDIAL_AS(box) chain @= borg.forward.model_lib.M_PRIMORDIAL_AS(box)
@ -525,7 +528,15 @@ def build_gravity_model(state: borg.likelihood.MarkovState, box: borg.forward.Bo
fwd_param.setCosmoParams(cpar) fwd_param.setCosmoParams(cpar)
# This is the forward model for velocity # This is the forward model for velocity
fwd_vel = borg.forward.velocity.LinearModel(box, mod, af) velmodel_name = config['model']['velocity']
velmodel = getattr(borg.forward.velocity, velmodel_name)
if velmodel_name == 'LinearModel':
fwd_vel = velmodel(box, mod, af)
elif velmodel_name == 'CICModel':
rsmooth = float(config['model']['rsmooth'])
fwd_vel = velmodel(box, mod, rsmooth)
else:
fwd_vel = velmodel(box, mod)
return chain return chain

View file

@ -1,9 +1,9 @@
[system] [system]
console_output = borg_log console_output = borg_log
VERBOSE_LEVEL = 2 VERBOSE_LEVEL = 2
N0 = 32 N0 = 8
N1 = 32 N1 = 8
N2 = 32 N2 = 8
L0 = 500.0 L0 = 500.0
L1 = 500.0 L1 = 500.0
L2 = 500.0 L2 = 500.0
@ -42,12 +42,14 @@ mixing = 1
[model] [model]
gravity = lpt gravity = lpt
velocity = CICModel
af = 1.0 af = 1.0
ai = 0.05 ai = 0.05
nsteps = 20 nsteps = 20
smooth_R = 4 smooth_R = 4
bias_epsilon = 1e-7 bias_epsilon = 1e-7
interp_order = 1 interp_order = 1
rsmooth = 1.
sig_v = 150. sig_v = 150.
R_lim = none R_lim = none
Nint_points = 201 Nint_points = 201

BIN
figs/gradient_test_8.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

File diff suppressed because one or more lines are too long

View file

@ -1,20 +1,30 @@
Memory still allocated at the end: 31.8652 MB Memory still allocated at the end: 10.0405 MB
Statistics per context (name, allocated, freed, peak) Statistics per context (name, allocated, freed, peak)
====================== ======================
*none* 76.2188 0.250069 32.2871 *none* 6.2686 0.141525 10.1813
BORG LPT MODEL 505.495 503.727 32.3027 BORG LPT MODEL 35.397 35.3694 10.1823
BORGForwardModel::setup 0.000160217 0 2.23588 BORGForwardModel::setup 0.000183105 0 0.039917
BorgLptModel::BorgLptModel 1.54688 0 2.23581 BorgLptModel::BorgLptModel 0.0263672 0 0.0398483
LinearModel::getVelocityField 607.75 589.875 33.1465 BorgLptModel::~BorgLptModel 0 0.0315552 0
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/chain_forward_model.cpp]virtual void LibLSS::ChainForwardModel::forwardModel_v2(LibLSS::detail_input::ModelInput<3>) 227.906 75.9688 32.5527 CICModel::getVelocityField 18.8408 16.9146 10.1931
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/forward_model.cpp]void LibLSS::BORGForwardModel::setupDefault() 0.53125 0 0.688934 CICModel::getVelocityFieldAlpha 56.3818 50.7437 10.2018
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/forwards/borg_lpt.cpp]std::shared_ptr<LibLSS::BORGForwardModel> build_borg_lpt(std::shared_ptr<LibLSS::MPI_Communication>, const LibLSS::BoxModel&, const LibLSS::PropertyProxy&) [with Grid = LibLSS::ClassicCloudInCell<double>; LibLSS::BoxModel = LibLSS::NBoxModel<3>] 0 0 0.157661 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/chain_forward_model.cpp]virtual void LibLSS::ChainForwardModel::forwardModel_v2(LibLSS::detail_input::ModelInput<3>) 25.0391 6.25977 10.1862
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/forwards/particle_balancer/balanceinfo.hpp]void LibLSS::BalanceInfo::allocate(LibLSS::MPI_Communication*, size_t) 72.2135 71.961 32.3027 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/chain_forward_model.cpp]void LibLSS::ChainForwardModel::trigger_ag() 0.0195312 0.00390625 0.22258
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/forwards/primordial_as.cpp]std::shared_ptr<LibLSS::BORGForwardModel> build_primordial_as(std::shared_ptr<LibLSS::MPI_Communication>, const LibLSS::BoxModel&, const LibLSS::PropertyProxy&) 0.078804 7.62939e-06 0.0788498 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/forward_model.cpp]void LibLSS::BORGForwardModel::setupDefault() 0.00976562 0 0.0134811
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/forwards/transfer_class.cpp]std::shared_ptr<LibLSS::BORGForwardModel> build_class(std::shared_ptr<LibLSS::MPI_Communication>, const LibLSS::BoxModel&, const LibLSS::PropertyProxy&) 0.078804 7.62939e-06 0.157669 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/forwards/borg_lpt.cpp]std::shared_ptr<LibLSS::BORGForwardModel> build_borg_lpt(std::shared_ptr<LibLSS::MPI_Communication>, const LibLSS::BoxModel&, const LibLSS::PropertyProxy&) [with Grid = LibLSS::ClassicCloudInCell<double>; LibLSS::BoxModel = LibLSS::NBoxModel<3>] 0 0 0.00369263
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/model_io/base.hpp]void LibLSS::detail_model::ModelIO<Nd>::transfer(LibLSS::detail_model::ModelIO<Nd>&&) [with long unsigned int Nd = 3] 0 222.656 0 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/forwards/lpt/borg_fwd_lpt_adj.cpp]void LibLSS::BorgLptModel<CIC>::clearAdjointGradient() [with CIC = LibLSS::ClassicCloudInCell<double>] 0 0.0236664 0
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/samplers/core/gridLikelihoodBase.cpp]LibLSS::GridDensityLikelihoodBase<Dims>::GridDensityLikelihoodBase(LibLSS::MPI_Communication*, const GridSizes&, const GridLengths&) [with int Dims = 3; GridSizes = std::array<long unsigned int, 3>; GridLengths = std::array<double, 3>] 0.53125 0.515625 2.76713 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/forwards/lpt/borg_fwd_lpt_adj.cpp]void LibLSS::BorgLptModel<CIC>::preallocate() [with CIC = LibLSS::ClassicCloudInCell<double>] 0.0236664 0 0.295334
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/python/pyforward.cpp]void do_get_density_final(LibLSS::BORGForwardModel*, pybind11::array) 75.9688 71.5 32.3027 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/forwards/particle_balancer/balanceinfo.hpp]void LibLSS::BalanceInfo::allocate(LibLSS::MPI_Communication*, size_t) 15.0802 15.0684 10.1823
lpt_ic 75.9688 75.9688 32.5683 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/forwards/primordial_as.cpp]std::shared_ptr<LibLSS::BORGForwardModel> build_primordial_as(std::shared_ptr<LibLSS::MPI_Communication>, const LibLSS::BoxModel&, const LibLSS::PropertyProxy&) 0.00180817 7.62939e-06 0.00187683
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/forwards/transfer_class.cpp]std::shared_ptr<LibLSS::BORGForwardModel> build_class(std::shared_ptr<LibLSS::MPI_Communication>, const LibLSS::BoxModel&, const LibLSS::PropertyProxy&) 0.00180817 7.62939e-06 0.00370026
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/model_io/base.hpp]void LibLSS::detail_model::ModelIO<Nd>::transfer(LibLSS::detail_model::ModelIO<Nd>&&) [with long unsigned int Nd = 3] 0 23.7539 0
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/velocity/velocity_cic.cpp]virtual void LibLSS::VelocityModel::CICModel::computeAdjointModel(LibLSS::VelocityModel::Base::arrayVelocityField_t) 0.197266 0.189941 0.27655
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/samplers/core/gridLikelihoodBase.cpp]LibLSS::GridDensityLikelihoodBase<Dims>::GridDensityLikelihoodBase(LibLSS::MPI_Communication*, const GridSizes&, const GridLengths&) [with int Dims = 3; GridSizes = std::array<long unsigned int, 3>; GridLengths = std::array<double, 3>] 0.00976562 0.00878906 0.0496826
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/tools/mpi/ghost_planes.hpp]void LibLSS::GhostPlanes<T, Nd>::setup(LibLSS::MPI_Communication*, PlaneList&&, PlaneSet&&, DimList&&, size_t) [with PlaneList = std::set<long int>&; PlaneSet = std::set<long int>&; DimList = std::array<long int, 2>&; T = std::complex<double>; long unsigned int Nd = 2; size_t = long unsigned int] 7.62939e-06 3.8147e-05 5.34058e-05
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/python/pyforward.cpp]void do_get_adjoint_model(LibLSS::BORGForwardModel*, pybind11::array) 0.00488281 0.00488281 0.227463
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/python/pyforward.cpp]void do_get_density_final(LibLSS::BORGForwardModel*, pybind11::array) 6.25977 5.00781 10.1823
dispatch_plane_map 7.24792e-05 4.19617e-05 0.000125885
exchanging nearby planes after projection 2.50635 2.50635 10.1926
lpt_ic 6.25977 6.25977 10.1872

View file

@ -1,28 +1,71 @@
(fftw-3.3.10 fftw_wisdom #x3c273403 #x192df114 #x4d08727c #xe98e9b9d (fftw-3.3.10 fftw_wisdom #x3c273403 #x192df114 #x4d08727c #xe98e9b9d
(fftw_dft_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #x21347a5d #x286e0d10 #xabf9ff02 #xccdf80a5) (fftw_codelet_r2cf_16 2 #x10bdd #x10bdd #x0 #xa7e83312 #x11c3dce9 #x403202b1 #xba9376e9)
(fftw_dft_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #xe7f77f6a #xaf2de8b8 #xad19bc70 #x80305f29) (fftw_dft_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #xe2b7638c #xca3eaae0 #xe5990134 #x15b362bd)
(fftw_codelet_n1bv_32_avx 0 #x10bdd #x10bdd #x0 #x6d197f20 #xfc9cbd23 #x91ddb367 #x208619cb)
(fftw_dft_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #x1f2e97fe #x61895cd8 #x6073a2f5 #x6ada2663)
(fftw_dft_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #x84033142 #x81339a41 #xb78a491e #x66362e05)
(fftw_dft_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #x0ac209ed #x737616a2 #xc31f0ad8 #x13c3716f)
(fftw_rdft2_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #x40ffeb6f #x4d232a35 #x49c61e65 #x4d75fa83)
(fftw_codelet_n1bv_32_avx 0 #x10bdd #x10bdd #x0 #x35d0d312 #x6b498ae1 #x1ddcffdc #x4a1a1998)
(fftw_dft_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #xbffceb36 #x5b340e87 #xc2433c88 #x10e155b2)
(fftw_codelet_r2cf_32 2 #x10bdd #x10bdd #x0 #xe5219ff5 #x7cc0cc2f #x9ce07377 #x12d27b02)
(fftw_dft_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #xd78cc60c #x6e1210c6 #x5868829d #x70ada990)
(fftw_codelet_r2cf_32 2 #x10bdd #x10bdd #x0 #x68269cfc #xb89b69b3 #x4eaad8fa #x9807c679)
(fftw_rdft2_rank_geq2_register 0 #x10bdd #x10bdd #x0 #x7446ec55 #x3f800a5f #xba25afcf #xc0e9d5c1)
(fftw_rdft2_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #x7ec9785e #x02957b55 #xab1017dc #xdcd04ed7)
(fftw_rdft2_rank_geq2_register 0 #x10bdd #x10bdd #x0 #x68900aea #xb640ce9e #xcd3b0e06 #x8170fa63)
(fftw_dft_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #x404fdd72 #x2323d034 #xc860c577 #x4779492a)
(fftw_rdft2_rank_geq2_register 0 #x10bdd #x10bdd #x0 #x3c2e2a1a #x07c08954 #x35c337d9 #x80864862)
(fftw_codelet_n1fv_32_sse2 0 #x10bdd #x10bdd #x0 #xe61c7c8d #x2cea019e #x8489a633 #x8d6543c6)
(fftw_rdft2_rank_geq2_register 0 #x10bdd #x10bdd #x0 #x962543ac #xb000f636 #xb27fc586 #xd4a83bb7)
(fftw_codelet_n1fv_32_avx 0 #x10bdd #x10bdd #x0 #x94cb38f8 #xed5987e0 #xa3d4151a #xeb412d04)
(fftw_codelet_r2cb_32 2 #x10bdd #x10bdd #x0 #x92bf92d5 #xdc456f1e #x5a32a424 #xe1f76e14)
(fftw_codelet_n1fv_32_avx 0 #x10bdd #x10bdd #x0 #xb5d7d23e #x26089494 #x55133ef3 #x8ac38174)
(fftw_dft_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #xe0a3b250 #xab7e7c07 #xf0935dde #x1568a95f)
(fftw_codelet_r2cb_32 2 #x10bdd #x10bdd #x0 #x4e6e3714 #xebce55aa #x0ede5253 #x4faf4524)
(fftw_codelet_n1bv_32_sse2 0 #x10bdd #x10bdd #x0 #x902cd310 #xa659999d #x6fde2637 #xb23e4fd2) (fftw_codelet_n1bv_32_sse2 0 #x10bdd #x10bdd #x0 #x902cd310 #xa659999d #x6fde2637 #xb23e4fd2)
(fftw_codelet_n1bv_16_sse2 0 #x10bdd #x10bdd #x0 #x9306ed57 #x98c44e85 #x5cdf298e #xbcec4b1f)
(fftw_codelet_n1bv_8_sse2 0 #x10bdd #x10bdd #x0 #xa80dd5c4 #x9fd5b8d4 #x3d6788bf #x5a24b1fc)
(fftw_dft_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #x40741233 #x3efc06b3 #x0f24264f #x64099f05)
(fftw_dft_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #x4b54e3ca #x4f94ebf3 #x244f4da3 #x2412ca79) (fftw_dft_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #x4b54e3ca #x4f94ebf3 #x244f4da3 #x2412ca79)
(fftw_codelet_n1fv_32_avx 0 #x10bdd #x10bdd #x0 #x94cb38f8 #xed5987e0 #xa3d4151a #xeb412d04)
(fftw_dft_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #x84033142 #x81339a41 #xb78a491e #x66362e05)
(fftw_dft_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #xcaf756bf #x6e71602c #x20e86581 #x110e9e90)
(fftw_rdft2_rank_geq2_register 0 #x10bdd #x10bdd #x0 #x3ca106a5 #xda967bc9 #xbb014751 #x74e4e6ae)
(fftw_codelet_n1fv_32_sse2 0 #x10bdd #x10bdd #x0 #xe61c7c8d #x2cea019e #x8489a633 #x8d6543c6)
(fftw_dft_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #x2e35848a #x0ae8a985 #xadfbead1 #xe429563d)
(fftw_codelet_r2cf_32 2 #x10bdd #x10bdd #x0 #xe5219ff5 #x7cc0cc2f #x9ce07377 #x12d27b02)
(fftw_rdft2_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #x6b14be63 #x1d99ab98 #xe3227f85 #xb1db4db0)
(fftw_codelet_n1fv_16_sse2 0 #x10bdd #x10bdd #x0 #xf8443ec2 #xfa3955a3 #xa7e19627 #xab87bd57)
(fftw_dft_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #xa3839252 #xea4efad1 #xaf8b0cda #xd8776397)
(fftw_dft_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #xa7f53555 #x21d66b4e #x9964caab #xd7909594)
(fftw_codelet_r2cf_8 2 #x10bdd #x10bdd #x0 #x27bdc5f1 #x0e0fc54e #x15095bf2 #x0e78cf6f)
(fftw_codelet_r2cf_16 2 #x10bdd #x10bdd #x0 #xc41f6ea8 #x979a9054 #x4af7b3f3 #xcbc1bd6e)
(fftw_codelet_n1bv_32_avx 0 #x10bdd #x10bdd #x0 #x6d197f20 #xfc9cbd23 #x91ddb367 #x208619cb)
(fftw_codelet_r2cf_32 2 #x10bdd #x10bdd #x0 #x68269cfc #xb89b69b3 #x4eaad8fa #x9807c679)
(fftw_dft_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #x8de57ca6 #x4d942122 #xcc9f63a3 #xda26628d)
(fftw_rdft2_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #x4cae513c #xd64a8afb #x187c71d1 #xb541a5b8)
(fftw_codelet_n1fv_32_avx 0 #x10bdd #x10bdd #x0 #xb5d7d23e #x26089494 #x55133ef3 #x8ac38174)
(fftw_codelet_n1fv_8_sse2 0 #x10bdd #x10bdd #x0 #x7035d47e #x31f840f3 #x9383f4ab #x075b88bb)
(fftw_rdft2_rank_geq2_register 0 #x10bdd #x10bdd #x0 #x7446ec55 #x3f800a5f #xba25afcf #xc0e9d5c1)
(fftw_codelet_n1bv_16_sse2 0 #x10bdd #x10bdd #x0 #xd9d77a34 #x2764630e #xaa589a35 #xc9be81db)
(fftw_dft_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #xe7f77f6a #xaf2de8b8 #xad19bc70 #x80305f29)
(fftw_dft_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #x37e6a727 #xc85b1b7c #x65d78a7d #xf0595850)
(fftw_rdft2_rank_geq2_register 0 #x10bdd #x10bdd #x0 #x962543ac #xb000f636 #xb27fc586 #xd4a83bb7)
(fftw_rdft2_rank_geq2_register 0 #x10bdd #x10bdd #x0 #x68900aea #xb640ce9e #xcd3b0e06 #x8170fa63)
(fftw_dft_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #x0ac209ed #x737616a2 #xc31f0ad8 #x13c3716f)
(fftw_dft_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #x21347a5d #x286e0d10 #xabf9ff02 #xccdf80a5)
(fftw_codelet_n1bv_16_avx 0 #x10bdd #x10bdd #x0 #x36abc7b8 #x1cd3eb8f #xa4996ada #x1a06c95a)
(fftw_rdft2_rank_geq2_register 0 #x10bdd #x10bdd #x0 #x855943e1 #x80e0a0ca #xd37ea014 #x23f0deee)
(fftw_dft_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #xbffceb36 #x5b340e87 #xc2433c88 #x10e155b2)
(fftw_codelet_n1fv_16_sse2 0 #x10bdd #x10bdd #x0 #x7304fb62 #xa799c05d #xa4bd6105 #x6d7bd16b)
(fftw_codelet_n1fv_8_sse2 0 #x10bdd #x10bdd #x0 #xdbede2d6 #x5032ed11 #x297abbbf #x39122c9f)
(fftw_codelet_r2cb_16 2 #x10bdd #x10bdd #x0 #x5bdedfde #x107be498 #x869a0bfb #x7cc04b4f)
(fftw_rdft2_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #x7ec9785e #x02957b55 #xab1017dc #xdcd04ed7)
(fftw_dft_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #x45123427 #x01281369 #xb95432bf #x1feb837a)
(fftw_dft_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #x91265544 #x90ab0f94 #x1c6548b3 #xe92ee441)
(fftw_dft_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #x99251b68 #x8a372a47 #xa305bb39 #x4df59c76)
(fftw_rdft2_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #x40ffeb6f #x4d232a35 #x49c61e65 #x4d75fa83)
(fftw_rdft2_rank_geq2_register 0 #x10bdd #x10bdd #x0 #xe6ba1829 #x368612bb #x2bdab11c #x2fc35e23)
(fftw_dft_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #x404fdd72 #x2323d034 #xc860c577 #x4779492a)
(fftw_rdft2_rank_geq2_register 0 #x10bdd #x10bdd #x0 #xc3c9e752 #x39b3927b #x7df101ab #x79309943)
(fftw_rdft2_rank_geq2_register 0 #x10bdd #x10bdd #x0 #x7b0c4ef3 #x2018ef0d #xa437b495 #xaddfa382)
(fftw_dft_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #x7e4e30fa #xc1ef6b3d #xbc1076dd #xc79407b9)
(fftw_codelet_r2cb_32 2 #x10bdd #x10bdd #x0 #x4e6e3714 #xebce55aa #x0ede5253 #x4faf4524)
(fftw_dft_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #xd78cc60c #x6e1210c6 #x5868829d #x70ada990)
(fftw_codelet_n1bv_8_sse2 0 #x10bdd #x10bdd #x0 #x90888d2b #x6076f166 #x437260f2 #x93ff29c3)
(fftw_codelet_n1bv_16_avx 0 #x10bdd #x10bdd #x0 #xdf3d687a #xe46fb97f #x6ee0e7aa #x945d2abd)
(fftw_dft_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #xdd819205 #xc9fe9ea4 #x32ec81f1 #x4bbca283)
(fftw_codelet_n1bv_32_avx 0 #x10bdd #x10bdd #x0 #x35d0d312 #x6b498ae1 #x1ddcffdc #x4a1a1998)
(fftw_rdft2_rank_geq2_register 0 #x10bdd #x10bdd #x0 #x2d4d9e0b #x4a34f327 #x275f3ae1 #x25641e46)
(fftw_dft_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #xe0a3b250 #xab7e7c07 #xf0935dde #x1568a95f)
(fftw_dft_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #x9ff9c3f3 #xf143b736 #xce2dc789 #x4d442c4a)
(fftw_rdft2_rank_geq2_register 0 #x10bdd #x10bdd #x0 #x0f7b58ed #xae4d4f79 #xe2fc8e0f #x211d3490)
(fftw_codelet_r2cb_8 2 #x10bdd #x10bdd #x0 #x51e5f6b8 #x566aac6d #x249913ff #xf363e314)
(fftw_dft_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #xa2573247 #x00a395db #xf017dd19 #x1df50dd6)
(fftw_dft_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #x1f2e97fe #x61895cd8 #x6073a2f5 #x6ada2663)
(fftw_rdft2_thr_vrank_geq1_register 0 #x10bdd #x10bdd #x0 #xfae0bb4c #xd2ae28c3 #x4adfa199 #xc55e4e63)
(fftw_rdft2_rank_geq2_register 0 #x10bdd #x10bdd #x0 #x8954f8e1 #x6c6f7b1c #xd3d53834 #xc9eb25c1)
(fftw_codelet_n1fv_16_avx 0 #x10bdd #x10bdd #x0 #x60ba7657 #xefd487be #x5ac1f2cf #x8eb91f0f)
(fftw_rdft2_rank_geq2_register 0 #x10bdd #x10bdd #x0 #x3c2e2a1a #x07c08954 #x35c337d9 #x80864862)
(fftw_codelet_n1fv_16_avx 0 #x10bdd #x10bdd #x0 #xca718bf8 #x524674ba #x011a6dfe #xfbebca33)
(fftw_codelet_r2cb_32 2 #x10bdd #x10bdd #x0 #x92bf92d5 #xdc456f1e #x5a32a424 #xe1f76e14)
) )

198
tests/test_gradient.py Normal file
View file

@ -0,0 +1,198 @@
import aquila_borg as borg
import configparser
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
import itertools
import h5py as h5
import os
import sys
import contextlib
from tqdm import tqdm
import borg_velocity.likelihood as likelihood
import borg_velocity.forwards as forwards
import borg_velocity.utils as utils
run_test = True
# run_test = False
epsilon = 1e-2
# Create a context manager to suppress stdout
@contextlib.contextmanager
def suppress_stdout():
with open(os.devnull, 'w') as devnull:
old_stdout = sys.stdout
sys.stdout = devnull
try:
yield
finally:
sys.stdout = old_stdout
def compare_gradients(
ag_lh_auto_real: np.ndarray,
ag_lh_auto_imag: np.ndarray,
ag_lh_num_real: np.ndarray,
ag_lh_num_imag: np.ndarray,
plot_step: int,
filename: str="gradients.png",
) -> None:
"""
Comparison of an autodiff adjoint gradient of the likelihood against a
numerical one evaluated with finite differences.
Args:
- ag_lh_auto_real (np.ndarray): Real part of the adjoint gradient (autodiff)
- ag_lh_auto_imag (np.ndarray): Imaginary part of the adjoint gradient (autodiff)
- ag_lh_num_real (np.ndarray): Real part of the adjoint gradient (numerical)
- ag_lh_num_imag (np.ndarray): Imaginary part of the adjoint gradient (numerical)
- plot_step (int): How frequently to sample the arrays
- filename (str): Name of the file to save the figure
"""
# Plot colors
colors = {
"red": "#ba3d3b",
"blue": "#3d5792",
}
fig, axs = plt.subplots(2, 2, figsize=(10, 7))
# Real part
axs[0,0].axhline(0.0, color="black", linestyle=":")
axs[0,0].plot(ag_lh_num_real[::plot_step], c=colors["blue"], label="Finite differences")
axs[0,0].plot(ag_lh_auto_real[::plot_step], "o", c=colors["red"], ms=3, label="Autodiff")
axs[0,0].yaxis.get_major_formatter().set_powerlimits((-2, 2))
axs[0,0].set_ylabel("Real part")
axs[0,0].legend()
axs[0,1].plot(ag_lh_num_real[::plot_step],
ag_lh_auto_real[::plot_step] - ag_lh_num_real[::plot_step],
"o",
c=colors["red"],
ms=3
)
x = axs[0,1].get_xlim()
axs[0,1].axhline(y=0, color='k')
axs[0,1].set_xlabel("Numerical")
axs[0,1].set_ylabel("Autodiff - Numerical (real)")
# Imaginary part
axs[1,0].axhline(0.0, color="black", linestyle=":")
axs[1,0].plot(ag_lh_num_imag[::plot_step][4:], c=colors["blue"], label="Finite differences")
axs[1,0].plot(ag_lh_auto_imag[::plot_step][4:], "o", c=colors["red"], ms=3, label="Autodiff")
axs[1,0].yaxis.get_major_formatter().set_powerlimits((-2, 2))
axs[1,0].set_ylabel("Imaginary part")
axs[1,0].set_xlabel("Voxel ID")
axs[1,1].plot(ag_lh_num_imag[::plot_step],
ag_lh_auto_imag[::plot_step] - ag_lh_num_imag[::plot_step],
".",
c=colors["red"]
)
x = axs[1,1].get_xlim()
axs[1,1].axhline(y=0, color='k')
axs[1,1].set_xlabel("Numerical")
axs[1,1].set_ylabel("Autodiff - Numerical (imag)")
fig.suptitle("Adjoint gradient of the likelihood w.r.t. initial conditions")
fig.tight_layout()
fig.subplots_adjust(hspace=0.)
path = "../figs/"
fig.savefig(path + filename, bbox_inches="tight")
ini_file = '../conf/basic_ini.ini'
# Input box
box_in = borg.forward.BoxModel()
config = configparser.ConfigParser()
config.read(ini_file)
box_in.L = (float(config['system']['L0']), float(config['system']['L1']), float(config['system']['L2']))
box_in.N = (int(config['system']['N0']), int(config['system']['N1']), int(config['system']['N2']))
box_in.xmin = (float(config['system']['corner0']), float(config['system']['corner1']), float(config['system']['corner2']))
# Setup BORG forward model and likelihood
model = likelihood.build_gravity_model(None, box_in, ini_file=ini_file)
cosmo = utils.get_cosmopar(ini_file)
model.setCosmoParams(cosmo)
fwd_param = forwards.NullForward(box_in)
fwd_vel = likelihood.fwd_vel
mylike = likelihood.VelocityBORGLikelihood(model, fwd_param, fwd_vel, ini_file)
# Create mock data
state = borg.likelihood.MarkovState()
mylike.initializeLikelihood(state)
mylike.updateCosmology(cosmo)
s_hat = np.fft.rfftn(np.random.randn(*box_in.N)) / box_in.Ntot ** (0.5)
mylike.generateMockData(s_hat, state)
# Compute density field
# output_density = np.zeros(box_in.N)
# mylike.fwd.forwardModel_v2(s_hat)
# print('SUM START', output_density.sum())
# mylike.fwd.getDensityFinal(output_density)
# print('SUM NOW', output_density.sum())
# L = mylike.logLikelihoodComplex(s_hat, None)
# print(L)
# quit()
# Autodiff
autodiff_gradient = mylike.gradientLikelihoodComplex(s_hat)
print(autodiff_gradient.min(), autodiff_gradient.max(), np.sum(np.isfinite(autodiff_gradient)), np.prod(autodiff_gradient.shape))
# Finite differences
if run_test:
s_hat_epsilon = s_hat.copy()
num_gradient = np.zeros(s_hat.shape, dtype=np.complex128)
for i, j, k in tqdm(
itertools.product(*map(range, [box_in.N[0], box_in.N[1], box_in.N[2] // 2 + 1])),
total=box_in.N[0] * box_in.N[1] * (box_in.N[2] // 2 + 1),
mininterval=1,
):
# +/- epsilon
s_hat_epsilon[i, j, k] = s_hat[i, j, k] + epsilon
with suppress_stdout():
L = mylike.logLikelihoodComplex(s_hat_epsilon, None)
s_hat_epsilon[i, j, k] = s_hat[i, j, k] - epsilon
with suppress_stdout():
L -= mylike.logLikelihoodComplex(s_hat_epsilon, None)
QQ = L / (2.0 * epsilon)
# +/- i * epsilon
s_hat_epsilon[i, j, k] = s_hat[i, j, k] + 1j * epsilon
with suppress_stdout():
L = mylike.logLikelihoodComplex(s_hat_epsilon, None)
s_hat_epsilon[i, j, k] = s_hat[i, j, k] - 1j * epsilon
with suppress_stdout():
L -= mylike.logLikelihoodComplex(s_hat_epsilon, None)
QQ = QQ + L * 1j / (2.0 * epsilon)
s_hat_epsilon[i, j, k] = s_hat[i, j, k]
num_gradient[i, j, k] = QQ
with h5.File(f"gradients_{box_in.N}.h5", mode="w") as ff:
ff["scalars/gradient_array_lh"] = autodiff_gradient
ff["scalars/gradient_array_lh_ref"] = num_gradient
ff["scalars/gradient_array_prior"] = np.zeros_like(autodiff_gradient)
ff["scalars/gradient_array_prior_ref"] = np.zeros_like(autodiff_gradient)
slice_step = 2
plot_step = 2
with h5.File(f'gradients_{box_in.N}.h5', 'r') as f:
ag_lh_auto_real = f["scalars"]["gradient_array_lh"][::slice_step, :, :].flatten().real
ag_lh_auto_imag = f["scalars"]["gradient_array_lh"][::slice_step, :, :].flatten().imag
ag_lh_num_real = f["scalars"]["gradient_array_lh_ref"][::slice_step, :, :].flatten().real
ag_lh_num_imag = f["scalars"]["gradient_array_lh_ref"][::slice_step, :, :].flatten().imag
compare_gradients(
ag_lh_auto_real,
ag_lh_auto_imag,
ag_lh_num_real,
ag_lh_num_imag,
plot_step,
f'gradient_test_{box_in.N[0]}.png',
)

View file

@ -1,54 +1,87 @@
ARES version c6de4f62faad20ede0bb40aa3678551dceee637b modules ARES version 53e8df9fe11c732cda13f7ffc821238622068e57 modules
Cumulative timing spent in different context Cumulative timing spent in different context
-------------------------------------------- --------------------------------------------
Context, Total time (seconds) Context, Total time (seconds)
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/forward_model.cpp]void LibLSS::ForwardModel::setCosmoParams(const LibLSS::CosmologicalParameters&) 439 128.974 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/chain_forward_model.cpp]virtual void LibLSS::ChainForwardModel::forwardModel_v2(LibLSS::detail_input::ModelInput<3>) 1282 34.5484
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/forwards/borg_lpt.cpp]void LibLSS::BorgLptModel<CIC>::updateCosmo() [with CIC = LibLSS::ClassicCloudInCell<double>] 87 59.7371 BORG LPT MODEL 1282 33.0864
lightcone computation 83 58.2376 BORG forward model 1282 32.9949
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/cosmo.cpp]void LibLSS::Cosmology::precompute_d_plus() 83 50.8567 CICModel::getVelocityField 1283 9.73471
LinearModel::getVelocityField 286 13.1932 CICModel::getVelocityFieldAlpha 3849 7.41442
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/chain_forward_model.cpp]virtual void LibLSS::ChainForwardModel::forwardModel_v2(LibLSS::detail_input::ModelInput<3>) 286 6.19859 FFTW_Manager::create_r2c_plan 5142 2.65586
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/cosmo.cpp]void LibLSS::Cosmology::precompute_com2a() 83 5.85109 FFTW_Manager::create_c2r_plan 5141 2.57818
BORG LPT MODEL 286 5.68871 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/forward_model.cpp]void LibLSS::ForwardModel::setCosmoParams(const LibLSS::CosmologicalParameters&) 34 2.20232
BORG forward model 286 5.65939 lpt_ic 1282 1.63669
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/forwards/transfer_class.cpp]virtual void LibLSS::ForwardClass::updateCosmo() 87 4.72651 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/forwards/borg_lpt.cpp]void LibLSS::BorgLptModel<CIC>::updateCosmo() [with CIC = LibLSS::ClassicCloudInCell<double>] 5 1.02187
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/class_cosmo.cpp]LibLSS::ClassCosmo::ClassCosmo(const LibLSS::CosmologicalParameters&, unsigned int, double, std::string, unsigned int, const std::map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >&) 83 4.65339 lightcone computation 1 0.998
FFTW_Manager::create_c2r_plan 860 1.08067 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/cosmo.cpp]void LibLSS::Cosmology::precompute_d_plus() 1 0.917015
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/forwards/lpt/borg_fwd_lpt.cpp]void LibLSS::BorgLptModel<CIC>::getDensityFinal(LibLSS::detail_output::ModelOutput<3>) [with CIC = LibLSS::ClassicCloudInCell<double>] 572 0.636041 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/hermitic.hpp]virtual void LibLSS::ForwardHermiticOperation::getDensityFinal(LibLSS::detail_output::ModelOutput<3>) 1282 0.595479
Classic CIC projection 572 0.489137 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/tools/hermiticity_fixup.cpp]void LibLSS::Hermiticity_fixer<T, Nd>::forward(CArrayRef&) [with T = double; long unsigned int Nd = 3; CArrayRef = boost::multi_array_ref<std::complex<double>, 3>] 1282 0.535228
lpt_ic 286 0.474278 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/tools/hermiticity_fixup.cpp]typename std::enable_if<(Dim != 1), void>::type fix_plane(Mgr&, Ghosts&&, CArray&&, size_t*) [with long unsigned int rank = 0; Mgr = LibLSS::FFTW_Manager<double, 3>; Ghosts = LibLSS::Hermiticity_fixer<double, 3>::forward(CArrayRef&)::<lambda(ssize_t)>; CArray = boost::detail::multi_array::multi_array_view<std::complex<double>, 2>; long unsigned int Dim = 2; typename std::enable_if<(Dim != 1), void>::type = void; size_t = long unsigned int] 2564 0.500125
FFTW_Manager::create_r2c_plan 289 0.377194 FFTW_Manager::execute_c2r 8985 0.339934
FFTW_Manager::execute_c2r 1716 0.297204 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/python/pyforward.cpp]void do_get_density_final(LibLSS::BORGForwardModel*, pybind11::array) 1282 0.232009
FFTW_Manager::destroy_plan 1144 0.0944267 FFTW_Manager::execute_r2c 5142 0.17592
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/class_cosmo.cpp]void LibLSS::ClassCosmo::retrieve_Tk(double) 166 0.0942418 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/forwards/lpt/borg_fwd_lpt.cpp]void LibLSS::BorgLptModel<CIC>::getDensityFinal(LibLSS::detail_output::ModelOutput<3>) [with CIC = LibLSS::ClassicCloudInCell<double>] 1282 0.171371
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/class_cosmo.cpp]void LibLSS::ClassCosmo::reinterpolate(const array_ref_1d&, const array_ref_1d&, LibLSS::internal_auto_interp::auto_interpolator<double>&) 498 0.0858865 Classic CIC projection 6415 0.161445
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/python/pyforward.cpp]void transfer_in(std::shared_ptr<LibLSS::FFTW_Manager<double, 3> >&, T&, U&, bool) [with T = boost::multi_array_ref<std::complex<double>, 3>; U = pybind11::detail::unchecked_reference<std::complex<double>, 3>] 286 0.0699093 FFTW_Manager::destroy_plan 10282 0.160099
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/python/pyforward.cpp]void do_get_density_final(LibLSS::BORGForwardModel*, pybind11::array) 286 0.0698282 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/model_io.cpp]LibLSS::detail_output::ModelOutputBase<Nd, Super>::~ModelOutputBase() [with long unsigned int Nd = 3; Super = LibLSS::detail_model::ModelIO<3>] 16683 0.148489
FFTW_Manager::execute_r2c 286 0.0460398 exchanging nearby planes after projection 5133 0.132258
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/chain_forward_model.cpp]virtual void LibLSS::ChainForwardModel::getDensityFinal(LibLSS::detail_output::ModelOutput<3>) 286 0.0272996 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/model_io.cpp]void LibLSS::detail_output::ModelOutputBase<Nd, Super>::transfer(LibLSS::detail_output::ModelOutputBase<Nd, Super>&&) [with long unsigned int Nd = 3; Super = LibLSS::detail_model::ModelIO<3>] 14113 0.109589
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/model_io.cpp]LibLSS::detail_output::ModelOutputBase<Nd, Super>::~ModelOutputBase() [with long unsigned int Nd = 3; Super = LibLSS::detail_model::ModelIO<3>] 3432 0.0272375 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/forwards/particle_balancer/balanceinfo.hpp]void LibLSS::BalanceInfo::allocate(LibLSS::MPI_Communication*, size_t) 2565 0.0855438
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/forwards/primordial_as.cpp]virtual void LibLSS::ForwardPrimordial_As::updateCosmo() 174 0.0224216 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/forwards/transfer_class.cpp]virtual void LibLSS::ForwardClass::updateCosmo() 5 0.0786533
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/forwards/particle_balancer/balanceinfo.hpp]void LibLSS::BalanceInfo::allocate(LibLSS::MPI_Communication*, size_t) 286 0.018951 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/python/pyforward.cpp]void transfer_in(std::shared_ptr<LibLSS::FFTW_Manager<double, 3> >&, T&, U&, bool) [with T = boost::multi_array_ref<std::complex<double>, 3>; U = pybind11::detail::unchecked_reference<std::complex<double>, 3>] 1282 0.0780552
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/model_io.cpp]void LibLSS::detail_output::ModelOutputBase<Nd, Super>::transfer(LibLSS::detail_output::ModelOutputBase<Nd, Super>&&) [with long unsigned int Nd = 3; Super = LibLSS::detail_model::ModelIO<3>] 2574 0.0179214 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/class_cosmo.cpp]LibLSS::ClassCosmo::ClassCosmo(const LibLSS::CosmologicalParameters&, unsigned int, double, std::string, unsigned int, const std::map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >&) 1 0.0778988
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/forwards/primordial_as.cpp]void LibLSS::ForwardPrimordial_As::updatePower() 87 0.0121461 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/cosmo.cpp]void LibLSS::Cosmology::precompute_com2a() 1 0.0569591
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/model_io/base.hpp]void LibLSS::detail_model::ModelIO<Nd>::transfer(LibLSS::detail_model::ModelIO<Nd>&&) [with long unsigned int Nd = 3] 6578 0.00613989 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/chain_forward_model.cpp]virtual void LibLSS::ChainForwardModel::getDensityFinal(LibLSS::detail_output::ModelOutput<3>) 1282 0.0554107
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/forwards/primordial_as.cpp]virtual void LibLSS::ForwardPrimordial_As::forwardModel_v2(LibLSS::detail_input::ModelInput<3>) 286 0.00534198 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/model_io/base.hpp]void LibLSS::detail_model::ModelIO<Nd>::transfer(LibLSS::detail_model::ModelIO<Nd>&&) [with long unsigned int Nd = 3] 37208 0.0357777
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/forwards/borg_lpt.cpp]std::shared_ptr<LibLSS::BORGForwardModel> build_borg_lpt(std::shared_ptr<LibLSS::MPI_Communication>, const LibLSS::BoxModel&, const LibLSS::PropertyProxy&) [with Grid = LibLSS::ClassicCloudInCell<double>; LibLSS::BoxModel = LibLSS::NBoxModel<3>] 1 0.00492109 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/velocity/velocity_cic.cpp]virtual void LibLSS::VelocityModel::CICModel::computeAdjointModel(LibLSS::VelocityModel::Base::arrayVelocityField_t) 1 0.028122
BorgLptModel::BorgLptModel 1 0.00485408 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/chain_forward_model.cpp]virtual void LibLSS::ChainForwardModel::adjointModel_v2(LibLSS::detail_input::ModelInputAdjoint<3>) 1 0.0271402
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/forwards/transfer_class.cpp]virtual void LibLSS::ForwardClass::forwardModel_v2(LibLSS::detail_input::ModelInput<3>) 286 0.00379283 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/chain_forward_model.cpp]void LibLSS::ChainForwardModel::trigger_ag() 1 0.0271251
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/forwards/transfer_class.cpp]std::shared_ptr<LibLSS::BORGForwardModel> build_class(std::shared_ptr<LibLSS::MPI_Communication>, const LibLSS::BoxModel&, const LibLSS::PropertyProxy&) 1 0.00279151 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/forwards/lpt/borg_fwd_lpt_adj.cpp]void LibLSS::BorgLptModel<CIC>::getAdjointModelOutput(LibLSS::detail_output::ModelOutputAdjoint<3>) [with CIC = LibLSS::ClassicCloudInCell<double>] 1 0.0259611
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/forwards/primordial_as.cpp]std::shared_ptr<LibLSS::BORGForwardModel> build_primordial_as(std::shared_ptr<LibLSS::MPI_Communication>, const LibLSS::BoxModel&, const LibLSS::PropertyProxy&) 1 0.00275793 BORG adjoint model (particles) 1 0.0259384
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/model_io.cpp]void LibLSS::detail_output::ModelOutputBase<Nd, Super>::close() [with long unsigned int Nd = 3; Super = LibLSS::detail_model::ModelIO<3>] 3432 0.00244201 LPT-IC adjoint 1 0.0258888
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/forward_model.cpp]void LibLSS::BORGForwardModel::setupDefault() 1 0.00234473 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/forwards/transfer_class.cpp]virtual void LibLSS::ForwardClass::forwardModel_v2(LibLSS::detail_input::ModelInput<3>) 1282 0.0198379
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/samplers/core/gridLikelihoodBase.cpp]LibLSS::GridDensityLikelihoodBase<Dims>::GridDensityLikelihoodBase(LibLSS::MPI_Communication*, const GridSizes&, const GridLengths&) [with int Dims = 3; GridSizes = std::array<long unsigned int, 3>; GridLengths = std::array<double, 3>] 1 0.00177276 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/forwards/primordial_as.cpp]virtual void LibLSS::ForwardPrimordial_As::forwardModel_v2(LibLSS::detail_input::ModelInput<3>) 1282 0.0194489
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/model_io.cpp]void LibLSS::detail_output::ModelOutputBase<Nd, Super>::setRequestedIO(LibLSS::PreferredIO) [with long unsigned int Nd = 3; Super = LibLSS::detail_model::ModelIO<3>] 1430 0.00117615 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/model_io.cpp]void LibLSS::detail_output::ModelOutputBase<Nd, Super>::close() [with long unsigned int Nd = 3; Super = LibLSS::detail_model::ModelIO<3>] 16683 0.0139736
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/forwards/adapt_generic_bias.cpp]void {anonymous}::bias_registrator() 1 0.00110666 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/model_io.cpp]void LibLSS::detail_output::ModelOutputBase<Nd, Super>::setRequestedIO(LibLSS::PreferredIO) [with long unsigned int Nd = 3; Super = LibLSS::detail_model::ModelIO<3>] 6415 0.00580403
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/model_io.cpp]void LibLSS::detail_input::ModelInputBase<Nd, Super>::setRequestedIO(LibLSS::PreferredIO) [with long unsigned int Nd = 3; Super = LibLSS::detail_model::ModelIO<3>] 858 0.000657356 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/model_io.cpp]void LibLSS::detail_input::ModelInputBase<Nd, Super>::setRequestedIO(LibLSS::PreferredIO) [with long unsigned int Nd = 3; Super = LibLSS::detail_model::ModelIO<3>] 5132 0.00454889
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/model_io.cpp]void LibLSS::detail_input::ModelInputBase<Nd, Super>::needDestroyInput() [with long unsigned int Nd = 3; Super = LibLSS::detail_model::ModelIO<3>] 286 0.00030629 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/tools/hermiticity_fixup.cpp]LibLSS::Hermiticity_fixer<T, Nd>::Hermiticity_fixer(Mgr_p) [with T = double; long unsigned int Nd = 3; Mgr_p = std::shared_ptr<LibLSS::FFTW_Manager<double, 3> >] 1 0.0034003
particle distribution 286 0.000249263 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/tools/mpi/ghost_planes.hpp]void LibLSS::GhostPlanes<T, Nd>::setup(LibLSS::MPI_Communication*, PlaneList&&, PlaneSet&&, DimList&&, size_t) [with PlaneList = std::set<long int>&; PlaneSet = std::set<long int>&; DimList = std::array<long int, 2>&; T = std::complex<double>; long unsigned int Nd = 2; size_t = long unsigned int] 1 0.00338329
BORGForwardModel::setup 7 0.000130953 dispatch_plane_map 1 0.00333988
Initializing peer system 13 4.4624e-05 [/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/forwards/borg_lpt.cpp]std::shared_ptr<LibLSS::BORGForwardModel> build_borg_lpt(std::shared_ptr<LibLSS::MPI_Communication>, const LibLSS::BoxModel&, const LibLSS::PropertyProxy&) [with Grid = LibLSS::ClassicCloudInCell<double>; LibLSS::BoxModel = LibLSS::NBoxModel<3>] 1 0.00264381
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/forwards/transfer_class.cpp]virtual void LibLSS::ForwardClass::setModelParams(const LibLSS::ModelDictionnary&) 1 1.445e-05 BorgLptModel::BorgLptModel 1 0.00258427
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1686906696789/work/libLSS/physics/forward_model.cpp]virtual void LibLSS::ForwardModel::setModelParams(const LibLSS::ModelDictionnary&) 1 3.659e-06 Classic CIC adjoint-interpolation 18 0.00243702
ghost synchronize 1282 0.00235298
particle distribution 2565 0.00232546
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/model_io.cpp]void LibLSS::detail_input::ModelInputBase<Nd, Super>::needDestroyInput() [with long unsigned int Nd = 3; Super = LibLSS::detail_model::ModelIO<3>] 1282 0.00174796
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/class_cosmo.cpp]void LibLSS::ClassCosmo::retrieve_Tk(double) 2 0.00143746
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/class_cosmo.cpp]void LibLSS::ClassCosmo::reinterpolate(const array_ref_1d&, const array_ref_1d&, LibLSS::internal_auto_interp::auto_interpolator<double>&) 6 0.00127092
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/forwards/adapt_generic_bias.cpp]void {anonymous}::bias_registrator() 1 0.00125063
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/forward_model.cpp]void LibLSS::BORGForwardModel::setupDefault() 1 0.0010723
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/samplers/core/gridLikelihoodBase.cpp]LibLSS::GridDensityLikelihoodBase<Dims>::GridDensityLikelihoodBase(LibLSS::MPI_Communication*, const GridSizes&, const GridLengths&) [with int Dims = 3; GridSizes = std::array<long unsigned int, 3>; GridLengths = std::array<double, 3>] 1 0.000721845
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/forwards/primordial_as.cpp]virtual void LibLSS::ForwardPrimordial_As::updateCosmo() 10 0.000559358
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/hermitic.hpp]virtual void LibLSS::ForwardHermiticOperation::getAdjointModelOutput(LibLSS::detail_output::ModelOutputAdjoint<3>) 1 0.000524894
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/tools/hermiticity_fixup.cpp]typename std::enable_if<(Dim != 1), void>::type adjoint_fix_plane(Mgr&, CArray&&, size_t*) [with long unsigned int rank = 0; Mgr = LibLSS::FFTW_Manager<double, 3>; CArray = boost::detail::multi_array::multi_array_view<std::complex<double>, 2>; long unsigned int Dim = 2; typename std::enable_if<(Dim != 1), void>::type = void; size_t = long unsigned int] 2 0.000443373
Classic CIC interpolation 3 0.000410194
BorgLptModel::~BorgLptModel 1 0.00018844
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/python/pyforward.cpp]void do_get_adjoint_model(LibLSS::BORGForwardModel*, pybind11::array) 1 0.000186842
BORGForwardModel::setup 8 0.000177922
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/forwards/lpt/borg_fwd_lpt_adj.cpp]void LibLSS::BorgLptModel<CIC>::adjointModelParticles(LibLSS::BORGForwardModelTypes::PhaseArrayRef&, LibLSS::BORGForwardModelTypes::PhaseArrayRef&) [with CIC = LibLSS::ClassicCloudInCell<double>; LibLSS::BORGForwardModelTypes::PhaseArrayRef = boost::multi_array_ref<double, 2>] 1 0.00013868
BORG adjoint model 1 0.000106633
Classic CIC adjoint-projection 1 8.2392e-05
exchanging nearby planes before taking adjoint gradient 6 8.2354e-05
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/forwards/lpt/borg_fwd_lpt_adj.cpp]void LibLSS::BorgLptModel<CIC>::preallocate() [with CIC = LibLSS::ClassicCloudInCell<double>] 2 7.5163e-05
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/forwards/primordial_as.cpp]std::shared_ptr<LibLSS::BORGForwardModel> build_primordial_as(std::shared_ptr<LibLSS::MPI_Communication>, const LibLSS::BoxModel&, const LibLSS::PropertyProxy&) 1 7.2877e-05
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/forwards/transfer_class.cpp]std::shared_ptr<LibLSS::BORGForwardModel> build_class(std::shared_ptr<LibLSS::MPI_Communication>, const LibLSS::BoxModel&, const LibLSS::PropertyProxy&) 1 7.2711e-05
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/chain_forward_model.cpp]virtual void LibLSS::ChainForwardModel::getAdjointModelOutput(LibLSS::detail_output::ModelOutputAdjoint<3>) 1 6.745e-05
Initializing peer system 14 6.3955e-05
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/forwards/primordial_as.cpp]void LibLSS::ForwardPrimordial_As::updatePower() 5 4.8762e-05
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/python/pyforward.cpp]void transfer_in(std::shared_ptr<LibLSS::FFTW_Manager<double, 3> >&, T&, U&, bool) [with T = boost::multi_array_ref<double, 3>; U = pybind11::detail::unchecked_reference<double, 3>] 1 3.5512e-05
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/forwards/transfer_class.cpp]virtual void LibLSS::ForwardClass::setModelParams(const LibLSS::ModelDictionnary&) 1 2e-05
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/forwards/transfer_class.cpp]virtual void LibLSS::ForwardClass::adjointModel_v2(LibLSS::detail_input::ModelInputAdjoint<3>) 1 1.5583e-05
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/forwards/primordial_as.cpp]virtual void LibLSS::ForwardPrimordial_As::adjointModel_v2(LibLSS::detail_input::ModelInputAdjoint<3>) 1 1.3838e-05
gather_peer_by_plane 1 1.0897e-05
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/forwards/lpt/borg_fwd_lpt_adj.cpp]void LibLSS::BorgLptModel<CIC>::clearAdjointGradient() [with CIC = LibLSS::ClassicCloudInCell<double>] 1 3.816e-06
[/build/jenkins/miniconda3/envs/builder/conda-bld/aquila_borg_1717878335917/work/libLSS/physics/forward_model.cpp]virtual void LibLSS::ForwardModel::setModelParams(const LibLSS::ModelDictionnary&) 1 2.816e-06
distribute_particles_ag 2 1.678e-06