Closed tom-andersson closed 4 months ago
Hmmm, @tom-andersson, I've not seen any strangeness on my side. Would you be able to create a MWE for the error? Happy to look more closely!
It seems that TF & PyTorch tensors are getting mixed, possibly because the model is created with the one type and run with the other.
Thanks @wesselb! to clarify I didn't mean plum
was at fault, more just a hypothesis that plum
was now catching a potential bug, as you suggest. However, the failing test module (test_active_learning.py
) only uses TensorFlow (it imports deepsensor.tensorflow
, which sets everything to be TF objects), and there are no references to torch objects in the tests. Also, tests are passing when I run them locally at HEAD.
@davidwilby any thoughts on what's going on here?
Also, tests are passing when I run them locally at HEAD.
Hmmm, this is really weird. Could it possibly be to do with the Python version and/or order in which the tests are run? Do they also locally pass when you install a fresh env and run the entire test suite as a whole?
Sorry that I haven't been able to look at this until now.
I have now been able to replicate this behaviour locally with python 3.8, neuralprocesses 0.2.6, plum-dispatch 2.4.1, tensorflow 2.13.1, torch 2.1.2. (Also same behaviour for neuralprocesses 0.2.2 and plum-dispatch 2.2.2.)
All tests pass with python 3.11, neuralprocesses 0.2.2, plum-dispatch 2.2.2, tensorflow 2.15.0.post1, torch 2.2.0.
Tests also pass with everything the same except: neuralprocesses 0.2.6, plum-dispatch 2.4.1
(NB I notice that tensorflow does not support python 3.8.)
On the CI run you linked above @tom-andersson, this is actually run with Python 3.10.12 (not 3.8, relates to #116) tensorflow==2.16.1, NeuralProcesses==0.2.5, plum-dispatch==2.3.6 - which is replicated locally as well.
Haven't quite got to the bottom of this issue but just putting this here for now.
Having a bit more of a play with this now I can replicate locally and the test_active_learning
tests only fail when run in the same test session as other tests, not when only that one module is run on its own.
There seems to be a lot of weird behaviour in the tests when running different combinations of the tests in the same session, not just in test_active_learning
but elsewhere as well, leading me to believe there was some undesirable pollution between the different test modules for some reason. In this case, resulting in the mix of torch and tensorflow types.
I've no idea why this has only recently become a problem, however..
@davidwilby fixed this in #117 :-)
Perhaps import deepsensor.torch
in test_model
wasn't playing well with import deepsensor.tensorflow
in test_active_learning
, triggering backends
to complain about mixed types, which is now fixed by using setUpClass
in test classes. I don't fully understand why test leakage would start becoming a problem seemingly "out of nowhere" though. Oh well, it's fixed now.
We have failing tests in test_active_learning.py where somewhere within a neuralprocesses call stack a PyTorch tensor is trying to be converted to a TensorFlow tensor (TypeError: No promotion rule for
torch.Tensor
andtensorflow.python.framework.ops.EagerTensor
.).I believe these tests are failing due to recent (~2 weeks ago) changes in plum meaning an error is raised that was not being raised before. There have been some changes to plum’s promotion handling since the tests started failing, and no changes in deepsensor. I’m not 100% sure though and will have to investigate further.
cc @wesselb @davidwilby