Do you call any other random functions from another lib like numpy?
If it’s possible, I would remove unnecessary parts of the code and see if a minimal example produces the deterministic behavior.
Regarding your second question:
@albanD posted a suggestion here 34