Replace torch.nn.Module with metatensor.torch.learn.nn.Module#938
Replace torch.nn.Module with metatensor.torch.learn.nn.Module#938GardevoirX wants to merge 4 commits intometatensor:mainfrom
torch.nn.Module with metatensor.torch.learn.nn.Module#938Conversation
|
Why is this needed? This might make it look more daunting for contributors of new architectures, since it seems you can't no longer use raw torch, you have to understand what the metatensor torch is 😅 |
It's said that it can allow us moving from device and dtypes more easily, because the torch's module doesn't support moving things like tensormap when you call .to |
|
Hmm I see, could we only apply the change to the modules that need it, which as far as I understand are the |
|
Or could this be solved by overwriting the |
|
my understanding is that this is helpful for modules that use tensormaps. so there's no point in converting models that are 100% torch, but those that have some metastuff would benefit from being converted. |
I think a no-brain-choice of using only one |
|
From the perspective of an outsider I think it is much better to use |
|
Okay if so I think I don't need to replace everything with |
|
That would be my opinion yes, but maybe others have a different opinion, let's see🙂 |
|
So This should remove a bunch of workaround and I personally think that it is best not to have two
No, because this would only override the method in Python, not in TorchScript. |
The only place where I see this PR removing code is for the CompositionModel and Scaler. Will it allow to remove more code?
This is not so clear to me to be honest. The people that will contribute to metatrain with new architectures for sure know what
Why? |
Any place using TensorMap/TensorBlock/Labels inside the model should become simpler. Everything else will stay the same.
I mean most people don't know how
Because that's how TorchScript works? You can not override any of the default methods of torch.nn.Module. For |
So, some other place apart from CompositionModel and Scaler? haha
Ok, didn't know this. |
3b13410 to
07b3f5e
Compare
Contributor (creator of pull-request) checklist
Maintainer/Reviewer checklist
📚 Documentation preview 📚: https://metatrain--938.org.readthedocs.build/en/938/