mlprt / feedbax

Optimal feedback control + interventions, in JAX.
https://docs.lprt.ca/feedbax
Apache License 2.0
1 stars 0 forks source link

Intervenors, and an issue with the abstract-final pattern #20

Open mlprt opened 6 months ago

mlprt commented 6 months ago

As mentioned in #19, intervention operations are prepended to the existing stages of a model's state operations. The intervention operations are defined by inserting AbstractIntervenor objects into the intervenors: Mapping[Optional[str], Sequence[AbstractIntervenor]] field of any AbstractStagedModel.

Currently, every subclass of AbstractStagedModel needs to implement that field. This is annoying: the field is generally just an empty dict that is later filled up with stuff, so it is always implemented in the same way. Developers are expected to repeat themselves.

We could avoid this by implementing intervenors directly in AbstractStagedModel, but this would violate the abstract-final pattern. We haven't been enforcing the pattern by subclassing equinox.Module with strict=True, yet.

Is there a way to avoid implementing intervenors in the base class?

There are a few other places this same issue appears in Feedbax.

mlprt commented 1 month ago

This should be simplified/obviated if we replace the staged model approach with a DAG approach (#28), so I'm tagging this issue as "won't fix".

In particular, intervenors will have a similar status as any other leaf modules.