jyaacoub / MutDTA

Improving the precision oncology pipeline by providing binding affinity purtubations predictions on a pirori identified cancer driver genes.
1 stars 2 forks source link

RuntimeError with GVP on DDP training (unused parameters) #91

Closed jyaacoub closed 5 months ago

jyaacoub commented 6 months ago

This error occurs when running GVP (#90) with distributed GPUs via DDP. I need to identify which parameters in the GVP model are being left unused since they are just wasting space. the temp solution will have to do for now.

Error message:

RuntimeError: Expected to have finished reduction in the prior iteration before starting a new one. This error indicates that your module has parameters that were not used in producing loss. You can enable unused parameter detection by passing the keyword argument find_unused_parameters=True to torch.nn.parallel.DistributedDataParallel, and by making sure all forward function outputs participate in calculating loss. If you already have done the above, then the distributed data parallel module wasn't able to locate the output tensors in the return value of your module's forward function. Please include the loss function and the structure of the return value of forward of your module when reporting this issue (e.g. list, dict, iterable). Parameter indices which did not receive grad for rank 0: 12 19 24 29 34 43 44 45 50 55 60 65 74 75 76 81 86 91 96 105 106 107 112 119 In addition, you can set the environment variable TORCH_DISTRIBUTED_DEBUG to either INFO or DETAIL to print out information about which particular parameters did not receive gradient on this rank as part of this error

Temporary solution

Alter DDP call to include find_unused_parameters=True:

    model = nn.parallel.DistributedDataParallel(model, device_ids=[args.gpu], find_unused_parameters=True)
jyaacoub commented 5 months ago

The reason why this occurs is due to inheriting from DGraphDTA:

https://github.com/jyaacoub/MutDTA/blob/e4a6f8db3793d3925bffaf24fe25410a79922fcd/src/models/gvp_models.py#L60

The issue is that the original DGraphDTA ligand branch is still initialized, but in this new subclass we replace it with a GVP branch. https://github.com/jyaacoub/MutDTA/blob/e4a6f8db3793d3925bffaf24fe25410a79922fcd/src/models/prior_work.py#L28

jyaacoub commented 5 months ago

this isnt that big of an issue and I don't have the bandwidth to fix atm