ciemss / pyciemss

Causal and probabilistic reasoning with continuous time dynamical systems
Other
17 stars 6 forks source link

`solution_mappings` ignored for `ensemble_sample` #449

Closed fivegrant closed 7 months ago

fivegrant commented 9 months ago

ensemble_sample doesn't seem to use the provided solution_mappings. Therefore, ensemble_sample will only work with an ensemble containing identical models.

If you grep for solution_mappings, it seems it's not used, only instantiated:

pyciemss/ensemble/compiled_dynamics.py:21:        solution_mappings: List[
pyciemss/ensemble/compiled_dynamics.py:28:        self.solution_mappings = solution_mappings
pyciemss/ensemble/compiled_dynamics.py:58:    def _load_from_list(cls, srcs: list, dirichlet_alpha, solution_mappings):
pyciemss/ensemble/compiled_dynamics.py:60:        return cls(dynamics_models, dirichlet_alpha, solution_mappings)
pyciemss/interfaces.py:32:    solution_mappings: List[
pyciemss/interfaces.py:54:    solution_mappings: List[Callable[[Dict[str, torch.Tensor]], Dict[str, torch.Tensor]]]
pyciemss/interfaces.py:99:        model_paths_or_jsons, dirichlet_alpha, solution_mappings
tests/test_interfaces.py:26:    solution_mappings = [lambda x: x, lambda x: {k: 2 * v for k, v in x.items()}]
tests/test_interfaces.py:27:    return ensemble_sample(model_paths_or_jsons, solution_mappings, *args, **kwargs)
docs/source/interfaces.ipynb:653:    "solution_mappings = [lambda x : x, lambda x : x] # Conveniently, these two models operate on exactly the same state space, with the same names.\n",
docs/source/interfaces.ipynb:655:    "ensemble_result = pyciemss.ensemble_sample(model_paths, solution_mappings, end_time, logging_step_size, num_samples, start_time=start_time)\n",

Furthermore, solution_mappings are not found in Mira, ChiRho, PyTorch, or Pyro.

fivegrant commented 9 months ago

This issue causes ensemble-simulate in the service refactor to break when using solution_mappings

mwdchang commented 7 months ago

@SamWitty are there any updates on this issue?

SamWitty commented 7 months ago

Sorry, this slipped through the cracks. I see the missing code in PyCIEMSS and will resolve on Monday.