-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes to run Llama2 on Apple Mac M2 / MPS
- Loading branch information
GD Dev
committed
Jul 21, 2023
1 parent
6c7fe27
commit 9a5670b
Showing
3 changed files
with
46 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9a5670b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this example. After following you, nn my intel mac this raised another exception:
File "/opt/dev/llms/codellama/llama/model.py", line 279, in init
File "/opt/dev/llms/codellama/llama/model.py", line 279, in init
self.freqs_cis = precompute_freqs_cis(
self.freqs_cis = precompute_freqs_cis(
File "/opt/dev/llms/codellama/llama/model.py", line 62, in precompute_freqs_cis
File "/opt/dev/llms/codellama/llama/model.py", line 62, in precompute_freqs_cis
freqs_cis = torch.polar(torch.ones_like(freqs), freqs) # complex64
freqs_cis = torch.polar(torch.ones_like(freqs), freqs) # complex64
NotImplementedError: The operator 'aten::polar.out' is not currently 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 pytorch/pytorch#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.NotImplementedError: The operator 'aten::polar.out' is not currently 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 pytorch/pytorch#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.ERROR:torch.distributed.elastic.multiprocessing.api:failed (exitcode: 1) local_rank: 0 (pid: 53666) of binary: /opt/dev/miniconda3/envs/llama/bin/python3.10
and after setting the env variable:
RuntimeErrorRuntimeError: : ProcessGroupGloo::allgather: invalid tensor type at index 0 (expected TensorOptions(dtype=c10::Half, device=cpu, layout=Strided, requires_grad=false (default), pinned_memory=false (default), memory_format=(nullopt)), got TensorOptions(dtype=c10::Half, device=mps:0, layout=Strided, requires_grad=false (default), pinned_memory=false (default), memory_format=(nullopt)))ProcessGroupGloo::allgather: invalid tensor type at index 0 (expected TensorOptions(dtype=c10::Half, device=cpu, layout=Strided, requires_grad=false (default), pinned_memory=false (default), memory_format=(nullopt)), got TensorOptions(dtype=c10::Half, device=mps:0, layout=Strided, requires_grad=false (default), pinned_memory=false (default), memory_format=(nullopt)))
ERROR:torch.distributed.elastic.multiprocessing.api:failed (exitcode: 1) local_rank: 0 (pid: 55764) of binary: /opt/dev/miniconda3/envs/llama/bin/python3.10
9a5670b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you need to install the lastest pytorch from source. They fixed the "aten::polar" stuff apparently today just a few hours ago which is crazy fitting for us.
After that I didn't need to set the variable anymore.
Here's the repo: https://github.com/pytorch/pytorch
Here's the instructions as far as I remember: :D
After that it should work.