modulus-sym icon indicating copy to clipboard operation
modulus-sym copied to clipboard

:bug: [BUG]: Incorrect get_num_losses return value when using custom loss function

Open zinccat opened this issue 2 years ago • 2 comments

The implementation of get_num_losses in domain.py is summing up the number of output names in constraints. Yet this is not the case when using custom loss function, e.g. when using variational constraint like the case in https://docs.nvidia.com/deeplearning/modulus/modulus-sym/user_guide/intermediate/variational_example.html

zinccat avatar Jun 05 '23 13:06 zinccat

Thanks for the report, I agree this is a bug. The get_num_losses in domain uses the output names of each constraint to get a total number of losses.

The custom loss, particularly in the variational constraint does not give its output variables ahead of time and the variational constraint constructor will have 0 output keys (and thus say it has zero losses) since there are no output keys of a variational data set.

Unsure about a clean fix, without requiring additional user information its not possible presently to tell that a custom loss exists in this constraint without a forward pass. Example impacted.

NickGeneva avatar Jun 06 '23 15:06 NickGeneva

@ktangsali Can you please review if we can address this bug?

ram-cherukuri avatar Feb 14 '25 01:02 ram-cherukuri