Conversation
fnattino
left a comment
There was a problem hiding this comment.
Nice work @SCiarella! I have left a few comments, note that not all comments are suggestions for changes - some are just notes for future work/discussion. Anyway, feel free to address only what you think makes sense!
| # Default values that can be overridden before instantiation | ||
| device = torch.device("cuda" if torch.cuda.is_available() else "cpu") | ||
| dtype = torch.float64 | ||
|
|
There was a problem hiding this comment.
I suspect the default device and dtype will be the same everywhere? So maybe we could define default values of DTYPE and DEVICE at a global level, e.g. in a defaults.py module, instead of having it defined for each module/model? What do yout think?
There was a problem hiding this comment.
Good point! Yes, they have to be the same everywhere, so it makes sense to follow a more centralized approach that is accessible for the user.
In the next iteration of this PR, I have added to config.py a new class called ComputeConfig that globally controls them. In its docstring, I have reported a small example on how to use that, but we should probably link that somewhere else if we want to use this class to control the global behavior.
|
Thanks @fnattino for the careful review! I have implemented most of the suggestions that you proposed. In particular, I introduced a new class in There is a point that remains open regarding the |
|
fnattino
left a comment
There was a problem hiding this comment.
Thanks a lot for having a look at all the comments @SCiarella - looks good to me!
I like
yes lets make an issue for this to not forget it. |
SarahAlidoost
left a comment
There was a problem hiding this comment.
@SCiarella thanks for the implementation 🥇 All good to me. Nice that you could test the gpu part on your system. Later in #58, we will find alternatives.



Closes issue #23
This PR exposes
deviceanddtypesuch that they can be controlled and set externally by the user. This is particularly relevant for runningdiffwofoston GPU by settingdevice="cuda". There are example of this in the notebooks and in the documentation.The tests have been update by adding a new
@pytest.fixturethat checks if a GPU is available, and if so, it re-runs the most important tests on the GPU a second time. Notice that GitHub actions do not provide GPU access (for free), so I have been using my local hardware to test the code.Notice that without finalizing the Engine, the GPU device could be slower than the CPU, due to temporary fixes like the use of
deepcopyin theTestEngine.