[TRL] Disable MPS Backend for testing

Hello dears,

I’d like to contribute to TRL , and to do it properly I need to run the test pyramid.

I encounter the following problem in the tests:

  • The models are instantiated on CPU
  • The dataset batches are located on MPS

This is explained as the default behaviour of DataLoader is to reach for CUDA or MPS devices, and my MacBook has the latter one available.

Therefore, I need to find a way, to disable globally the use of MPS for the time of the tests.

I know that for CUDA I could play with the variable CUDA_VISIBLE_DEVICES, but I could not find such trick for MPS.

Any idea ? I saw that there was an issue closely related to that, but that is at stale for quite some time: Input_ids not automatically convert to device · Issue #502 · huggingface/trl · GitHub

Kind regards,

Tristan