diff --git a/cmake/toolchain/cuda_package_config.cmake b/cmake/toolchain/cuda_package_config.cmake
index 06c5d76f5ca3b47ac9299a9897921f7da1180383..44025c5639d1f940073b198b30f8cacc594b0b38 100644
--- a/cmake/toolchain/cuda_package_config.cmake
+++ b/cmake/toolchain/cuda_package_config.cmake
@@ -17,7 +17,7 @@ LCG_external_package(cudnn        8.9.7.29  cuda=12              )
 LCG_external_package(cupy         13.0.0    cuda=12x            )
 LCG_external_package(fastrlock    0.8.2                         )
 LCG_external_package(llvmmin      17.0.6                        )
-LCG_external_package(mako         1.1.4                         )
+LCG_external_package(mako         1.3.5                         )
 LCG_external_package(py_tools     2021.2.7                      )
 LCG_external_package(pycuda       2024.1                        )
 LCG_external_package(pyopencl     2024.1                        )
diff --git a/cmake/toolchain/heptools-dev-base.cmake b/cmake/toolchain/heptools-dev-base.cmake
index 09240f8cbb7be790f483210bac2ca7ee284871b3..2e0e974a652572162d01192fa546df46a8146a5a 100644
--- a/cmake/toolchain/heptools-dev-base.cmake
+++ b/cmake/toolchain/heptools-dev-base.cmake
@@ -16,7 +16,11 @@ if(${LCG_OS}${LCG_OSVERS} MATCHES centos|ubuntu|el)
   endif()
 endif()
 LCG_AA_project(DD4hep                  01.30                                    )
-LCG_AA_project(EDM4hep                 00.99                                    )
+
+if(((${LCG_COMP} MATCHES gcc) AND (${LCG_COMPVERS} GREATER 12)) OR (${LCG_COMP} MATCHES clang AND ${LCG_COMPVERS} GREATER 15))
+  #edm4hep needs c++20
+  LCG_AA_project(EDM4hep                 00.99.01                                 )
+endif()
 
 #---Externals--------------------------------------------------------------------------------------
 
@@ -30,6 +34,7 @@ LCG_external_package(aiohttp           3.8.4
 LCG_external_package(aiosignal         1.2.0                                    )
 LCG_external_package(aiostream         0.4.5                                    )
 LCG_external_package(alabaster         0.7.12                                   )
+LCG_external_package(alembic           1.13.3                                   )
 LCG_external_package(alpaka            0.9.0                                    )
 LCG_external_package(altair            5.2.0                                    )
 LCG_external_package(annotated_types   0.6.0                                    )
@@ -440,6 +445,7 @@ else()
 endif()
 LCG_external_package(madx              5.09.00                                  )
 LCG_external_package(make_it_sync       1.0.0                                    )
+LCG_external_package(mako              1.3.5                                    )
 LCG_external_package(markdown          3.1.1                                    )
 LCG_external_package(markdown_it_py    2.2.0                                    )
 LCG_external_package(MarkupSafe        2.1.2                                    )
@@ -530,6 +536,7 @@ if(${LCG_OS} MATCHES mac)
 endif()
 LCG_external_package(optree            0.11.0                                   )
 LCG_external_package(opt_einsum        3.2.0                                    )
+LCG_external_package(optuna            4.0.0                                    )
 LCG_external_package(orjson            3.9.15                                   )
 if(${LCG_OS} MATCHES centos|el)
   LCG_external_package(oracle            19.19.0.0.0                              )
@@ -580,7 +587,7 @@ LCG_external_package(pluggy            1.5.0
 LCG_external_package(plumbum           1.7.2                                    )
 LCG_external_package(ply               3.11                                     )
 LCG_external_package(png               1.6.37                                   )
-LCG_external_package(podio             1.00.01					)
+LCG_external_package(podio             01.01                                    )
 LCG_external_package(polars           0.18.13                                  )
 LCG_external_package(pooch             1.6.0                                    )
 LCG_external_package(postgresql        12.14                                    )
diff --git a/cmake/toolchain/heptools-devARM.cmake b/cmake/toolchain/heptools-devARM.cmake
index 872b01a1fe383dd2486e835361c0fd633df5644c..c68f708329013edf5e79b2462844fde1a0ded7e8 100644
--- a/cmake/toolchain/heptools-devARM.cmake
+++ b/cmake/toolchain/heptools-devARM.cmake
@@ -23,9 +23,6 @@ LCG_remove_package(spark)
 LCG_remove_package(gomacro)
 LCG_remove_package(gophernotes)
 
-# has issues with pythia8
-LCG_remove_package(EDM4hep)
-
 #mcfm builds many internal packages for static linking which have a problem with aarm64
 LCG_remove_package(mcfm)
 
diff --git a/pyexternals/CMakeLists.txt b/pyexternals/CMakeLists.txt
index 9c2c86539eaf4b7a6c872f6b6e568fdff1b50a9e..f2d290a05aecef75a62beab347e0e845c97b02c4 100644
--- a/pyexternals/CMakeLists.txt
+++ b/pyexternals/CMakeLists.txt
@@ -1897,6 +1897,19 @@ LCGPackage_Add(
   DEPENDS Python setuptools
 )
 
+#---mako-----------------------------------------------------------------------
+LCGPackage_Add(
+  mako
+  URL ${GenURL}/Mako-${mako_native_version}.tar.gz
+  CONFIGURE_COMMAND <VOID>
+  BUILD_COMMAND <VOID>
+  INSTALL_COMMAND ${MakeSitePackagesDir}
+          COMMAND ${PYTHON} setup.py install ${PySetupOptions}
+          COMMAND ${CMAKE_SOURCE_DIR}/pyexternals/Python_postinstall.sh <INSTALL_DIR>
+  BUILD_IN_SOURCE 1
+  DEPENDS Python setuptools MarkupSafe
+)
+
 #---babel--------------------------------------------------------------------------------------------------------------
 LCGPackage_Add(
     babel
@@ -5579,19 +5592,6 @@ LCGPackage_Add(
   DEPENDS Python setuptools numpy appdirs six decorator
 )
 
-#---mako-----------------------------------------------------------------------
-LCGPackage_Add(
-  mako
-  URL ${GenURL}/Mako-${mako_native_version}.tar.gz
-  CONFIGURE_COMMAND <VOID>
-  BUILD_COMMAND <VOID>
-  INSTALL_COMMAND ${MakeSitePackagesDir}
-          COMMAND ${PYTHON} setup.py install ${PySetupOptions}
-          COMMAND ${CMAKE_SOURCE_DIR}/pyexternals/Python_postinstall.sh <INSTALL_DIR>
-  BUILD_IN_SOURCE 1
-  DEPENDS Python setuptools MarkupSafe
-)
-
 #---pyopencl-------------------------------------------------------------------
 LCGPackage_Add(
   pyopencl
@@ -8908,6 +8908,32 @@ LCGPackage_Add(
   DEPENDS Python pip Boost scipy numpy
 )
 
+#---alembic-----------------------------------------------------------------------------------------------------
+LCGPackage_Add(
+  alembic
+  URL ${GenURL}/alembic-<VERSION>.tar.gz
+  CONFIGURE_COMMAND <VOID>
+  BUILD_COMMAND <VOID>
+  INSTALL_COMMAND ${MakeSitePackagesDir}
+          COMMAND ${PYTHON} -m pip install ${PySetupOptions} --no-deps .
+          COMMAND ${CMAKE_SOURCE_DIR}/pyexternals/Python_postinstall.sh <INSTALL_DIR>
+  BUILD_IN_SOURCE 1
+  DEPENDS Python pip mako sqlalchemy typing_extensions
+)
+
+#---optuna-----------------------------------------------------------------------------------------------------
+LCGPackage_Add(
+  optuna
+  URL ${GenURL}/optuna-<VERSION>.tar.gz
+  CONFIGURE_COMMAND <VOID>
+  BUILD_COMMAND <VOID>
+  INSTALL_COMMAND ${MakeSitePackagesDir}
+          COMMAND ${PYTHON} -m pip install ${PySetupOptions} --no-deps .
+          COMMAND ${CMAKE_SOURCE_DIR}/pyexternals/Python_postinstall.sh <INSTALL_DIR>
+  BUILD_IN_SOURCE 1
+  DEPENDS Python pip alembic colorlog numpy packaging PyYAML sqlalchemy tqdm
+)
+
 #---qibo-----------------------------------------------------------------------------------------------------
 LCGPackage_Add(
   qibo
@@ -8918,8 +8944,9 @@ LCGPackage_Add(
           COMMAND ${PYTHON} -m pip install ${PySetupOptions} --no-deps .
           COMMAND ${CMAKE_SOURCE_DIR}/pyexternals/Python_postinstall.sh <INSTALL_DIR>
   BUILD_IN_SOURCE 1
-  DEPENDS Python pip cma hyperopt openqasm3 joblib networkx numpy scipy sympy tabulate
+  DEPENDS Python pip cma joblib networkx numpy openqasm3 scipy sympy tabulate
     IF <VERSION> VERSION_GREATER_EQUAL 0.2.10 THEN qulacs ENDIF
+    IF <VERSION> VERSION_GREATER_EQUAL 0.2.12 THEN optuna ELSE hyperopt ENDIF
 )
 
 #---qibojit-----------------------------------------------------------------------------------------------------