Efficiently Distribute Large Language Models (LLM) among Multiple Machines
This repository, named llm-fission, addresses the need to distribute Large Language Models efficiently across multiple machines. The system is designed to facilitate the execution of substantial language models by distributing the workload among various machines.
A server is a machine responsible for hosting one or multiple transformer decoder layers.
A client is a machine responsible for hosting the embedding layer and lm_head.
Servers host one or multiple transformer decoder layers within the distributed environment. Each server listens for incoming requests from clients at its designated port.
-
Begin by creating a dedicated Docker network:
docker network create mynetwork
-
Construct a Docker image based on the provided Dockerfile:
docker build -t docker_test -f <path/to/dockerfile> .
-
Launch a server container, designating its role ('server') alongside the required layer range (0 through 11):
docker run -e DEVICE="cpu" -e REPO="Writer/palmyra-small" -e USER_TYPE=server -e LAYERS=0:11 --network my_network -p 7001:7001 --name my_container docker_test
Clients, which manage the embedding layer and lm_head, communicate with appropriate servers to fetch processed data seamlessly.
-
Use the previously created Docker network when building another container:
docker build -t docker_test -f <path/to/dockerfile> .
-
Initialize a client container, identifying itself accordingly ('client'), along with the URL mappings associated with each respective server layer:
docker run -e DEVICE="cpu" -e REPO="Writer/palmyra-small" -e USER_TYPE=client -e LAYER_URL_MAPPING="0:11=http://my_container:7001/block2," --network my_network -p 7002:7002 --name my_container2 docker_test
For locally accessible machines, establish a shared Docker network called mynetwork via the following command:
docker network create mynetwork| Command | Description | Example |
|---|---|---|
docker network create mynetwork |
Creates a custom Docker network | See previous note. |
docker build ... |
Generates a Docker image based on a Dockerfile | docker build -t... |
docker run ... |
Executes a Docker container | Various examples. |
Feel free to reach out if further clarification is needed. Happy coding! 💻