Reformating Unet#53
Conversation
|
The current version is increasing significantly the memory consumption. It is necessary to check. |
fixed |
|
@ericspod sorry, but I was not able to solve a few Torchscript problems, could you please help me or indicate someone that could help us? Right now, I am stuck in two kind of errors:
I am getting I found a few mention about this problem (https://discuss.pytorch.org/t/torchscript-jit-cant-handle-tuple-tensor-tensor-tuple-tensor-statement/115838), but I could not solve it.
This one it does not report the line of the error. =/ Both errors should be replicated when running the tests |
|
Hi Walter, The solution to the adding two tuples problem is to use lists instead, and the output_states = []
for resnet in self.resnets:
hidden_states = resnet(hidden_states, temb)
output_states.append(hidden_states)
if self.downsampler is not None:
hidden_states = self.downsampler(hidden_states)
output_states.append(hidden_states)There are quite a few places in the code this needs replacing. I'm still getting other torchscript errors, though. A big one is you can't use with a layer we would need to know the values of Another option would just be to remove the einops dependency and replace it with code that is messier but will be torchscript compatible, as MONAI trialled here |
…ror-in-latent-diffusion-models-unet-network # Conflicts: # tutorials/generative/2d_ddpm/2d_ddpm_tutorial.ipynb
|
Almost there... =/ |
…-models-unet-network # Conflicts: # generative/utils/__init__.py
|
Torchscript will use type annotations so |
|
Fixed all torchscript errors, but the performance at the tutorials is worse than before, Trying to find the source of the problem =/ |
|
Surprisingly, zero_module function makes a big change (not included in the diffuser implementation) |
|
I tried to use a version with the attentions blocks using the Rearrange layer and the MONAI's SAB here and but I am getting this torchscript error So I am adopting the version without einops again. |
…-models-unet-network
|
Could that be related to the |
Yes, it is compatible with Torchscript now and ready for Review. Let's use it for version 0.1. However, there is an attention block on it that it could make use of the SAB block from MONAI core (https://github.com/Project-MONAI/MONAI/blob/0c2fbac6eb55a546886921d9add66be9688d9775/monai/networks/blocks/selfattention.py#L20). Maybe we can use it in the future. For now, when I tried with it (using einops version 0.6.0), I got the mentioned error. |
marksgraham
left a comment
There was a problem hiding this comment.
Hi @Warvito
This looks really nice - the new unet implementation is very neat! Comments are very minor, to do with unused args and variables.
I noticed you've increased the time estimates in all the tutorials - is the new model slower? If so, do you have any idea why?
Signed-off-by: Walter Hugo Lopez Pinaya <ianonimato@hotmail.com>
Signed-off-by: Walter Hugo Lopez Pinaya <ianonimato@hotmail.com>
Signed-off-by: Walter Hugo Lopez Pinaya <ianonimato@hotmail.com>
In the |
Fix #31