Repository navigation
🥭 Device and autojac fixes
This patch makes .to() move the tensors given to many aggregators, weightings and scalarizers (Constant, UPGrad, DualProj, STCH, ...), and fixes jac_to_grad with repeated tensors and backward / mtl_backward with expanded .jac or .grad fields. Thanks a lot to @SajalDevX for all these fixes!
Changelog
Fixed
- Fixed
.to()not moving the tensors given to theConstant,STCH,PBIandCOSMOSscalarizers (weightsandreference). These tensors are now registered as non-persistent buffers, so they follow the dtype and device of the scalarizer without being added to itsstate_dict.FAMO'smin_lossesbuffer is also no longer in itsstate_dict. - Fixed
.to()not moving the tensors given toConstant,ConstantWeighting,UPGrad,UPGradWeighting,DualProj,DualProjWeighting,AlignedMTL,AlignedMTLWeighting,ConFIG,SDMGradWeighting,CRMOGMWeightingandGradDrop(weights,pref_vector,initial_weightsandleak). These tensors are now registered as non-persistent buffers, so they follow the dtype and device of the aggregator or weighting without being added to itsstate_dict. - Fixed
jac_to_gradfailing with anAttributeError(or, withretain_jac=True, accumulating a wrong gradient) when a tensor is repeated intensors. Repeated tensors are now only considered once. - Fixed
backwardandmtl_backwardfailing with aRuntimeErrorwhen the.jacor.gradfield held an expanded tensor (e.g. when a parameter is directly summed into a loss) and was then accumulated into by another call, or when such a.gradwas modified in-place (e.g. withclip_grad_norm_). Expanded gradients are now materialized before being stored in.grad, and an expanded.jacis now only materialized when another Jacobian is accumulated into it.