Mava icon indicating copy to clipboard operation
Mava copied to clipboard

[BUG] Remove nested tf.function

Open arnupretorius opened this issue 3 years ago • 5 comments

Describe the bug Nested tf.function decorators are causes TF to constantly retrace which is could cause significant performance and memory issues.

Additional context I think this bug creeped in when we refactored our code to separate forward and backward passes.

Possible Solution Remove tf.function decorator from the backward pass.

This bug is also related to #77 and #346

arnupretorius avatar Feb 04 '22 07:02 arnupretorius

Already fixed in #362.

arnupretorius avatar Feb 04 '22 07:02 arnupretorius

Having tf.function over the _policy function in the executor causes retracing as well because _policy is called inside a for loop in the select_actions function. It is better to create a new function called _select_functions and put the for loop inside there and put the tf.function decorator on that function. See MADQN executor in #362

jcformanek avatar Feb 04 '22 08:02 jcformanek

Having tf.function over the _policy function in the executor causes retracing as well because _policy is called inside a for loop in the select_actions function. It is better to create a new function called _select_functions and put the for loop inside there and put the tf.function decorator on that function. See MADQN executor in #362

Thanks @jcformanek! Can you please make an issue for this with the above advice that we look at fixing it for other systems as well.

arnupretorius avatar Feb 08 '22 13:02 arnupretorius

Reopening this issue until we fix the problem in all other systems.

jcformanek avatar Feb 11 '22 14:02 jcformanek

https://github.com/instadeepai/Mava/pull/353 handles this for ppo.

KaleabTessera avatar Feb 16 '22 10:02 KaleabTessera

Closing all TF issues as we are depreciating our TF systems.

DriesSmit avatar Sep 08 '22 14:09 DriesSmit