Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e3c49cf
Make type extensions compatible with Python 3.8.11 because that is wh…
IshaanDesai Dec 11, 2025
6531d57
implement model instancing to reduce memory footprint
Snapex2409 Dec 12, 2025
12416b2
small fix, to make mada work again
Snapex2409 Dec 12, 2025
062b555
fix formatting
Snapex2409 Dec 12, 2025
f660372
fix tests
Snapex2409 Dec 12, 2025
530d31a
missed one...
Snapex2409 Dec 12, 2025
db1bca9
Merge branch 'develop' into supermuc-compatible
IshaanDesai Dec 14, 2025
b49d47d
Merge branch 'develop' into supermuc-compatible
IshaanDesai Dec 27, 2025
d25757c
Merge branch 'develop' into supermuc-compatible
IshaanDesai Dec 31, 2025
b0b9487
Remove tuple type hint
IshaanDesai Dec 31, 2025
23cbf73
Merge branch 'develop' into supermuc-compatible
IshaanDesai Dec 31, 2025
ce268b5
Merge branch 'develop' into supermuc-compatible
IshaanDesai Dec 31, 2025
6192542
add dummy state property for micro sim class
Snapex2409 Jan 3, 2026
5c7baaa
Merge remote-tracking branch 'origin/supermuc-compatible' into model-…
Snapex2409 Jan 3, 2026
ff0a917
Merge branch 'develop' into supermuc-compatible
IshaanDesai Jan 7, 2026
6c3fdec
Merge remote-tracking branch 'origin/supermuc-compatible' into model-…
Snapex2409 Jan 12, 2026
e0468c6
add task model skeleton
Snapex2409 Jan 12, 2026
d61daf9
full impl and integrated
Snapex2409 Jan 13, 2026
b251cc4
impl late sim init for model adaptivity
Snapex2409 Jan 13, 2026
5098bdd
small fixes
Snapex2409 Jan 13, 2026
4164781
improved task model, less pickling
Snapex2409 Jan 15, 2026
fa26e43
integrate tasking with other modules
Snapex2409 Jan 16, 2026
7b366ea
remove debug output
Snapex2409 Jan 16, 2026
37d497c
fix tests
Snapex2409 Jan 20, 2026
e6d6703
fix example micro files
Snapex2409 Jan 20, 2026
f0bf90a
fix more test
Snapex2409 Jan 20, 2026
28d424e
fix last change
Snapex2409 Jan 20, 2026
5d025a4
fix test micro sim classes
Snapex2409 Jan 20, 2026
70e1d98
fix snapshot test
Snapex2409 Jan 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions examples/cpp-dummy/micro_cpp_dummy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ py::list MicroSimulation::get_state() const
return state_python;
}

int MicroSimulation::get_global_id() const
{
return _sim_id;
}

PYBIND11_MODULE(micro_dummy, m) {
// optional docstring
m.doc() = "pybind11 micro dummy plugin";
Expand All @@ -68,6 +73,7 @@ PYBIND11_MODULE(micro_dummy, m) {
.def("solve", &MicroSimulation::solve)
.def("get_state", &MicroSimulation::get_state)
.def("set_state", &MicroSimulation::set_state)
.def("get_global_id", &MicroSimulation::get_global_id)
// Pickling support does not work currently, as there is no way to pass the simulation ID to the new instance ms.
.def(py::pickle( // https://pybind11.readthedocs.io/en/latest/advanced/classes.html#pickling-support
[](const MicroSimulation &ms) { // __getstate__
Expand Down
1 change: 1 addition & 0 deletions examples/cpp-dummy/micro_cpp_dummy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class MicroSimulation

void set_state(py::list state);
py::list get_state() const;
int get_global_id() const;

private:
int _sim_id;
Expand Down
3 changes: 3 additions & 0 deletions examples/python-dummy/micro_dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ def set_state(self, state):

def get_state(self):
return self._state

def get_global_id(self):
return self._sim_id
5 changes: 4 additions & 1 deletion micro_manager/adaptivity/adaptivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class AdaptivityCalculator:
def __init__(
self, configurator, nsims, micro_problem_cls, base_logger, rank
self, configurator, nsims, micro_problem_cls, model_manager, base_logger, rank
) -> None:
"""
Class constructor.
Expand All @@ -24,6 +24,8 @@ def __init__(
Number of micro simulations.
micro_problem_cls : callable
Class of micro problem.
model_manager : object
Handles instantiation of micro simulation.
base_logger : object of class Logger
Logger object to log messages.
rank : int
Expand All @@ -37,6 +39,7 @@ def __init__(
self._adaptivity_output_type = configurator.get_adaptivity_output_type()

self._micro_problem_cls = micro_problem_cls
self._model_manager = model_manager

self._coarse_tol = 0.0
self._ref_tol = 0.0
Expand Down
50 changes: 50 additions & 0 deletions micro_manager/adaptivity/adaptivity_selection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from .global_adaptivity import GlobalAdaptivityCalculator
from .global_adaptivity_lb import GlobalAdaptivityLBCalculator
from .local_adaptivity import LocalAdaptivityCalculator
from .adaptivity import AdaptivityCalculator


def create_adaptivity_calculator(
config,
local_number_of_sims,
global_number_of_sims,
global_ids_of_local_sims,
participant,
logger,
rank,
comm,
micro_problem_cls,
model_manager,
use_lb,
) -> AdaptivityCalculator:
adaptivity_type = config.get_adaptivity_type()

if adaptivity_type == "local":
return LocalAdaptivityCalculator(
config,
local_number_of_sims,
logger,
rank,
comm,
micro_problem_cls,
model_manager,
)

if adaptivity_type == "global":
cls = GlobalAdaptivityCalculator
if use_lb:
cls = GlobalAdaptivityLBCalculator

return cls(
config,
global_number_of_sims,
global_ids_of_local_sims,
participant,
logger,
rank,
comm,
micro_problem_cls,
model_manager,
)

raise ValueError("Unknown adaptivity type")
18 changes: 15 additions & 3 deletions micro_manager/adaptivity/global_adaptivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def __init__(
rank: int,
comm,
micro_problem_cls,
model_manager,
) -> None:
"""
Class constructor.
Expand All @@ -48,9 +49,16 @@ def __init__(
Communicator for MPI.
micro_problem_cls : callable
Class of micro problem.
model_manager : object of class ModelManager
Handles instantiation of the micro simulation.
"""
super().__init__(
configurator, global_number_of_sims, micro_problem_cls, base_logger, rank
configurator,
global_number_of_sims,
micro_problem_cls,
model_manager,
base_logger,
rank,
)
self._global_number_of_sims = global_number_of_sims
self._global_ids = global_ids
Expand Down Expand Up @@ -459,7 +467,9 @@ def _update_inactive_sims(self, micro_sims: list) -> None:
# Only handle activation of simulations on this rank
for gid in to_be_activated_gids:
to_be_activated_lid = self._global_ids.index(gid)
micro_sims[to_be_activated_lid] = self._micro_problem_cls(gid)
micro_sims[to_be_activated_lid] = self._model_manager.get_instance(
gid, self._micro_problem_cls
)
assoc_active_gid = self._sim_is_associated_to[gid]

if self._is_sim_on_this_rank[
Expand Down Expand Up @@ -496,7 +506,9 @@ def _update_inactive_sims(self, micro_sims: list) -> None:
local_ids = to_be_activated_map[gid]
for lid in local_ids:
# Create the micro simulation object and set its state
micro_sims[lid] = self._micro_problem_cls(self._global_ids[lid])
micro_sims[lid] = self._model_manager.get_instance(
self._global_ids[lid], self._micro_problem_cls
)
micro_sims[lid].set_state(state)

# Delete the micro simulation object if it is inactive
Expand Down
8 changes: 7 additions & 1 deletion micro_manager/adaptivity/global_adaptivity_lb.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def __init__(
rank: int,
comm,
micro_problem_cls: callable,
model_manager,
) -> None:
"""
Class constructor.
Expand All @@ -45,6 +46,8 @@ def __init__(
Communicator for MPI.
micro_problem_cls : callable
Class of micro problem.
model_manager : object of class ModelManager
Handles instantiation of the micro simulation.
"""
super().__init__(
configurator,
Expand All @@ -55,6 +58,7 @@ def __init__(
rank,
comm,
micro_problem_cls,
model_manager,
)

self._base_logger = base_logger
Expand Down Expand Up @@ -367,7 +371,9 @@ def _move_active_sims(
# Create simulations and set them to the received states
for req in recv_reqs:
output, gid = req.wait()
micro_sims.append(self._micro_problem_cls(gid))
micro_sims.append(
self._model_manager.get_instance(gid, self._micro_problem_cls)
)
micro_sims[-1].set_state(output)
self._global_ids.append(gid)
self._is_sim_on_this_rank[gid] = True
Expand Down
9 changes: 7 additions & 2 deletions micro_manager/adaptivity/local_adaptivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def __init__(
rank,
comm,
micro_problem_cls,
model_manager,
) -> None:
"""
Class constructor.
Expand All @@ -38,8 +39,12 @@ def __init__(
Communicator for MPI.
micro_problem_cls : callable
Class of micro problem.
model_manager : object of class ModelManager
Handles instantiation of micro simulation.
"""
super().__init__(configurator, num_sims, micro_problem_cls, base_logger, rank)
super().__init__(
configurator, num_sims, micro_problem_cls, model_manager, base_logger, rank
)
self._comm = comm

# similarity_dists: 2D array having similarity distances between each micro simulation pair
Expand Down Expand Up @@ -292,7 +297,7 @@ def _update_inactive_sims(self, micro_sims: list) -> None:
# Update the set of inactive micro sims
for i in to_be_activated_ids:
associated_active_id = self._sim_is_associated_to[i]
micro_sims[i] = self._micro_problem_cls(i)
micro_sims[i] = self._model_manager.get_instance(i, self._micro_problem_cls)
micro_sims[i].set_state(micro_sims[associated_active_id].get_state())
self._sim_is_associated_to[
i
Expand Down
Loading