NVIDIA / Fuser

A Fusion Code Generator for NVIDIA GPUs (commonly known as "nvFuser")
Other
265 stars 53 forks source link

NVFuserTest and mpi_test aren't compatible. #3214

Open wujingyue opened 2 weeks ago

wujingyue commented 2 weeks ago

https://github.com/NVIDIA/Fuser/compare/wjy/pytest?expand=1 is a failed attempt of mine.

Currently, Python distributed tests rely on mpi_test to get ranks, sizes and the barrier. After we expose Communicator via nvfuser's Python API, we should be able to replace the mpi_test fixture with a singleton nvfuser.communicator.

However, this indicates a general problem of incompatibility between pytest and unittest as discussed https://github.com/NVIDIA/Fuser/pull/3192#discussion_r1802331505. Apparently, pytest fixture and unittest.TestCase don't like each other.

cc @Priya2698 and @rdspring1

Priya2698 commented 2 weeks ago

This TestCase comes from torch.testing._internal.common_utils: https://github.com/pytorch/pytorch/blob/6d8c9be54bd78846aa7c55625deec11b10ae544f/torch/testing/_internal/common_utils.py#L2773.

TestCase is further derived from expecttest. I need to check if expecttest uses UnitTest.

We use some assert methods from TestCase like assertEqual or assertTrue which should be replacable to avoid inheriting from TestCase.

Priya2698 commented 2 weeks ago

expecttest should work with both pytest and unittest based on their documentation: https://github.com/pytorch/expecttest

wujingyue commented 2 weeks ago

Good to know that! It seems to say expecttest is expected to work under the pytest runner. However, I don't think expecttest is claimed to be compatible with all pytest features, e.g., fixtures in this particular example. That's at least my impression from https://github.com/pytorch/pytorch/issues/11578#issuecomment-627688827, and thanks @IvanYashchuk for the pointer.