← 开源
jankais3r

LLaMA_MPS

Run LLaMA (and Stanford-Alpaca) inference on Apple Silicon GPUs.

InfrastructureInference service optimizationPython
在 GitHub 打开
增长势头
+024 小时新增 Star0.0%
576
Star
42
Fork
+0
本周
2
贡献者
创建于 2023-03-08 · 更新于 2026-09-21 · 今日第 16714 名
主要开发者
jankais3rBirch-san

jankais3r/LLaMA_MPS 排名第 16,714,有 576 个星标。

同类别比较

jankais3r/LLaMA_MPS 排名第 16,714,此处有 8 个同类条目;NVIDIA/jitify 排名第 16,723。

同类别比较
名称排名指标
kreeben/resin16,676
语言:
C#
星标数:
578
分叉数:
41
简介:
Language model search engine built on a vector database and an anything key/value store.
tensorflow/tfjs-wechat16,683
语言:
TypeScript
星标数:
578
分叉数:
106
简介:
WeChat Mini-program plugin for TensorFlow.js
liuzhuang13/slimming16,696
语言:
Lua
星标数:
577
分叉数:
75
简介:
Learning Efficient Convolutional Networks through Network Slimming, In ICCV 2017.
microsoft/psi16,697
语言:
C#
星标数:
577
分叉数:
103
简介:
Platform for Situated Intelligence
NVIDIA/jitify16,723
语言:
C++
星标数:
575
分叉数:
80
简介:
A single-header C++ library for simplifying the use of CUDA Runtime Compilation (NVRTC).
litter-coder/midjourney-proxy-plus16,737
星标数:
575
分叉数:
68
简介:
midjourney-proxy的先行版
c0deJedi/nbd-vram16,765
语言:
Shell
星标数:
573
分叉数:
18
简介:
Use your NVIDIA GPU's VRAM as swap space on Linux. Built for laptops with soldered memory and no upgrade path. If you have an RTX card sitting there with 8GB of VRAM and you're getting swapped to SSD, this puts that VRAM to work
Maknee/minigpt4.cpp16,775
语言:
C++
星标数:
572
分叉数:
28
简介:
Port of MiniGPT4 in C++ (4bit, 5bit, 6bit, 8bit, 16bit CPU inference with GGML)
关键参数与规格
关键参数与规格
参数值
语言Python
类别Infrastructure
子类别Inference service optimization
关键词LocalAI
星标数576
分叉数42
贡献者2
创建日期2023-03-08
更新日期2026-09-21
1 天星标数0
7 天星标数0
排名16,714
上次排名16,503
排名变化-211
7 天星标排名15,681
上次 7 天星标排名15,688
7 天星标排名变化7
总星标排名17,331
上次总星标排名17,302
总星标排名变化-29
国家Switzerland
README 摘录

LLaMA_MPS Run LLaMA (and Stanford-Alpaca) inference on Apple Silicon GPUs. As you can see, unlike other LLMs, LLaMA is not biased in any way 😄 Initial setup steps **1. Install Python dependencies** LLaMA-specific setup **3. Download the model weights and put them into a folder called** (e. _(Optional)_ Reshard the model weights (13B/30B/65B)** Since we are running the inference on a single GPU, we need to merge the larger models' weights into a single file. Run

the inference** The above steps will let you run inference on the raw LLaMA model in an 'auto-complete' mode. If you would like to try the 'instruction-response' mode similar to ChatGPT using the fine-tuned weights of Stanford Alpaca, continue the setup with the following steps: Alpaca-specific setup **3. Download the fine-tuned weights (available for 7B/13B)** **4. GB | **Min specs per model (slow due to swapping):** 7B - 16 GB RAM 13B - 32 GB RAM 30B

- 64 GB RAM 65B - needs testing **Recommended specs per model:** 7B - 24 GB RAM 13B - 48 GB RAM 30B - 96 GB RAM 65B - needs testing Parameters to experiment with **- max_batch_size** If you have spare memory (e. , when running the 13B model on a 64 GB Mac), you can increase the batch size by using the argument. **- max_seq_len** To increase/decrease the maximum length of generated text, use the argument. **- use_repetition_penalty** The example script penalizes

the model for generating a repetitive content. This should lead to higher quality output, but it slightly slows down the inference. Run the script with argument to disable the penalty algorithm. Alternatives The best alternative to LLaMA_MPS for Apple Silicon users is llama. cpp, which is a C/C++ re-implementation that runs the inference purely on the CPU part of the SoC. Because compiled C code is so much faster than Python, it can actually beat this MPS

implementation in speed, however at the cost of much worse power and heat efficiency. See the below comparison when deciding which implementation better fits your use case. 16 | Credits facebookresearch (original code) markasoftware (cpu optimizations) remixer-dec (mps optimizations) venuatu (continuous token printing / loading optimizations) benob (reshard script) tloen (repetition penalty / LoRA merge script)

常见问题

记录了多少星标和分叉?

jankais3r/LLaMA_MPS 有 576 个星标和 42 个分叉。

仓库排名是多少?

jankais3r/LLaMA_MPS 排名第 16,714。

记录的语言和类别是什么?

jankais3r/LLaMA_MPS 有 576 个星标,语言为 Python,类别为 Infrastructure。

哪个仓库排名最接近?

jankais3r/LLaMA_MPS 与 NVIDIA/jitify 比较,后者排名第 16,723,有 575 个星标。

README

LLaMA_MPS

Run LLaMA (and Stanford-Alpaca) inference on Apple Silicon GPUs.

As you can see, unlike other LLMs, LLaMA is not biased in any way 😄

Initial setup steps

1. Clone this repo

git clone https://github.com/jankais3r/LLaMA_MPS

2. Install Python dependencies

cd LLaMA_MPS
pip3 install virtualenv
python3 -m venv env
source env/bin/activate
pip3 install -r requirements.txt
pip3 install -e .

LLaMA-specific setup

3. Download the model weights and put them into a folder called models (e.g., LLaMA_MPS/models/7B)

4. (Optional) Reshard the model weights (13B/30B/65B)

Since we are running the inference on a single GPU, we need to merge the larger models' weights into a single file.

mv models/13B models/13B_orig
mkdir models/13B
python3 reshard.py 1 models/13B_orig models/13B

5. Run the inference

python3 chat.py --ckpt_dir models/13B --tokenizer_path models/tokenizer.model --max_batch_size 8 --max_seq_len 256

The above steps will let you run inference on the raw LLaMA model in an 'auto-complete' mode.

If you would like to try the 'instruction-response' mode similar to ChatGPT using the fine-tuned weights of Stanford Alpaca, continue the setup with the following steps:

Alpaca-specific setup

3. Download the fine-tuned weights (available for 7B/13B)

python3 export_state_dict_checkpoint.py 7B
python3 clean_hf_cache.py

4. Run the inference

python3 chat.py --ckpt_dir models/7B-alpaca --tokenizer_path models/tokenizer.model --max_batch_size 8 --max_seq_len 256

Memory requirements

Model Starting memory during inference Peak memory during checkpoint conversion Peak memory during resharding
7B 16 GB 14 GB N/A
13B 32 GB 37 GB 45 GB
30B 66 GB 76 GB 125 GB
65B ?? GB ?? GB ?? GB

Min specs per model (slow due to swapping):

  • 7B - 16 GB RAM
  • 13B - 32 GB RAM
  • 30B - 64 GB RAM
  • 65B - needs testing

Recommended specs per model:

  • 7B - 24 GB RAM
  • 13B - 48 GB RAM
  • 30B - 96 GB RAM
  • 65B - needs testing

Parameters to experiment with

- max_batch_size

If you have spare memory (e.g., when running the 13B model on a 64 GB Mac), you can increase the batch size by using the --max_batch_size=32 argument. Default value is 1.

- max_seq_len

To increase/decrease the maximum length of generated text, use the --max_seq_len=256 argument. Default value is 512.

- use_repetition_penalty

The example script penalizes the model for generating a repetitive content. This should lead to higher quality output, but it slightly slows down the inference. Run the script with --use_repetition_penalty=False argument to disable the penalty algorithm.

Alternatives

The best alternative to LLaMA_MPS for Apple Silicon users is llama.cpp, which is a C/C++ re-implementation that runs the inference purely on the CPU part of the SoC. Because compiled C code is so much faster than Python, it can actually beat this MPS implementation in speed, however at the cost of much worse power and heat efficiency.

See the below comparison when deciding which implementation better fits your use case.

Implementation Total run time - 256 tokens Tokens/s Peak memory use Peak SoC temperature Peak SoC Power consumption Tokens per 1 Wh
LLAMA_MPS (13B fp16) 75 s 3.41 30 GB 79 °C 10 W 1,228.80
llama.cpp (13B fp16) 70 s 3.66 25 GB 106 °C 35 W 376.16

Credits

排名相邻
同类项目