Skip to content

Commit 0ef4c16

Browse files
committed
sized down the model to 70B and the instances to 4xl for ease of use
1 parent 4348ceb commit 0ef4c16

4 files changed

Lines changed: 75 additions & 82 deletions

File tree

content/learning-paths/servers-and-cloud-computing/distributed-inference-with-llama-cpp/_index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ who_is_this_for: This learning path is for developers with some experience using
1111

1212
learning_objectives:
1313
- Set up the main host and worker nodes using llama.cpp
14-
- Run a large quantized model (e.g., Llama 3.1 405B) on CPUs in a distributed manner on Arm machines
14+
- Run a large quantized model (e.g., Llama 3.1 70B) on CPUs in a distributed manner on Arm machines
1515

1616
prerequisites:
17-
- Three AWS c8g.16xlarge instances with at least 2TB EBS space.
17+
- Three AWS c8g.4xlarge instances with at least 500GB EBS space.
1818
- Python installed on the AWS instances.
1919
- Access to Meta’s gated repository for the Llama 3.1 model family, with a Hugging Face token generated for downloading the models.
2020
- Familiarity with -> [Deploy a Large Language Model (LLM) chatbot with llama.cpp using KleidiAI on Arm servers](/learning-paths/servers-and-cloud-computing/llama-cpu)

content/learning-paths/servers-and-cloud-computing/distributed-inference-with-llama-cpp/how-to-1.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@ weight: 2
66
layout: learningpathall
77
---
88
## Overview
9-
This example will run on three AWS Graviton4 c8g.16xlarge instances with 64 cores and 128GB of RAM. The instances should have 2TB disk storage, to store downloaded and quantized model weights.
9+
This example will run on three AWS Graviton4 c8g.4xlarge instances with 16 cores and 32GB of RAM. The instances should have 500GB disk storage, to store downloaded and quantized model weights.
1010

1111
You will perform these steps in this Learning Path:
1212

13-
1. Download Meta's [405B parameter llama 3.1 model](https://huggingface.co/meta-llama/Llama-3.1-405B).
13+
1. Download Meta's [70B parameter llama 3.1 model](https://huggingface.co/meta-llama/Llama-3.1-70B).
1414
2. Download and build llama.cpp, a C++ library that enables efficient inference of LLaMA and similar large language models on CPUs, optimized for local and embedded environments.
1515
3. Convert Meta's safetensors files to a single gguf file.
1616
4. Quantize the 16 bit gguf weights file to 4 bit weights.
1717
5. Load and run the model.
1818

19-
{{% notice Note %}}The "reading time" mentioned on the Introduction page doesn't include downloading, converting, and requantizing the model. The process mentioned on this page will take 6+ hours. You may skip the model download and quantization if you have a quantized gguf file ready to use.{{% /notice %}}
19+
{{% notice Note %}}The "reading time" mentioned on the Introduction page doesn't include downloading, converting, and requantizing the model. The process mentioned on this page will take 1-2 hours. You may skip the model download and quantization if you have a quantized gguf file ready to use.{{% /notice %}}
2020

2121
## Procedure
22-
First, ensure you have permissions to access to Meta's [405B parameter llama 3.1 model](https://huggingface.co/meta-llama/Llama-3.1-405B).
22+
First, ensure you have permissions to access to Meta's [70B parameter llama 3.1 model](https://huggingface.co/meta-llama/Llama-3.1-70B).
2323

2424
{{% notice Note %}}
2525
Remember that you will need to replicate the install steps below on each device. Do NOT replicate the download and quantization step, llama.cpp will send the tensors to the cache.
@@ -29,7 +29,7 @@ Remember that you will need to replicate the install steps below on each device.
2929

3030
```bash
3131
apt update
32-
apt install python3.12-venv
32+
apt install -y python3.12-venv
3333
python3 -m venv myenv
3434
source myenv/bin/activate
3535
```
@@ -48,7 +48,6 @@ cmake --build . --config Release
4848
`llama.cpp` is now built in the `build-rpc/bin` directory.
4949
Check that `llama.cpp` has built correctly by running the help command:
5050
```bash
51-
cd build-rpc
5251
bin/llama-cli -h
5352
```
5453

@@ -58,15 +57,16 @@ Install Huggingface Hub in the virtual environment:
5857
pip3 install huggingface_hub
5958

6059
```
61-
Make a python file and name it download.py:
60+
Make a python file in a parallel directory to llama.cpp and name it download.py:
6261
```bash
62+
cd ../..
6363
vi download.py
6464
```
6565
Write the following code to it:
6666
```python
6767
import os
6868
from huggingface_hub import snapshot_download
69-
model_id = "meta-llama/Llama-3.1-405B"
69+
model_id = "meta-llama/Llama-3.1-70B"
7070
local_dir = "llama-hf"
7171
# Create the directory if it doesn't exist
7272
os.makedirs(local_dir, exist_ok=True)
@@ -87,7 +87,7 @@ Following lines installs the files important for conversion to .gguf format.
8787
pip3 install -r llama.cpp/requirements.txt
8888
python3 llama.cpp/convert_hf_to_gguf.py llama-hf
8989
cd llama.cpp/build-rpc
90-
bin/llama-quantize ../../llama-hf/llama-3.1-405B-F16.gguf Q4_0
90+
bin/llama-quantize ../../llama-hf/Llama-3.1-70B-F16.gguf Q4_0
9191
```
9292
You may rename the resultant file to model.gguf and use it. There are different quantization options as well, as shown below:
9393
```bash

content/learning-paths/servers-and-cloud-computing/distributed-inference-with-llama-cpp/how-to-2.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ weight: 3
66
layout: learningpathall
77
---
88
## Cluster overview
9-
llama.cpp is a C++ library that enables efficient inference of LLaMA and similar large language models on CPUs, optimized for local and embedded environments. Just over a year ago from the publication date of this article, rgerganov’s RPC code was merged into llama.cpp, enabling distributed inference of large LLMs across multiple CPU-based machines—even when the models don’t fit into the memory of a single machine. In this learning path, we’ll explore how to run a 405B parameter model on Arm-based CPUs.
9+
llama.cpp is a C++ library that enables efficient inference of LLaMA and similar large language models on CPUs, optimized for local and embedded environments. Just over a year ago from the publication date of this article, rgerganov’s RPC code was merged into llama.cpp, enabling distributed inference of large LLMs across multiple CPU-based machines—even when the models don’t fit into the memory of a single machine. In this learning path, we’ll explore how to run a 70B parameter model on Arm-based CPUs.
1010

1111
For the purposes of this demonstration, the following experimental setup will be used:
1212
- Total number of instances: 3
13-
- Instance type: c8g.16xlarge
14-
- Model: model.gguf (Llama-3.1-405B_Q4_0)
13+
- Instance type: c8g.4xlarge
14+
- Model: model.gguf (Llama-3.1-70B_Q4_0, ~38GB when quantized to 4 bits)
1515

1616
One of the three nodes will serve as the master node, which physically hosts the model file. The other two nodes will act as worker nodes. In llama.cpp, remote procedure calls (RPC) are used to offload both the model and the computation over TCP connections between nodes. The master node forwards inference requests to the worker nodes, where all the actual computation is performed.
1717

1818
## Cluster setup
1919

20-
Choose two of the three devices to act as backend workers. If the devices had varying compute capacities, the ones with the highest compute should be selected—especially for a 405B model. However, since all three devices have identical compute capabilities in this case, you can select any two to serve as backend workers.
20+
Choose two of the three devices to act as backend workers. If the devices had varying compute capacities, the ones with the highest compute should be selected. However, since all three devices have identical compute capabilities in this case, you can select any two to serve as backend workers.
2121

2222
Communication between the master node and the worker nodes occurs through a socket created on each worker. This socket listens for incoming data from the master—such as model parameters, tokens, hidden states, and other inference-related information.
2323
{{% notice Note %}}The RPC feature in llama.cpp is not secure by default, so you should never expose it to the open internet. To mitigate this risk, ensure that the security groups for all your EC2 instances are properly configured—restricting access to only trusted IPs or internal VPC traffic. This helps prevent unauthorized access to the RPC endpoints.{{% /notice %}}
@@ -36,4 +36,5 @@ Below are the available flag options that can be used with the rpc-server functi
3636
-m MEM, --mem MEM backend memory size (in MB)
3737
-c, --cache enable local file cache
3838
```
39-
Setting the host to 0.0.0.0 might seem counterintuitive given the earlier security warning, but it’s acceptable in this case because the security groups have been properly configured to block any unintended or unauthorized access.
39+
40+
There is currently no way to pre-load tensors onto the workers, the `-c` option will cache tensors during runtime. The first time inference runs the tensors will be distributed to the workers.

0 commit comments

Comments
 (0)