-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Thoughts on bringing heavylight under a single API? #40
Comments
|
graph can't be same class due to special methods, use abstract base class?
The special method means it can't be of the same class I believe. I propose a minimal interface be agreed upon for properties and methods, like this - interface of the model def RunModel(self, proj_len: int):
def Clear(self):
@property
def cache(self):
@property
def cache_agg(self):
@property
def df(self):
@property
def df_agg(self): interface of the cached method @property
def cache(self):
@property
def cache_agg(self):
@property
def df(self):
@property
def df_agg(self): You have maybe the graph sucks anywaysIt is probably more memory efficient like 2-10x and handles the long range dependencies, so maybe don't delete it, but maybe the we can all agree
might agree
certain disagreement2/6. My understanding is that avoiding the init is not idiomatic Python. Need to understand why avoiding it is desirable other than saving a few lines of code. PyTorch for example makes you do the super() on nn.Module. My disagreement with your approach is I don't know it to be widely in use, and it breaks typing. would like evidence that your approach is a common practice in Python libraries. |
Update: My previous thoughts under heading "certain disagreement", no longer disagreement on this issue. I will update my code to match the init behavior of the base What you are doing seems to be similar to what https://docs.kidger.site/equinox/api/module/module/ does. And they take the same approach to type hinting you have described previously. |
Defined default behaviour with option to override sounds good, if it mostly calls other methods (e.g. set up cache / run etc) then users can easily override. I've been working on a model dependency viewer (demo: https://lewisfogden.github.io/heavylight/experiments/term_assurance_graph.html) I found that this was easy to code when I defined the data/basis items as class instances (I made them both dataclasses), which also helps with type inference. E.g.
|
I could probably generate the graph as well, I use a stack to track dependencies between items. I'm trying to understand what you mean by the model dependencies being easier to generate when I usually take any dataframes I use and put them in a class that makes all the columns into numpy arrays. Usually looks like class Modelpoints(df: pd.DataFrame):
self.pols_if = df["pols_if"].to_numpy()
... more of that ... |
When Data is a dataclass (or a normal class like yours) - I am using the At the moment though, I'm using dictionaries, to get from dataframe I do something like: data = {col:df[col].values for col in df.columns} |
I now see you are tracking data dependencies and that is why the data format is relevant. Let me see if I can enumerate the changes that need to be made to have more of a single API.
|
Changes I'm thinking. @MatthewCaseres would like your views too
__init__
(i.e. Model behaviour rather than LightModel behaviour).backend
in Model, covering:t-2
simple aggregator that appliesagg_func
on all methods takingt
as a parameter.graph
Memory Optimisedt-2
andgraph
both take theagg_func
parameter, which defaults tonp.sum
graph
which requires a pre-run to optimise, this samples 50 points (say) from the dataset, but could pass aoptimiser_data
optional parameter?backend
allows us to add different optimisers in future (potentially even a compiler)The caller might look like this:
The text was updated successfully, but these errors were encountered: