`pipeline` support for `device="mps"` (or any other string)
Author: julien-c
Pull request: yes

No tests yet given we don't officially support `torch==1.12` yet (and M1-based CI is still a work in progress)

Comments:
_The documentation is not available anymore as the PR was closed or merged._

Thanks @julien-c .  am getting a new error
My guess this is on the pytorch op.
> NotImplementedError: The operator 'aten::unique_consecutive' is not current implemented for the MPS device. If you want this op to be added in priority during the prototype phase of this feature, please comment on https://github.com/pytorch/pytorch/issues/77764. As a temporary fix, you can set the environment variable `PYTORCH_ENABLE_MPS_FALLBACK=1` to use the CPU as a fallback for this op. WARNING: this will be slower than running natively on MPS.



Here is the traceback

> preds = pipe('i am feeling awesome', ['positive', 'negative'])
>   File "/Volumes/training/torch-gpu/env/lib/python3.8/site-packages/transformers/pipelines/zero_shot_classification.py", line 182, in __call__
>     return super().__call__(sequences, **kwargs)
>   File "/Volumes/training/torch-gpu/env/lib/python3.8/site-packages/transformers/pipelines/base.py", line 1071, in __call__
>     return self.run_single(inputs, preprocess_params, forward_params, postprocess_params)
>   File "/Volumes/training/torch-gpu/env/lib/python3.8/site-packages/transformers/pipelines/base.py", line 1093, in run_single
>     model_outputs = self.forward(model_inputs, **forward_params)
>   File "/Volumes/training/torch-gpu/env/lib/python3.8/site-packages/transformers/pipelines/base.py", line 987, in forward
>     model_outputs = self._forward(model_inputs, **forward_params)
>   File "/Volumes/training/torch-gpu/env/lib/python3.8/site-packages/transformers/pipelines/zero_shot_classification.py", line 201, in _forward
>     outputs = self.model(**model_inputs)
>   File "/Volumes/training/torch-gpu/env/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1186, in _call_impl
>     return forward_call(*input, **kwargs)
>   File "/Volumes/training/torch-gpu/env/lib/python3.8/site-packages/transformers/models/bart/modeling_bart.py", line 1516, in forward
>     if len(torch.unique_consecutive(eos_mask.sum(1))) > 1:
>   File "/Volumes/training/torch-gpu/env/lib/python3.8/site-packages/torch/_jit_internal.py", line 447, in fn
>     return if_false(*args, **kwargs)
>   File "/Volumes/training/torch-gpu/env/lib/python3.8/site-packages/torch/_jit_internal.py", line 447, in fn
>     return if_false(*args, **kwargs)
>   File "/Volumes/training/torch-gpu/env/lib/python3.8/site-packages/torch/functional.py", line 913, in _consecutive_return_output
>     output, _, _ = _unique_consecutive_impl(input, return_inverse, return_counts, dim)
>   File "/Volumes/training/torch-gpu/env/lib/python3.8/site-packages/torch/functional.py", line 830, in _unique_consecutive_impl
>     output, inverse_indices, counts = _VF.unique_consecutive(  # type: ignore[attr-defined]

Yes @AsaKal, please comment on https://github.com/pytorch/pytorch/issues/77764

⚠️ You might have to `os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1"` because many operations are still not implemented

also cc @pacman100 for visibility