Scale your local AI
beyond one device.
Connect consumer hardware you have already paid for into one distributed inference runtime.
Zero or lowest new hardware cost
Enhance local AI
at lowest cost.
No need to buy a higher-performance workstation. Pool the heterogeneous devices you already own—laptops, desktops, tablets, Mac Minis, and devices of different operating systems.
Scale what matters
Scalability,
not just a speed miracle.
Bring more of your existing hardware together to expand what local AI can do—without pretending one device becomes something it is not.
Application cases
Bring every device into your local AI.

Your devices. Your private AI.
Pool the hardware around your home into one private inference service.

Shared capacity for the team.
Turn existing office devices into a useful local AI pool for everyday work.

Different LANs. One AI pool.
Pool devices across remote LANs and strengthen the local AI you use here.
Flexible by design
Easy to deploy. Free to adapt.
PRIMA manages devices as they join and leave, without imposing a specific device or network setup.
Devices join automatically.
When a device comes online, PRIMA discovers it and adds it to the inference pool—no complex configuration required.
Devices leave. PRIMA adapts.
When a device goes offline, PRIMA detects its departure and heals the inference pool automatically.
Use the devices and network you have.
PRIMA has no specific hardware or network requirement. Mix heterogeneous devices across wired LAN, Wi-Fi, or secure cross-LAN connections—including different device types, operating systems, chips, memory, GPUs, and storage.
Prima Lab · Blog
Scalability Matters More Than a Bigger Machine
What PRIMA’s Hy4 preview 770B experiment reveals about the future of scalable local AI.
Read note →The workstation you need may already be in the room.
Why treating existing hardware as one adaptable pool can be more practical than replacing it.
Read note →Inside the PRIMA Hy4 Preview 770B Experiment: How We Ran It Across Two Machines
Two machines in different locations, across separate networks and connected wirelessly, combined 80 GB of VRAM and 64 GB of RAM to run Hy4 preview 770B at 1.5 TPS.
The Hy4 preview 770B case study explains why we combined existing devices and what the experiment revealed about scalable local AI. The procedure below records the two-rank path used on this testbed.
Remark: We recommend using an AI tool to help deploy this preview. We will simplify deployment in future releases and provide one-click deployment and installation tools.
The deployment in one view
The experiment was a two-rank static topology. The four-A4000 machine was rank 0 and exposed the client API. The 4090 Laptop was rank 1 and joined as the second worker.
| Rank | OS · runtime | CPU · RAM | GPU · VRAM | Local model disk | Network · bandwidth | RTT |
|---|---|---|---|---|---|---|
| Rank 0 · head | Ubuntu 24.04 · CUDA 12.x | Intel Core i7-12700 · 32 GB RAM | NVIDIA RTX A4000 × 4 · 16 GB each, 64 GB total | 8 TB NVMe SSD | Wired remote LAN · 1 Gbps up/down | ≈ 50 ms |
| Rank 1 · worker | Ubuntu 22.04 · CUDA 13.x | Intel Core Ultra 9 185H · 32 GB RAM | NVIDIA RTX 4090 Laptop × 1 · 16 GB | 2 TB NVMe SSD | Wi-Fi · VPN · cross-LAN · 27 Mbps up / 145 Mbps down | ≈ 50 ms |
Each machine had 32GB of system memory. The two hosts communicated through direct host-to-host addresses across the existing Wi-Fi, VPN, and remote-LAN path.
1. Prepare one runtime package per rank
The experiment used one hardware-specific runtime package per rank:
| Package | Install on | Role |
|---|---|---|
prima-preview-a4000-rank0-linux-x86_64-cuda-runtime.tar.gz | Four-A4000 server | Rank 0, the head device |
prima-preview-4090-rank1-linux-x86_64-cuda-runtime.tar.gz | 4090 Laptop | Rank 1, the worker device |
The current functional-preview binaries have this exact compatibility matrix:
| Rank | CPU architecture | Validated GPU | Compute capability | Operating system | CUDA ABI |
|---|---|---|---|---|---|
| Rank 0 | x86-64 | NVIDIA RTX A4000 × 4 | SM86 | Ubuntu 24.04 | CUDA 12 ABI |
| Rank 1 | x86-64 | NVIDIA RTX 4090 Laptop × 1 | SM89 | Ubuntu 22.04 | CUDA 13 ABI |
The packages contain compiled ELF executables, shared libraries, and symlinks. They do not contain model files, source code, setup scripts, the NVIDIA driver, CUDA, or cuBLAS. The public Hugging Face prima-runtime directory provides the runtime packages and their matching SHA256SUMS.
set -euo pipefail
mkdir -p hy4-runtime
cd hy4-runtime
for tool in bash tar file ldd sha256sum curl realpath stat install sed ssh jq nvidia-smi ss df free find tee sleep awk grep; do
command -v "$tool" >/dev/null
done
ROLE=a4000-rank0 # use 4090-rank1 on the Laptop
HF_BASE=https://huggingface.co/AngelSlim/Hy4-preview-GGUF/resolve/main/prima-runtime
ARCHIVE="prima-preview-${ROLE}-linux-x86_64-cuda-runtime.tar.gz"
curl -fL --retry 20 -o SHA256SUMS "$HF_BASE/SHA256SUMS?download=true"
curl -fL -C - --retry 20 -o "$ARCHIVE" \
"$HF_BASE/$ARCHIVE?download=true"
Download the archive and SHA256SUMS from that same public directory. Keep the exact archive filename shown above; do not rename it or substitute a checksum manifest from another source.
set -euo pipefail
DOWNLOAD_DIR=/absolute/path/to/hy4-runtime
# Match the exact archive and SHA256SUMS downloaded from Hugging Face above.
ARCHIVE=prima-preview-a4000-rank0-linux-x86_64-cuda-runtime.tar.gz
# On the Laptop use the 4090-rank1 archive name.
cd "$DOWNLOAD_DIR"
sha256sum -c SHA256SUMS --ignore-missing
first_entry=$(tar -tzf "$ARCHIVE" | sed -n '1p')
PACKAGE=${first_entry%%/*}
[[ "$PACKAGE" =~ ^[A-Za-z0-9._-]+$ ]]
[[ ! -e "$PACKAGE" && ! -L "$PACKAGE" ]]
tar -xzf "$ARCHIVE"
cd "$PACKAGE"
elf_count=0
while IFS= read -r -d '' artifact; do
file_type=$(file -b -- "$artifact")
[[ "$file_type" == ELF* ]] || continue
elf_count=$((elf_count + 1))
echo "==> $artifact"
ldd_output=$(env -i PATH=/usr/bin:/bin LANG=C LC_ALL=C ldd "$artifact")
printf '%s\n' "$ldd_output"
if [[ "$ldd_output" == *"not found"* ]]; then
echo "Missing dependency in $artifact" >&2
exit 1
fi
done < <(find . -type f -print0)
(( elf_count > 0 ))
Run the blocks in Bash. SHA256SUMS verifies the small runtime archives only—this procedure deliberately does not hash the model payload. The second block enters the extracted top-level directory, runs ldd on every ELF artifact, and fails on a missing dependency or an archive with no ELF files. Keep each package’s bin/ and lib/ directories together.
2. Put the same model file on both machines
The model artifact referenced here is Hy4-preview-STQ1_0.gguf from the public AngelSlim/Hy4-preview-GGUF repository. It is a mixed 1–2-bit quantization at approximately 2.38 bits per weight.
set -euo pipefail
MODEL_ROOT=/absolute/path/to/model-directory
MODEL="$MODEL_ROOT/Hy4-preview-STQ1_0.gguf"
mkdir -p "$MODEL_ROOT"
df -h "$MODEL_ROOT"
free -h
EXPECTED_BYTES=229412839872
SAFETY_BYTES=$((5 * 1024 * 1024 * 1024))
current_bytes=0
test ! -L "$MODEL"
if [[ -e "$MODEL" ]]; then
test -f "$MODEL"
current_bytes=$(stat -c %s -- "$MODEL")
fi
(( current_bytes <= EXPECTED_BYTES ))
available_bytes=$(df -PB1 -- "$MODEL_ROOT" | awk 'NR == 2 { print $4 }')
(( available_bytes >= EXPECTED_BYTES - current_bytes + SAFETY_BYTES ))
if (( current_bytes < EXPECTED_BYTES )); then
curl -fL -C - --retry 20 -o "$MODEL" \
'https://huggingface.co/AngelSlim/Hy4-preview-GGUF/resolve/main/Hy4-preview-STQ1_0.gguf?download=true'
fi
test -r "$MODEL"
test "$(stat -c %s -- "$MODEL")" -eq "$EXPECTED_BYTES"
The single file is 229,412,839,872 bytes. Put one assumed-complete, fixed copy on fast local storage on each machine. Each wrapper opens the local file on FD 203, and --model reads it through /proc/self/fd/203.
The cross-LAN link carried intermediate activations and control traffic, not a continuous stream of 200GB-plus model weights.
3. Verify and bind the model once on each machine
Use a fresh state directory on each machine. Its directory and every authority input must not be group- or world-accessible: the preview tools reject a topology or receipt with unsafe ownership or mode. The manifest is supplied by this guidance; prima-moe-artifact does not generate it. The SHA-256 string inside the frozen manifest is provenance metadata—none of the commands below hashes the local model payload.
set -euo pipefail
umask 077
RUNTIME=/absolute/path/to/extracted-runtime
STATE=/absolute/path/to/fresh-private-state
MODEL_ROOT=/absolute/path/to/model-directory
MODEL="$MODEL_ROOT/Hy4-preview-STQ1_0.gguf"
[[ "$RUNTIME" = /* && "$STATE" = /* && "$MODEL_ROOT" = /* ]]
test ! -e "$STATE"
mkdir -m 700 "$STATE"
mkdir -m 700 "$STATE/tmp" "$STATE/logs"
mkdir -m 700 "$STATE/logs/prima-log"
cat > "$STATE/hy4-stq1_0-manifest.json" <<'JSON'
{
"schema": "prima.moe.artifact-manifest.v1",
"repository": "AngelSlim/Hy4-preview-GGUF",
"revision": "7f10d3724b61b2e1d6e9207a0bd961768b7b30a1",
"adapter": "hyv4-preview-stq1-0-v1",
"variant": "Hy4-preview-STQ1_0",
"shard_count": 1,
"total_bytes": 229412839872,
"shards": [
{
"ordinal": "00001",
"basename": "Hy4-preview-STQ1_0.gguf",
"size_bytes": 229412839872,
"sha256": "4d1d2259446e33e25c3e1d8bcb072f026cc69b90a361c5e5a8f6eca50d8d0036"
}
]
}
JSON
chmod 600 "$STATE/hy4-stq1_0-manifest.json"
Then run create-v1 once per machine, changing RANK to rank1 on the Laptop. It checks the bounded GGUF metadata, expected basename and size, and model-root identity before writing a machine-local .prar receipt. In the reproduced run it reported metadata_bytes_read=5051512 and tensor_payload_bytes_read=0: it does not read or hash the tensor payload and is not a corruption check.
set -euo pipefail
umask 077
RUNTIME=/absolute/path/to/extracted-runtime
STATE=/absolute/path/to/fresh-private-state
MODEL_ROOT=/absolute/path/to/model-directory
MODEL="$MODEL_ROOT/Hy4-preview-STQ1_0.gguf"
RANK=rank0
test -r "$MODEL"
test "$(stat -c %s -- "$MODEL")" -eq 229412839872
RECEIPT="$STATE/${RANK}-receipt.prar"
[[ ! -e "$RECEIPT" && ! -L "$RECEIPT" ]]
"$RUNTIME/bin/prima-moe-artifact" create-v1 \
--adapter-id hyv4-preview-stq1-0-v1 \
--repository AngelSlim/Hy4-preview-GGUF \
--revision 7f10d3724b61b2e1d6e9207a0bd961768b7b30a1 \
--manifest "$STATE/hy4-stq1_0-manifest.json" \
--model-root "$MODEL_ROOT" \
--output "$RECEIPT"
chmod 600 "$RECEIPT"
The model is assumed complete and fixed. If it is moved or replaced, create a fresh private state directory and new receipt rather than reusing the old binding.
The command options have the following roles:
create-v1reads the supplied manifest and creates a version-1, machine-local artifact receipt; it does not create the manifest;--adapter-idselects PRIMA’s model-specific STQ1_0 adapter;--repositoryand--revisionpin the model’s source and immutable repository revision;--manifestpoints to the fixed local JSON containing the declared filename, byte size, and artifact provenance; it does not request a local payload hash;--model-rootpoints to the local directory containing the GGUF;--outputwrites the receipt that this machine passes toprima-serverat startup.
Generate the receipt once on each machine and reuse it only while the model file and its absolute local path remain unchanged. Authority paths must be canonical absolute paths with no symlink component; every input must be owned by the effective user, be a regular file with link count one and exact mode 0600; the output parent must be owned by that user with exact mode 0700. chmod alone cannot repair a wrong owner, hard link, or symlink.
4. Probe the GPUs once on both ranks
Each rank captured its own local GPU topology. The A4000 process exposed 4 CUDA devices; the laptop exposed one.
set -euo pipefail
umask 077
RUNTIME=/absolute/path/to/extracted-runtime
STATE=/absolute/path/to/fresh-private-state
nvidia-smi
RANK=rank0 # set rank1 on the 4090 Laptop
case "$RANK" in
rank0) VISIBLE=0,1,2,3; DEVICE_GROUP=CUDA0,CUDA1,CUDA2,CUDA3 ;;
rank1) VISIBLE=0; DEVICE_GROUP=CUDA0 ;;
*) echo "RANK must be rank0 or rank1" >&2; exit 2 ;;
esac
TOPOLOGY="$STATE/${RANK}-topology.bin"
[[ ! -e "$TOPOLOGY" && ! -L "$TOPOLOGY" ]]
env -i \
PATH=/usr/bin:/bin LANG=C LC_ALL=C \
CUDA_DEVICE_ORDER=PCI_BUS_ID CUDA_VISIBLE_DEVICES="$VISIBLE" \
"$RUNTIME/bin/prima-server" --moe-device-group "$DEVICE_GROUP" \
--moe-topology-probe > "$TOPOLOGY"
chmod 600 "$TOPOLOGY"
Inspect nvidia-smi before every probe or launch and do not disturb unrelated processes. The clean env -i probe deliberately matches the launch’s PCI-bus CUDA ordering and leaves GGML_CUDA_P2P unset; either setting can change the topology digest and make manual startup reject the plan. A plain redirection under the common 022 umask creates mode 0644, which the authority checks also reject. Keep each topology, receipt, plan, profile-cache path, and their parent state directory private.
5. Generate the hybrid two-rank placement plan
This testbed combined two levels of parallelism. Across the approximately 50 ms cross-LAN link, the two ranks used layer/pipeline partitioning. Inside the four-A4000 rank, PRIMA used local expert parallelism for routed MoE work. The manual plan establishes the inter-rank cut and assigns each layer’s resident main-graph tensors, shared-expert weights, state, and KV cache to a reference GPU. Routed-expert banks are managed separately by the tiered MoE runtime.
For this preview, the reference placement was selected explicitly and then validated and materialized with prima-moe-plan. Copy rank 1’s receipt and topology file to rank 0 over an authenticated channel, place them inside rank 0’s private STATE, and force mode 0600. Use absolute paths and a fresh, absent output path:
set -euo pipefail
umask 077
RUNTIME=/absolute/path/to/extracted-runtime
STATE=/absolute/path/to/fresh-private-state
TRANSFER=/absolute/private/path/to/received-rank1-files
[[ ! -e "$STATE/rank1-receipt.prar" && ! -L "$STATE/rank1-receipt.prar" ]]
[[ ! -e "$STATE/rank1-topology.bin" && ! -L "$STATE/rank1-topology.bin" ]]
install -m 600 "$TRANSFER/rank1-receipt.prar" "$STATE/rank1-receipt.prar"
install -m 600 "$TRANSFER/rank1-topology.bin" "$STATE/rank1-topology.bin"
[[ "$(realpath -e -- "$STATE")" == "$STATE" ]]
[[ "$(stat -c %u -- "$STATE")" -eq "$EUID" ]]
[[ "$(stat -c %a -- "$STATE")" == 700 ]]
for input in "$STATE"/rank{0,1}-{receipt.prar,topology.bin}; do
[[ -f "$input" && ! -L "$input" ]]
[[ "$(realpath -e -- "$input")" == "$input" ]]
[[ "$(stat -c %u -- "$input")" -eq "$EUID" ]]
[[ "$(stat -c %a -- "$input")" == 600 ]]
[[ "$(stat -c %h -- "$input")" -eq 1 ]]
done
PLAN="$STATE/hy4-two-rank-plan.prmp"
[[ ! -e "$PLAN" && ! -L "$PLAN" ]]
"$RUNTIME/bin/prima-moe-plan" create-v1 \
--adapter hyv4-preview-stq1-0-v1 \
--rank0-receipt "$STATE/rank0-receipt.prar" \
--rank1-receipt "$STATE/rank1-receipt.prar" \
--rank0-topology "$STATE/rank0-topology.bin" \
--rank1-topology "$STATE/rank1-topology.bin" \
--cut 61 \
--rank0-device-layers 15,15,15,16 \
--rank1-device-layers 17 \
--output "$PLAN"
chmod 600 "$PLAN"
--cut 61 assigns model layers 0–60 to rank 0 and layers 61–77 to rank 1. The per-device counts are contiguous base layer placement and expand as follows:
| Rank | GPU | Plan count | Reference layer range |
|---|---|---|---|
| Rank 0 | CUDA0 · A4000 | 15 | 0–14 |
| Rank 0 | CUDA1 · A4000 | 15 | 15–29 |
| Rank 0 | CUDA2 · A4000 | 15 | 30–44 |
| Rank 0 | CUDA3 · A4000 | 16 | 45–60 |
| Rank 1 | CUDA0 · 4090 Laptop | 17 | 61–77 |
This table is layer placement, not expert parallelism. For each contiguous range, the listed GPU owns the resident main graph—including attention, routing, and normalization tensors—the shared-expert weights, and that layer’s state and KV cache. The counts do not divide the routed-expert bank among GPUs.
Expert parallelism is a second, intra-rank step that applies only to routed experts. For routed MoE layers 1–60 on rank 0, accepted hot-expert weights are striped across all four A4000 GPUs using (reference owner + expert ID mod 4) mod 4. For example, if CUDA1 is the reference owner, expert IDs 0, 4, … prefer CUDA1; 1, 5, … prefer CUDA2; 2, 6, … prefer CUDA3; and 3, 7, … prefer CUDA0, subject to hot-cache capacity. Independent GPU expert branches are submitted together, overlap with the local CPU cold-expert branch backed by host memory and SSD, and are then reduced in a stable order.
Rank 1 has one GPU, so it has no intra-rank multi-GPU expert fan-out. PRIMA does not fan experts across the two machines: doing so would introduce expert communication at every routed layer over the high-RTT cross-LAN path.
The tool does not search for the fastest placement. It verifies that the two receipts refer to the same model artifact and adapter, checks both captured GPU topologies, validates the selected cut and layer counts, and writes a binary plan. These values describe this testbed and should not be copied to different hardware without a new placement decision. Transfer the generated plan without modifying it; on rank 1, receive it outside STATE, require the destination to be absent, then run install -m 600 /absolute/path/to/received-plan "$STATE/hy4-two-rank-plan.prmp". Both ranks pass their private local copy through --moe-manual-plan.
6. Start rank 0 and rank 1
The two processes connect with a data port and a signal port on each rank. The tested path uses an SSH tunnel because direct reverse reachability was unavailable. Start the tunnel, then rank 1 with --worker-ready-listener, and finally rank 0 as --head --world 2.
| Order | Rank | Own data / signal / echo ports | --next |
|---|---|---|---|
| 1 | Rank 1 · 4090 | 19541 / 20571 / 20771 | 127.0.0.1:19542:20572 (local forwards) |
| 2 | Rank 0 · A4000 | 19540 / 20570 / 20770 | 127.0.0.1:19543:20573 (reverse forwards) |
Secure the ports before starting anything. In this preview, the Ring data/signal and diagnostic echo listeners bind wildcard interfaces, and the reproduced rank 0 HTTP listener appeared on 0.0.0.0:18331 even with --host 127.0.0.1. These listeners have no TLS or client authentication. Use site-specific firewall and routing rules to deny untrusted ingress to 18331, 18332, 19540, 19541, 20570, 20571, 20770, and 20771 while preserving required loopback traffic. Inspect ss -ltnp on both hosts before launch to confirm all declared and forwarded ports are free. Do not paste generic firewall commands that could cut off SSH.
Before first use, verify the A4000 host-key fingerprint through a separate trusted channel and record it in known_hosts; do not blindly accept a TOFU prompt. In Terminal A on the Laptop, keep this tunnel in the foreground. Replace both the SSH username and A4000_HOST; non-interactive public-key authentication, strict known-host checking, and both local and remote TCP forwarding must be allowed (and not blocked by PermitOpen/PermitListen). ExitOnForwardFailure confirms that the six forwarding listeners bound successfully, not that the still-unstarted Prima endpoints are ready.
set -euo pipefail
SSH_TARGET=ubuntu@A4000_HOST # replace username and host
ssh -N -T -S none \
-o BatchMode=yes \
-o PasswordAuthentication=no \
-o KbdInteractiveAuthentication=no \
-o ControlMaster=no \
-o ControlPath=none \
-o ExitOnForwardFailure=yes \
-o ServerAliveInterval=15 \
-o ServerAliveCountMax=3 \
-o ConnectTimeout=15 \
-o ForwardAgent=no \
-o NumberOfPasswordPrompts=0 \
-o StrictHostKeyChecking=yes \
-L 127.0.0.1:19542:127.0.0.1:19540 \
-L 127.0.0.1:20572:127.0.0.1:20570 \
-L 127.0.0.1:20770:127.0.0.1:20770 \
-R 127.0.0.1:19543:127.0.0.1:19541 \
-R 127.0.0.1:20573:127.0.0.1:20571 \
-R 127.0.0.1:20771:127.0.0.1:20771 \
"$SSH_TARGET"
The four data/signal forwards are the reproduced functional path. The two additional echo forwards follow the runtime's signal_port + 200 scheme and allow best-effort outbound-hop telemetry; they do not affect the fixed scheduler hop price.
Save the following common launch settings as $STATE/hy4-common.sh on both machines. These opt-in gates are part of the reproduced STQ runtime—not optional tuning suggestions.
set -euo pipefail
umask 077
STATE=/absolute/path/to/fresh-private-state
cat > "$STATE/hy4-common.sh" <<'BASH'
COMMON_ENV=(
PATH=/usr/bin:/bin LANG=C LC_ALL=C
CUDA_CACHE_DISABLE=1 CUDA_DEVICE_ORDER=PCI_BUS_ID CUDA_LAUNCH_BLOCKING=0
GGML_CUDA_DISABLE_GRAPHS=1
LLAMA_MOE_CPU_CUDA_NUMERIC_COMPAT_V1=1
PRIMA_ACTIVATION_WIRE_DTYPE=fp32
PRIMA_MOE_BACKGROUND_STAGING_V1=1
PRIMA_MOE_BG_PROMOTION_V1=1
PRIMA_MOE_COPY_STREAM_READY_SYNC_V1=1
PRIMA_MOE_COPY_STREAM_V1=1
PRIMA_MOE_DECODE_TIMING_V1=1
PRIMA_MOE_DRAIN_PROMOTION_COPIES_WITHIN_ALLOWANCE_V1=1
PRIMA_MOE_HOTCACHE_POLICY_V1=recent
PRIMA_MOE_PRECISE_PREFETCH_V1=1
PRIMA_MOE_PUBLISH_READY_BEFORE_DECODE_V1=1
PRIMA_MOE_REQUEST_PLANNER_V1=1
PRIMA_MOE_ROUTE_PAGECACHE_POPULATE_V1=1
PRIMA_MOE_ROUTE_PAGE_PREFETCH_V1=1
PRIMA_MOE_STARTUP_COLD_PREFETCH_MAX_BYTES_V1=8589934592
PRIMA_MOE_STARTUP_COLD_PREFETCH_V1=1
)
COMMON_ARGS=(
--model /proc/self/fd/203 --load-mode mmap --log-profile production
--topology static --world-timeout 7200
--ctx-size 8192 --batch-size 2 --ubatch-size 1 --parallel 1
--n-predict 60 --threads 8 --threads-batch 8
--moe-hybrid manual
--moe-provider tiered-local-cold-hot-v1
--moe-model-adapter hyv4-preview-stq1-0-v1
--moe-routing-policy local-cold-no-remote-v1
--moe-min-request-hits 2 --moe-ttft-guard-percent 3
--moe-artifact-receipt /proc/self/fd/200
--moe-manual-plan /proc/self/fd/201
--jinja --no-context-shift --no-warmup --no-repack
--no-cache-prompt --cache-reuse 0 --no-slots --no-webui
--seed 0 --temp 0 --top-k 1 --top-p 1 --min-p 0
--repeat-penalty 1 --ignore-eos
)
BASH
chmod 600 "$STATE/hy4-common.sh"
In Terminal B on the 4090 Laptop, start rank 1 in the foreground. The retained run had 15,930 MiB GPU memory free and 22.66 GB MemAvailable before launch; the block aborts below conservative reproduced-environment gates of 15,800 MiB and 22.0 GB. The wrapper pins the local receipt, plan, and model to file descriptors 200, 201, and 203. A normal plan pathname is not accepted by the current manual-mode contract.
set -euo pipefail
umask 077
RUNTIME=/absolute/path/to/extracted-runtime
STATE=/absolute/path/to/fresh-private-state
MODEL=/absolute/path/to/Hy4-preview-STQ1_0.gguf
source "$STATE/hy4-common.sh"
nvidia-smi
mem_available_bytes=$(awk '/^MemAvailable:/ { printf "%.0f\n", $2 * 1024 }' /proc/meminfo)
gpu_free_mib=$(nvidia-smi --query-gpu=memory.free --format=csv,noheader,nounits)
(( mem_available_bytes >= 22000000000 ))
[[ "$gpu_free_mib" =~ ^[0-9]+$ ]]
(( gpu_free_mib >= 15800 ))
(
exec 200<"$STATE/rank1-receipt.prar"
exec 201<"$STATE/hy4-two-rank-plan.prmp"
exec 203<"$MODEL"
exec env -i \
"${COMMON_ENV[@]}" \
TMPDIR="$STATE/tmp" \
PRIMA_LOG_ROOT="$STATE/logs/prima-log" \
CUDA_VISIBLE_DEVICES=0 \
"$RUNTIME/bin/prima-server" \
"${COMMON_ARGS[@]}" \
--moe-profile-cache "$STATE/rank1-profile-cache.bin" \
--next 127.0.0.1:19542:20572 \
--data-port 19541 --signal-port 20571 \
--worker-ready-listener \
--host 127.0.0.1 --port 18332 \
--device CUDA0 --split-mode layer --moe-device-group CUDA0
) 2>&1 | tee "$STATE/logs/rank1.log"
Keep Terminal B alive. In another Laptop terminal, confirm that the rank 1 process is still running and that ss -ltnp shows its data listener on 19541; then immediately start rank 0 in Terminal C on the four-A4000 server. Do not wait for rank 1 signal port 20571, HTTP port 18332, or prima-server: service ready yet: the signal listener and ready marker appear only after rank 0 joins and the static world advances through its barriers.
The retained A4000 launch had 14,966 MiB free on each of four cards and 27.91 GB MemAvailable. The rank 0 block requires exactly four visible devices, at least 14,900 MiB free on each, and at least 27.0 GB available host memory. These gates reproduce the measured admission envelope; they are not universal hardware minima.
set -euo pipefail
umask 077
RUNTIME=/absolute/path/to/extracted-runtime
STATE=/absolute/path/to/fresh-private-state
MODEL=/absolute/path/to/Hy4-preview-STQ1_0.gguf
source "$STATE/hy4-common.sh"
nvidia-smi
mem_available_bytes=$(awk '/^MemAvailable:/ { printf "%.0f\n", $2 * 1024 }' /proc/meminfo)
mapfile -t gpu_free_mib < <(nvidia-smi --query-gpu=memory.free --format=csv,noheader,nounits)
(( mem_available_bytes >= 27000000000 ))
(( ${#gpu_free_mib[@]} == 4 ))
for free_mib in "${gpu_free_mib[@]}"; do
[[ "$free_mib" =~ ^[0-9]+$ ]]
(( free_mib >= 14900 ))
done
(
exec 200<"$STATE/rank0-receipt.prar"
exec 201<"$STATE/hy4-two-rank-plan.prmp"
exec 203<"$MODEL"
exec env -i \
"${COMMON_ENV[@]}" \
TMPDIR="$STATE/tmp" \
PRIMA_LOG_ROOT="$STATE/logs/prima-log" \
CUDA_VISIBLE_DEVICES=0,1,2,3 \
"$RUNTIME/bin/prima-server" \
"${COMMON_ARGS[@]}" \
--moe-profile-cache "$STATE/rank0-profile-cache.bin" \
--head --world 2 \
--next 127.0.0.1:19543:20573 \
--data-port 19540 --signal-port 20570 \
--host 127.0.0.1 --port 18331 \
--device CUDA0 --split-mode layer \
--moe-device-group CUDA0,CUDA1,CUDA2,CUDA3
) 2>&1 | tee "$STATE/logs/rank0.log"
After both processes are running, confirm the 20570/20571 signal listeners and wait for the exact prima-server: service ready marker in both rank logs. If either foreground command exits, stop and diagnose instead of continuing to poll. Only rank 0 serves clients. On the A4000 host, poll /health to HTTP 200 with a bounded per-attempt timeout and an overall deadline, then make a fixed-sampler chat request with its own finite timeout. Hy4 may spend the first tokens reasoning, so inspect both content and reasoning_content; a very small token budget can legitimately leave content empty.
set -euo pipefail
umask 077
STATE=/absolute/path/to/fresh-private-state
deadline=$((SECONDS + 7200))
until curl -fsS --connect-timeout 2 --max-time 5 \
-o "$STATE/health.json" http://127.0.0.1:18331/health; do
(( SECONDS < deadline )) || { echo "health deadline exceeded" >&2; exit 1; }
sleep 5
done
RESPONSE="$STATE/smoke-chat-response.json"
curl -fsS --connect-timeout 5 --max-time 900 \
-o "$RESPONSE" http://127.0.0.1:18331/v1/chat/completions \
-H 'Content-Type: application/json' \
-d '{
"model": "hy4-preview-stq1_0",
"messages": [{"role": "user", "content": "Reply with one short sentence: why does local expert caching help sparse MoE inference?"}],
"max_tokens": 64,
"temperature": 0,
"top_k": 1,
"top_p": 1,
"min_p": 0,
"repeat_penalty": 1,
"seed": 0,
"stream": false
}'
jq -e '((((.choices[0].message.content // "") | length) > 0) or
(((.choices[0].message.reasoning_content // "") | length) > 0))' \
"$RESPONSE" >/dev/null
jq '.choices[0].message | {content, reasoning_content}' "$RESPONSE"
Immediately after launch, re-run ss -ltnp and verify that the observed wildcard data, signal, echo, and HTTP listeners—including 20770/20771—are protected by the preconfigured ingress policy. Neither --host 127.0.0.1 nor the SSH loopback forwards constrain Prima’s own wildcard binds.
7. The settings that shaped the run
The essential settings were:
/proc/self/fd/200,/proc/self/fd/201, and/proc/self/fd/203: consume the receipt, manual plan, and model through the descriptors pinned by the wrapper, rather than reopening mutable pathnames inside the server;--topology static,--world-timeout 7200, and--moe-hybrid manual: satisfy the current STQ startup contract by selecting the declared static two-rank topology, allowing up to 7,200 seconds for rank coordination and cold startup, and requiring the supplied manual hybrid-MoE plan;--moe-provider tiered-local-cold-hot-v1: keep hot expert data on GPU while using host memory and local SSD for colder data;--moe-routing-policy local-cold-no-remote-v1: read a rank’s cold weights locally instead of fetching them from the other machine;--moe-manual-plan /proc/self/fd/201: load the same validated plan on both ranks through required FD 201; a normal filesystem path is rejected by the current manual-mode contract;--load-mode mmap: map the 229 GB model and allow colder pages to be served from each rank’s local storage;--split-mode layer: place resident main-graph and shared-expert layer data according to the plan; routed hot experts still use rank 0’s local expert parallelism;--moe-device-group: declare the ordered local GPU group available to each rank;--ctx-size 8192 --batch-size 2 --ubatch-size 1 --parallel 1: run one request at a time with the measured 8K-context batch configuration;--no-warmup --no-repack: skip automatic warmup and weight repacking for this recorded path;--jinja: apply the model’s Jinja chat template so/v1/chat/completionshas reliable chat semantics.
The common wrapper also fixes PCI-bus GPU ordering, disables CUDA graphs, enables the measured CPU–CUDA numeric-compatibility path, and sends inter-rank activations as FP32. The PRIMA_MOE_* variables shown in the common block explicitly enable the reproduced request planner, hot-cache policy, cold prefetch, page-cache population, background staging and promotion, and asynchronous copy synchronization. Omitting them is a different, unverified configuration.
We replay the measured generation in the Playground. The Playground does not connect to live devices or start a live inference run; it replays the fixed input, output, and per-token timing captured from a real offline inference run.
1 This guidance is a functional preview limited to the exact x86-64, GPU/SM, Ubuntu, and CUDA ABI combinations in the compatibility matrix above. Macs are not yet supported. Future releases will simplify deployment, support automatic plan generation, and add support for both Mac clusters and mixed Mac–Linux clusters.
2 Executable binary packages: public AngelSlim/Hy4-preview-GGUF/prima-runtime.
解密 PRIMA:如何在两台异构设备上运行 Hy4 Preview 770B
两台设备,异地、跨网、无线连接,总计仅 80GB 显存和 64GB 系统内存,用 PRIMA 将 Hy4 Preview 770B 提速到 1.5 TPS。
Hy4 preview 770B 案例研究解释了我们为何组合已有设备,以及这次实验揭示了可扩展本地 AI 的哪些可能。下面的流程记录了这套测试环境所使用的双 rank 运行路径。
备注:我们建议使用 AI 工具来辅助部署这个预览版本。我们将在后续版本中简化部署,并提供一键式部署和安装工具。
部署结构一览
实验采用双 rank 静态拓扑。四卡 A4000 机器作为 rank 0,对外提供客户端 API;4090 Laptop 作为 rank 1,以第二个工作进程的身份加入。
| Rank | 操作系统 · 运行时 | CPU · 系统内存 | GPU · 显存 | 本地模型磁盘 | 网络 · 带宽 | RTT |
|---|---|---|---|---|---|---|
| Rank 0 · 主进程 | Ubuntu 24.04 · CUDA 12.x | Intel Core i7-12700 · 32 GB RAM | NVIDIA RTX A4000 × 4 · 每张 16 GB,共 64 GB | 8 TB NVMe SSD | 有线远端局域网 · 上下行 1 Gbps | ≈ 50 ms |
| Rank 1 · 工作进程 | Ubuntu 22.04 · CUDA 13.x | Intel Core Ultra 9 185H · 32 GB RAM | NVIDIA RTX 4090 Laptop × 1 · 16 GB | 2 TB NVMe SSD | Wi-Fi · VPN · 跨局域网 · 上行 27 Mbps / 下行 145 Mbps | ≈ 50 ms |
每台机器均配备 32GB 系统内存。两台主机通过现有 Wi-Fi、VPN 和远端局域网路径中的主机直连地址通信。
1. 为每个 rank 准备一个运行时软件包
实验为每个 rank 使用一个针对其硬件的软件包:
| 软件包 | 安装位置 | 用途 |
|---|---|---|
prima-preview-a4000-rank0-linux-x86_64-cuda-runtime.tar.gz | 四卡 A4000 服务器 | Rank 0,主设备 |
prima-preview-4090-rank1-linux-x86_64-cuda-runtime.tar.gz | 4090 Laptop | Rank 1,工作设备 |
当前功能预览二进制文件仅对应下面这份精确兼容矩阵:
| Rank | CPU 架构 | 已验证 GPU | 计算能力 | 操作系统 | CUDA ABI |
|---|---|---|---|---|---|
| Rank 0 | x86-64 | NVIDIA RTX A4000 × 4 | SM86 | Ubuntu 24.04 | CUDA 12 ABI |
| Rank 1 | x86-64 | NVIDIA RTX 4090 Laptop × 1 | SM89 | Ubuntu 22.04 | CUDA 13 ABI |
软件包包含已编译的 ELF 可执行文件、共享库和符号链接,不包含模型文件、源代码、安装脚本、NVIDIA 驱动、CUDA 或 cuBLAS。公开的 Hugging Face prima-runtime 目录提供运行时软件包及其对应的 SHA256SUMS。
set -euo pipefail
mkdir -p hy4-runtime
cd hy4-runtime
for tool in bash tar file ldd sha256sum curl realpath stat install sed ssh jq nvidia-smi ss df free find tee sleep awk grep; do
command -v "$tool" >/dev/null
done
ROLE=a4000-rank0 # 在 Laptop 上使用 4090-rank1
HF_BASE=https://huggingface.co/AngelSlim/Hy4-preview-GGUF/resolve/main/prima-runtime
ARCHIVE="prima-preview-${ROLE}-linux-x86_64-cuda-runtime.tar.gz"
curl -fL --retry 20 -o SHA256SUMS "$HF_BASE/SHA256SUMS?download=true"
curl -fL -C - --retry 20 -o "$ARCHIVE" \
"$HF_BASE/$ARCHIVE?download=true"
压缩包与 SHA256SUMS 必须从同一个公开目录下载。保留上方显示的精确压缩包文件名;不要重命名,也不要替换为其他来源的 checksum manifest。
set -euo pipefail
DOWNLOAD_DIR=/absolute/path/to/hy4-runtime
# 与上一个代码块从 Hugging Face 下载的精确文件名和 SHA256SUMS 保持一致。
ARCHIVE=prima-preview-a4000-rank0-linux-x86_64-cuda-runtime.tar.gz
# Laptop 使用 4090-rank1 压缩包文件名。
cd "$DOWNLOAD_DIR"
sha256sum -c SHA256SUMS --ignore-missing
first_entry=$(tar -tzf "$ARCHIVE" | sed -n '1p')
PACKAGE=${first_entry%%/*}
[[ "$PACKAGE" =~ ^[A-Za-z0-9._-]+$ ]]
[[ ! -e "$PACKAGE" && ! -L "$PACKAGE" ]]
tar -xzf "$ARCHIVE"
cd "$PACKAGE"
elf_count=0
while IFS= read -r -d '' artifact; do
file_type=$(file -b -- "$artifact")
[[ "$file_type" == ELF* ]] || continue
elf_count=$((elf_count + 1))
echo "==> $artifact"
ldd_output=$(env -i PATH=/usr/bin:/bin LANG=C LC_ALL=C ldd "$artifact")
printf '%s\n' "$ldd_output"
if [[ "$ldd_output" == *"not found"* ]]; then
echo "Missing dependency in $artifact" >&2
exit 1
fi
done < <(find . -type f -print0)
(( elf_count > 0 ))
请在 Bash 中运行这些命令。SHA256SUMS 只校验较小的运行时压缩包;本流程明确不对模型 payload 做哈希。第二段命令进入解压目录,对每个 ELF 制品执行 ldd,遇到依赖缺失或包内没有 ELF 文件就失败。软件包中的 bin/ 和 lib/ 必须保持在一起。
2. 在两台机器上放置同一模型文件
本文使用的模型制品是公开 AngelSlim/Hy4-preview-GGUF 仓库中的 Hy4-preview-STQ1_0.gguf。这是 1–2 bit 混合量化,平均每个权重约 2.38 bit。
set -euo pipefail
MODEL_ROOT=/absolute/path/to/model-directory
MODEL="$MODEL_ROOT/Hy4-preview-STQ1_0.gguf"
mkdir -p "$MODEL_ROOT"
df -h "$MODEL_ROOT"
free -h
EXPECTED_BYTES=229412839872
SAFETY_BYTES=$((5 * 1024 * 1024 * 1024))
current_bytes=0
test ! -L "$MODEL"
if [[ -e "$MODEL" ]]; then
test -f "$MODEL"
current_bytes=$(stat -c %s -- "$MODEL")
fi
(( current_bytes <= EXPECTED_BYTES ))
available_bytes=$(df -PB1 -- "$MODEL_ROOT" | awk 'NR == 2 { print $4 }')
(( available_bytes >= EXPECTED_BYTES - current_bytes + SAFETY_BYTES ))
if (( current_bytes < EXPECTED_BYTES )); then
curl -fL -C - --retry 20 -o "$MODEL" \
'https://huggingface.co/AngelSlim/Hy4-preview-GGUF/resolve/main/Hy4-preview-STQ1_0.gguf?download=true'
fi
test -r "$MODEL"
test "$(stat -c %s -- "$MODEL")" -eq "$EXPECTED_BYTES"
该单文件精确大小为 229,412,839,872 字节。两台机器的高速本地存储上各放置一份假定完整且固定的副本。每个 wrapper 在 FD 203 上打开本地文件,--model 再通过 /proc/self/fd/203 读取。
跨局域网链路传输的是中间激活和控制流量,而不是持续传输超过 200 GB 的模型权重。
3. 在每台机器上校验并绑定一次模型
先在每台机器上使用全新的私有 state 目录。目录以及每个 authority 输入都不能允许 group 或 world 访问,否则预览工具会拒绝不安全的 topology 或 receipt。Manifest 由本指南提供,prima-moe-artifact 不会生成它。Frozen manifest 内的 SHA-256 字符串属于制品来源元数据;下方命令都不会计算本地模型 payload 的哈希。
set -euo pipefail
umask 077
RUNTIME=/absolute/path/to/extracted-runtime
STATE=/absolute/path/to/fresh-private-state
MODEL_ROOT=/absolute/path/to/model-directory
MODEL="$MODEL_ROOT/Hy4-preview-STQ1_0.gguf"
[[ "$RUNTIME" = /* && "$STATE" = /* && "$MODEL_ROOT" = /* ]]
test ! -e "$STATE"
mkdir -m 700 "$STATE"
mkdir -m 700 "$STATE/tmp" "$STATE/logs"
mkdir -m 700 "$STATE/logs/prima-log"
cat > "$STATE/hy4-stq1_0-manifest.json" <<'JSON'
{
"schema": "prima.moe.artifact-manifest.v1",
"repository": "AngelSlim/Hy4-preview-GGUF",
"revision": "7f10d3724b61b2e1d6e9207a0bd961768b7b30a1",
"adapter": "hyv4-preview-stq1-0-v1",
"variant": "Hy4-preview-STQ1_0",
"shard_count": 1,
"total_bytes": 229412839872,
"shards": [
{
"ordinal": "00001",
"basename": "Hy4-preview-STQ1_0.gguf",
"size_bytes": 229412839872,
"sha256": "4d1d2259446e33e25c3e1d8bcb072f026cc69b90a361c5e5a8f6eca50d8d0036"
}
]
}
JSON
chmod 600 "$STATE/hy4-stq1_0-manifest.json"
然后每台机器各运行一次 create-v1;Laptop 上把 RANK 改成 rank1。工具检查有界 GGUF 元数据、预期文件名与大小,以及 model-root 身份,再写出机器本地的 .prar receipt。本次复现中它报告 metadata_bytes_read=5051512、tensor_payload_bytes_read=0:它不会读取或哈希 tensor payload,也不是文件损坏检查。
set -euo pipefail
umask 077
RUNTIME=/absolute/path/to/extracted-runtime
STATE=/absolute/path/to/fresh-private-state
MODEL_ROOT=/absolute/path/to/model-directory
MODEL="$MODEL_ROOT/Hy4-preview-STQ1_0.gguf"
RANK=rank0
test -r "$MODEL"
test "$(stat -c %s -- "$MODEL")" -eq 229412839872
RECEIPT="$STATE/${RANK}-receipt.prar"
[[ ! -e "$RECEIPT" && ! -L "$RECEIPT" ]]
"$RUNTIME/bin/prima-moe-artifact" create-v1 \
--adapter-id hyv4-preview-stq1-0-v1 \
--repository AngelSlim/Hy4-preview-GGUF \
--revision 7f10d3724b61b2e1d6e9207a0bd961768b7b30a1 \
--manifest "$STATE/hy4-stq1_0-manifest.json" \
--model-root "$MODEL_ROOT" \
--output "$RECEIPT"
chmod 600 "$RECEIPT"
这里假设模型完整且固定。移动或替换模型后,应创建新的私有 state 目录与 receipt,不要继续使用旧绑定。
各命令选项的作用如下:
create-v1读取给定的 manifest,并创建版本 1 的机器本地制品凭据;它不会创建 manifest;--adapter-id选择 PRIMA 针对该模型的 STQ1_0 适配器;--repository和--revision固定模型来源及不可变的仓库修订版本;--manifest指向本地固定内容的 JSON,其中包含声明的文件名、字节大小和制品来源元数据;它不会要求对本地 payload 做哈希;--model-root指向包含 GGUF 的本地目录;--output写出本机在启动时传给prima-server的凭据。
每台机器只需生成一次凭据;仅当模型文件及其绝对本地路径保持不变时才可复用。Authority path 必须是无 symlink component 的 canonical absolute path;每个输入都必须由 effective user 拥有、是 link count 为 1 且 mode 精确为 0600 的 regular file;输出父目录必须由该用户拥有且 mode 精确为 0700。仅执行 chmod 无法修复错误 owner、hard link 或 symlink。
4. 探测两个 rank 的 GPU
每个 rank 分别采集本机 GPU 拓扑。A4000 进程暴露四个 CUDA 设备,Laptop 暴露一个。
set -euo pipefail
umask 077
RUNTIME=/absolute/path/to/extracted-runtime
STATE=/absolute/path/to/fresh-private-state
nvidia-smi
RANK=rank0 # 在 4090 Laptop 上设为 rank1
case "$RANK" in
rank0) VISIBLE=0,1,2,3; DEVICE_GROUP=CUDA0,CUDA1,CUDA2,CUDA3 ;;
rank1) VISIBLE=0; DEVICE_GROUP=CUDA0 ;;
*) echo "RANK must be rank0 or rank1" >&2; exit 2 ;;
esac
TOPOLOGY="$STATE/${RANK}-topology.bin"
[[ ! -e "$TOPOLOGY" && ! -L "$TOPOLOGY" ]]
env -i \
PATH=/usr/bin:/bin LANG=C LC_ALL=C \
CUDA_DEVICE_ORDER=PCI_BUS_ID CUDA_VISIBLE_DEVICES="$VISIBLE" \
"$RUNTIME/bin/prima-server" --moe-device-group "$DEVICE_GROUP" \
--moe-topology-probe > "$TOPOLOGY"
chmod 600 "$TOPOLOGY"
每次 probe 或启动前都先检查 nvidia-smi,不得干扰无关进程。干净的 env -i probe 会与正式启动保持相同的 PCI-bus CUDA 顺序,并让 GGML_CUDA_P2P 保持未设置;任一项不同都可能改变 topology digest,导致 manual startup 拒绝 plan。常见的 022 umask 配合普通重定向还会生成 0644 文件,authority 检查同样会拒绝。Topology、receipt、plan、profile-cache 路径及父 state 目录都应保持私有。
5. 生成混合并行的双 rank 放置计划
这个测试床组合了两个层级的并行机制:两台机器之间经过 RTT 约 50 ms 的跨 LAN 链路,采用按层切分和流水线并行;四卡 A4000 rank 内部则对路由 MoE 计算使用本地专家并行。人工 plan 定义跨 rank 切分点,并把每层常驻的 main-graph tensors、shared-expert weights、state 和 KV cache 分给一张参考 GPU;routed-expert banks 则由分层 MoE runtime 单独管理。
在这个预览版本中,参考放置由人工明确选择,再由 prima-moe-plan 校验并生成二进制计划。通过认证通道把 rank 1 的 receipt 和 topology 复制到 rank 0,放入 rank 0 的私有 STATE 并强制设为 0600。使用绝对路径以及尚不存在的全新输出路径:
set -euo pipefail
umask 077
RUNTIME=/absolute/path/to/extracted-runtime
STATE=/absolute/path/to/fresh-private-state
TRANSFER=/absolute/private/path/to/received-rank1-files
[[ ! -e "$STATE/rank1-receipt.prar" && ! -L "$STATE/rank1-receipt.prar" ]]
[[ ! -e "$STATE/rank1-topology.bin" && ! -L "$STATE/rank1-topology.bin" ]]
install -m 600 "$TRANSFER/rank1-receipt.prar" "$STATE/rank1-receipt.prar"
install -m 600 "$TRANSFER/rank1-topology.bin" "$STATE/rank1-topology.bin"
[[ "$(realpath -e -- "$STATE")" == "$STATE" ]]
[[ "$(stat -c %u -- "$STATE")" -eq "$EUID" ]]
[[ "$(stat -c %a -- "$STATE")" == 700 ]]
for input in "$STATE"/rank{0,1}-{receipt.prar,topology.bin}; do
[[ -f "$input" && ! -L "$input" ]]
[[ "$(realpath -e -- "$input")" == "$input" ]]
[[ "$(stat -c %u -- "$input")" -eq "$EUID" ]]
[[ "$(stat -c %a -- "$input")" == 600 ]]
[[ "$(stat -c %h -- "$input")" -eq 1 ]]
done
PLAN="$STATE/hy4-two-rank-plan.prmp"
[[ ! -e "$PLAN" && ! -L "$PLAN" ]]
"$RUNTIME/bin/prima-moe-plan" create-v1 \
--adapter hyv4-preview-stq1-0-v1 \
--rank0-receipt "$STATE/rank0-receipt.prar" \
--rank1-receipt "$STATE/rank1-receipt.prar" \
--rank0-topology "$STATE/rank0-topology.bin" \
--rank1-topology "$STATE/rank1-topology.bin" \
--cut 61 \
--rank0-device-layers 15,15,15,16 \
--rank1-device-layers 17 \
--output "$PLAN"
chmod 600 "$PLAN"
--cut 61 把模型的第 0–60 层分给 rank 0,把第 61–77 层分给 rank 1。各 GPU 的数字表示连续的基础层放置,具体如下:
| Rank | GPU | Plan 层数 | 参考层范围 |
|---|---|---|---|
| Rank 0 | CUDA0 · A4000 | 15 | 0–14 |
| Rank 0 | CUDA1 · A4000 | 15 | 15–29 |
| Rank 0 | CUDA2 · A4000 | 15 | 30–44 |
| Rank 0 | CUDA3 · A4000 | 16 | 45–60 |
| Rank 1 | CUDA0 · 4090 Laptop | 17 | 61–77 |
这张表描述的是 layer placement,并不是专家并行。对每个连续层范围,表中的 GPU 负责常驻 main graph,包括 attention、routing 和 normalization tensors,同时负责 shared-expert weights 以及该层的 state 和 KV cache。这些数字不会把 routed-expert bank 按层分给各 GPU。
专家并行是随后发生在 rank 内部、仅作用于 routed experts 的第二步。对 rank 0 的路由 MoE 层 1–60,被接纳的 hot-expert weights 会按照 (参考 owner + expert ID mod 4) mod 4 分散到四张 A4000。例如,参考 owner 为 CUDA1 时,expert ID 0、4、……优先进入 CUDA1;1、5、……进入 CUDA2;2、6、……进入 CUDA3;3、7、……进入 CUDA0,实际放置还需满足 hot cache 容量。多个 GPU expert branches 会一起提交,与由本机主存和 SSD 支撑的 CPU cold-expert branch 重叠执行,最后按稳定顺序归并。
Rank 1 只有一张 GPU,因此没有 rank 内多 GPU expert fan-out。PRIMA 不在两台机器之间做专家分发,因为这会让每个路由层都经过高 RTT 的跨 LAN 链路交换专家数据。
这个工具不会自动搜索最快的放置方案。它会确认两个凭据指向同一模型制品和适配器,检查两端记录的 GPU 拓扑,验证人工选择的切分点与各 GPU 层数,并写出二进制 plan。这些参数只对应本测试环境,硬件变化后需要重新决定放置方式。原样传输生成的 plan;在 rank 1 上先接收到 STATE 之外,确认目标不存在,再执行 install -m 600 /absolute/path/to/received-plan "$STATE/hy4-two-rank-plan.prmp"。两个 rank 启动时都通过 --moe-manual-plan 使用各自的私有本地副本。
6. 启动 rank 0 和 rank 1
两个进程组成一个环,每个 rank 各有一个数据端口和一个信号端口。由于直接反向连通性不可用,实测主路径使用 SSH tunnel。先启动 tunnel,再以 --worker-ready-listener 启动 rank 1,最后以 --head --world 2 启动 rank 0。
| 顺序 | Rank | 本机 data / signal / echo 端口 | --next |
|---|---|---|---|
| 1 | Rank 1 · 4090 | 19541 / 20571 / 20771 | 127.0.0.1:19542:20572(本地转发) |
| 2 | Rank 0 · A4000 | 19540 / 20570 / 20770 | 127.0.0.1:19543:20573(反向转发) |
启动任何进程前先保护端口。本预览的 Ring data/signal 与诊断 echo listener 会绑定 wildcard interface;复现时 rank 0 HTTP listener 即使传入 --host 127.0.0.1,仍出现在 0.0.0.0:18331。这些 listener 都没有 TLS 或客户端认证。应使用符合本地网络的 firewall/routing 策略,拒绝不可信入口访问 18331、18332、19540、19541、20570、20571、20770 和 20771,同时保留必要的 loopback 流量。启动前在两机运行 ss -ltnp,确认所有声明及转发端口空闲。不要粘贴可能切断 SSH 的通用防火墙命令。
首次使用前,应通过独立可信渠道核对 A4000 主机公钥指纹并写入 known_hosts,不要盲目接受 TOFU 提示。在 Laptop 的终端 A 中让下方 tunnel 保持前台运行。替换 SSH 用户名与 A4000_HOST;必须允许非交互式公钥认证、严格 known-host 校验以及 local、remote 两种 TCP forwarding,且不能被 PermitOpen/PermitListen 阻断。ExitOnForwardFailure 只确认六个转发 listener 绑定成功,不代表尚未启动的 Prima endpoint 已 ready。
set -euo pipefail
SSH_TARGET=ubuntu@A4000_HOST # 替换用户名和主机
ssh -N -T -S none \
-o BatchMode=yes \
-o PasswordAuthentication=no \
-o KbdInteractiveAuthentication=no \
-o ControlMaster=no \
-o ControlPath=none \
-o ExitOnForwardFailure=yes \
-o ServerAliveInterval=15 \
-o ServerAliveCountMax=3 \
-o ConnectTimeout=15 \
-o ForwardAgent=no \
-o NumberOfPasswordPrompts=0 \
-o StrictHostKeyChecking=yes \
-L 127.0.0.1:19542:127.0.0.1:19540 \
-L 127.0.0.1:20572:127.0.0.1:20570 \
-L 127.0.0.1:20770:127.0.0.1:20770 \
-R 127.0.0.1:19543:127.0.0.1:19541 \
-R 127.0.0.1:20573:127.0.0.1:20571 \
-R 127.0.0.1:20771:127.0.0.1:20771 \
"$SSH_TARGET"
其中四个 data/signal forward 是已经复现的功能路径。额外两个 echo forward 遵循 runtime 的 signal_port + 200 规则,用于获得 best-effort outbound-hop telemetry;它们不会改变固定的 scheduler hop price。
在两台机器上把以下公共启动设置保存为 $STATE/hy4-common.sh。这些 opt-in gate 是经过复现的 STQ runtime 配置组成部分,不是可省略的调优建议。
set -euo pipefail
umask 077
STATE=/absolute/path/to/fresh-private-state
cat > "$STATE/hy4-common.sh" <<'BASH'
COMMON_ENV=(
PATH=/usr/bin:/bin LANG=C LC_ALL=C
CUDA_CACHE_DISABLE=1 CUDA_DEVICE_ORDER=PCI_BUS_ID CUDA_LAUNCH_BLOCKING=0
GGML_CUDA_DISABLE_GRAPHS=1
LLAMA_MOE_CPU_CUDA_NUMERIC_COMPAT_V1=1
PRIMA_ACTIVATION_WIRE_DTYPE=fp32
PRIMA_MOE_BACKGROUND_STAGING_V1=1
PRIMA_MOE_BG_PROMOTION_V1=1
PRIMA_MOE_COPY_STREAM_READY_SYNC_V1=1
PRIMA_MOE_COPY_STREAM_V1=1
PRIMA_MOE_DECODE_TIMING_V1=1
PRIMA_MOE_DRAIN_PROMOTION_COPIES_WITHIN_ALLOWANCE_V1=1
PRIMA_MOE_HOTCACHE_POLICY_V1=recent
PRIMA_MOE_PRECISE_PREFETCH_V1=1
PRIMA_MOE_PUBLISH_READY_BEFORE_DECODE_V1=1
PRIMA_MOE_REQUEST_PLANNER_V1=1
PRIMA_MOE_ROUTE_PAGECACHE_POPULATE_V1=1
PRIMA_MOE_ROUTE_PAGE_PREFETCH_V1=1
PRIMA_MOE_STARTUP_COLD_PREFETCH_MAX_BYTES_V1=8589934592
PRIMA_MOE_STARTUP_COLD_PREFETCH_V1=1
)
COMMON_ARGS=(
--model /proc/self/fd/203 --load-mode mmap --log-profile production
--topology static --world-timeout 7200
--ctx-size 8192 --batch-size 2 --ubatch-size 1 --parallel 1
--n-predict 60 --threads 8 --threads-batch 8
--moe-hybrid manual
--moe-provider tiered-local-cold-hot-v1
--moe-model-adapter hyv4-preview-stq1-0-v1
--moe-routing-policy local-cold-no-remote-v1
--moe-min-request-hits 2 --moe-ttft-guard-percent 3
--moe-artifact-receipt /proc/self/fd/200
--moe-manual-plan /proc/self/fd/201
--jinja --no-context-shift --no-warmup --no-repack
--no-cache-prompt --cache-reuse 0 --no-slots --no-webui
--seed 0 --temp 0 --top-k 1 --top-p 1 --min-p 0
--repeat-penalty 1 --ignore-eos
)
BASH
chmod 600 "$STATE/hy4-common.sh"
在 4090 Laptop 的终端 B 中以前台方式启动 rank 1。保留复现启动前有 15,930 MiB 可用显存和 22.66 GB MemAvailable;代码块会在低于保守的复现环境 gate(15,800 MiB 和 22.0 GB)时中止。Wrapper 会把本地 receipt、plan 和模型固定到文件描述符 200、201 和 203;当前 manual-mode 合同不接受普通的 plan 路径。
set -euo pipefail
umask 077
RUNTIME=/absolute/path/to/extracted-runtime
STATE=/absolute/path/to/fresh-private-state
MODEL=/absolute/path/to/Hy4-preview-STQ1_0.gguf
source "$STATE/hy4-common.sh"
nvidia-smi
mem_available_bytes=$(awk '/^MemAvailable:/ { printf "%.0f\n", $2 * 1024 }' /proc/meminfo)
gpu_free_mib=$(nvidia-smi --query-gpu=memory.free --format=csv,noheader,nounits)
(( mem_available_bytes >= 22000000000 ))
[[ "$gpu_free_mib" =~ ^[0-9]+$ ]]
(( gpu_free_mib >= 15800 ))
(
exec 200<"$STATE/rank1-receipt.prar"
exec 201<"$STATE/hy4-two-rank-plan.prmp"
exec 203<"$MODEL"
exec env -i \
"${COMMON_ENV[@]}" \
TMPDIR="$STATE/tmp" \
PRIMA_LOG_ROOT="$STATE/logs/prima-log" \
CUDA_VISIBLE_DEVICES=0 \
"$RUNTIME/bin/prima-server" \
"${COMMON_ARGS[@]}" \
--moe-profile-cache "$STATE/rank1-profile-cache.bin" \
--next 127.0.0.1:19542:20572 \
--data-port 19541 --signal-port 20571 \
--worker-ready-listener \
--host 127.0.0.1 --port 18332 \
--device CUDA0 --split-mode layer --moe-device-group CUDA0
) 2>&1 | tee "$STATE/logs/rank1.log"
保持终端 B 存活。在 Laptop 的另一个终端确认 rank 1 进程仍在运行,并确认 ss -ltnp 已显示 data listener 19541;随后立即在四卡 A4000 服务器的终端 C 启动 rank 0。此时不要等待 rank 1 的 signal 端口 20571、HTTP 端口 18332 或 prima-server: service ready:signal listener 与 ready 标志只有在 rank 0 加入、static world 继续通过各项 barrier 后才会出现。
保留复现中,四张 A4000 启动前每张有 14,966 MiB 可用显存,主机有 27.91 GB MemAvailable。rank 0 代码块要求恰好四张可见 GPU、每张至少 14,900 MiB 可用显存,以及至少 27.0 GB 可用主存。这些 gate 用于复现本次 admission envelope,并非通用硬件最低配置。
set -euo pipefail
umask 077
RUNTIME=/absolute/path/to/extracted-runtime
STATE=/absolute/path/to/fresh-private-state
MODEL=/absolute/path/to/Hy4-preview-STQ1_0.gguf
source "$STATE/hy4-common.sh"
nvidia-smi
mem_available_bytes=$(awk '/^MemAvailable:/ { printf "%.0f\n", $2 * 1024 }' /proc/meminfo)
mapfile -t gpu_free_mib < <(nvidia-smi --query-gpu=memory.free --format=csv,noheader,nounits)
(( mem_available_bytes >= 27000000000 ))
(( ${#gpu_free_mib[@]} == 4 ))
for free_mib in "${gpu_free_mib[@]}"; do
[[ "$free_mib" =~ ^[0-9]+$ ]]
(( free_mib >= 14900 ))
done
(
exec 200<"$STATE/rank0-receipt.prar"
exec 201<"$STATE/hy4-two-rank-plan.prmp"
exec 203<"$MODEL"
exec env -i \
"${COMMON_ENV[@]}" \
TMPDIR="$STATE/tmp" \
PRIMA_LOG_ROOT="$STATE/logs/prima-log" \
CUDA_VISIBLE_DEVICES=0,1,2,3 \
"$RUNTIME/bin/prima-server" \
"${COMMON_ARGS[@]}" \
--moe-profile-cache "$STATE/rank0-profile-cache.bin" \
--head --world 2 \
--next 127.0.0.1:19543:20573 \
--data-port 19540 --signal-port 20570 \
--host 127.0.0.1 --port 18331 \
--device CUDA0 --split-mode layer \
--moe-device-group CUDA0,CUDA1,CUDA2,CUDA3
) 2>&1 | tee "$STATE/logs/rank0.log"
两个进程都启动后,确认 20570/20571 signal listener 已出现,并等待两份 rank 日志都出现精确标志 prima-server: service ready。如果任一前台命令退出,应停止并诊断,而不是继续轮询。只有 rank 0 对客户端提供服务。在 A4000 主机上使用单次超时和总 deadline 轮询 /health 至 HTTP 200,再以独立的有限超时发送固定 sampler chat 请求。Hy4 可能先用若干 token 进行推理,因此应同时检查 content 和 reasoning_content;token 预算很小时,content 为空并不一定是启动失败。
set -euo pipefail
umask 077
STATE=/absolute/path/to/fresh-private-state
deadline=$((SECONDS + 7200))
until curl -fsS --connect-timeout 2 --max-time 5 \
-o "$STATE/health.json" http://127.0.0.1:18331/health; do
(( SECONDS < deadline )) || { echo "health deadline exceeded" >&2; exit 1; }
sleep 5
done
RESPONSE="$STATE/smoke-chat-response.json"
curl -fsS --connect-timeout 5 --max-time 900 \
-o "$RESPONSE" http://127.0.0.1:18331/v1/chat/completions \
-H 'Content-Type: application/json' \
-d '{
"model": "hy4-preview-stq1_0",
"messages": [{"role": "user", "content": "Reply with one short sentence: why does local expert caching help sparse MoE inference?"}],
"max_tokens": 64,
"temperature": 0,
"top_k": 1,
"top_p": 1,
"min_p": 0,
"repeat_penalty": 1,
"seed": 0,
"stream": false
}'
jq -e '((((.choices[0].message.content // "") | length) > 0) or
(((.choices[0].message.reasoning_content // "") | length) > 0))' \
"$RESPONSE" >/dev/null
jq '.choices[0].message | {content, reasoning_content}' "$RESPONSE"
启动后立即再次运行 ss -ltnp,确认观察到的 wildcard data、signal、echo 与 HTTP listener(包括 20770/20771)均已被预先配置的 ingress 策略保护。--host 127.0.0.1 与 SSH loopback forward 都不会约束 Prima 自身的 wildcard bind。
7. 决定本次运行方式的关键设置
关键设置包括:
/proc/self/fd/200、/proc/self/fd/201和/proc/self/fd/203:通过 wrapper 固定的描述符读取 receipt、manual plan 和模型,避免服务端再次按可变路径名打开这些文件;--topology static、--world-timeout 7200和--moe-hybrid manual:满足当前 STQ 启动合同,使用声明的双 rank 静态拓扑,为 rank 协调和冷启动预留最多 7,200 秒,并要求使用提供的手动 hybrid-MoE plan;--moe-provider tiered-local-cold-hot-v1:热专家数据保留在 GPU,较冷的数据使用主机内存和本地 SSD;--moe-routing-policy local-cold-no-remote-v1:每个 rank 从本地读取自己的冷权重,而不是从另一台机器获取;--moe-manual-plan /proc/self/fd/201:两个 rank 都通过必需的 FD 201 加载同一份经过校验的 plan;当前 manual-mode 合同会拒绝普通文件系统路径;--load-mode mmap:映射 229 GB 模型,让较冷的页面由每个 rank 的本地存储提供;--split-mode layer:按 plan 放置常驻 main-graph 和 shared-expert 层数据;routed hot experts 仍使用 rank 0 内部的本地专家并行;--moe-device-group:声明每个 rank 可用且有序的本地 GPU 组;--ctx-size 8192 --batch-size 2 --ubatch-size 1 --parallel 1:以本次实测使用的 8K 上下文 batch 配置,每次运行一个请求;--no-warmup --no-repack:在这条记录路径中跳过自动 warmup 和权重 repack;--jinja:应用模型的 Jinja chat template,确保/v1/chat/completions具有可靠的聊天语义。
公共 wrapper 还会固定 PCI 总线 GPU 顺序、关闭 CUDA graphs、启用实测的 CPU–CUDA 数值兼容路径,并以 FP32 传输 rank 间激活。公共代码块中列出的 PRIMA_MOE_* 变量明确启用本次复现所用的 request planner、hot-cache policy、cold prefetch、page-cache population、后台 staging/promotion 与异步 copy synchronization;省略它们就属于未经验证的另一套配置。
我们会在 Playground 中回放实测生成过程。Playground 不会连接真实设备或启动实时推理;它回放的是一次真实离线推理运行中记录的固定输入、输出和逐 token 时间。
1 本指南仅用于功能预览,当前只适配上方兼容矩阵中精确列出的 x86-64、GPU/SM、Ubuntu 和 CUDA ABI 组合。Mac 系列设备暂未支持。未来版本将简化部署流程、支持自动生成 plan,并支持 Mac 集群和 Mac–Linux 混合集群。
2 可执行二进制文件包:公开的 AngelSlim/Hy4-preview-GGUF/prima-runtime。
The workstation you need may already be in the room.
Local AI does not always need another monolithic machine. Sometimes the more practical path is to treat the hardware around you as one adaptable pool.
Local AI often begins with a shopping list: more VRAM, a larger power supply, and a workstation built around the biggest model you hope to run. That approach can be fast, but it also leaves capable laptops, desktops, mini PCs, and tablets sitting outside the system.
The single-box assumption
A single workstation is easy to reason about because every resource sits behind one operating system. Its limits are equally clear. Once the model, context, or precision outgrows that box, the usual answer is to replace it with a more expensive one.
A useful local AI system does not have to be the fastest possible system.
Treat hardware as a pool
Distributed inference changes the unit of planning from one machine to a collection of machines. A laptop can contribute a GPU, a desktop can contribute memory and compute, and devices on another LAN can remain part of the same testbed.
The important question becomes less binary: not “Can this device run the model?” but “What useful capacity can this device add to the pool?”
Useful is a product decision
A pooled system may not beat a purpose-built server on every latency metric. It can still unlock a larger model, longer context, better precision, or enough throughput for a private workflow—without discarding hardware that has already been purchased.
That tradeoff is the point: local AI should be able to grow incrementally, across the devices and networks people actually have.
Scalability Matters More Than a Bigger Machine: What PRIMA’s Hy4 Preview 770B Experiment Reveals About Local AI
PRIMA is not trying to make one ordinary machine perform a miracle. It lets the devices we already own work together and push the boundaries of local AI further.
Every local AI performance number hides a trade-off
Life is full of trade-offs. Local AI is no different.
We have already seen remarkable local AI throughput. With a highly customized hardware setup, for example, two RTX 2080 Ti cards modified to 22GB of VRAM and connected over NVLink can deliver more than 100 TPS for single-request generation with Qwen 3.8 27B.
FreeToken, as another example, has accelerated GLM-5.2 753B to 15 TPS on an RTX PRO 6000 96GB, but that setup requires 512GB of host memory.
Other approaches use low-bit quantization to bring interactive throughput for hundred-billion-parameter MoE models to consumer workstations.
All of these approaches are valuable, but each encodes a different trade-off among intelligence, speed, and cost:
- Larger models, and models closer to full precision, come with a sharp loss in speed;
- Lowering quantization precision can reduce model capability;
- Custom or more powerful CPUs and GPUs, more system memory, and greater memory bandwidth raise hardware cost;
- Laptops we already own often have limited RAM and VRAM, forcing us toward smaller models or lower precision.
These are impressive systems. But:
Choosing a fixed hardware configuration also means choosing its ceiling. If frontier models grow, the machine quickly becomes insufficient. If frontier models shrink, we may have bought more than we need. Either way, an expensive fixed configuration can easily become a sunk or unnecessary cost.
This does not mean we should never buy stronger hardware. The problem is that local AI requirements change quickly, while hardware remains fixed.
A high-memory workstation purchased today for a 100B model may be insufficient tomorrow when the model grows to 700B. We then look for another, stronger machine: new GPUs, more and larger memory modules, a faster CPU and SSD, perhaps even a new motherboard, power supply, cooling system, and chassis. Meanwhile, the hardware we already paid for becomes a sleeping asset.
The reverse can also happen. If MoE, sparsity, or a more efficient architecture produces a stronger model with fewer parameters, the expensive hardware purchased specifically for a “large model” may be wasted.
That led us to a different question:
Instead of repeatedly searching for a new machine that only meets today’s requirements, can the machines we already own keep scaling as those requirements change?
PRIMA pursues scalability, not a “speed miracle”
PRIMA is not designed to set a local AI throughput record on one carefully selected hardware configuration. It focuses on a different and more common real-world situation.
We may already have a laptop, an older workstation, a Mac Mini, a GPU server at the office, or even devices at a neighbor’s or friend’s home on another LAN. None is powerful enough on its own. But what if we combine them?
PRIMA aims to organize these otherwise independent devices into a local AI cluster that can expand on demand. It wakes sleeping assets and lets every machine contribute whatever remains useful. As new devices join, the capacity of the cluster can continue to grow.
PRIMA does not optimize only for “fastest.” It expands four boundaries of local AI as needed: larger models, faster generation, longer context, and higher model precision. In other words:
Do not buy an entirely new machine every time requirements grow. Add devices to the local AI cluster when demand rises, and release them when demand falls. Those devices are ones we already own.
This is what PRIMA means by scalable local AI.
Hy4 preview 770B gave us an extreme experiment
When Tencent released Hy4 preview, we saw a model that was unusually well suited to testing this idea.
Hy4 preview is a 770B-parameter MoE model. Its MoE layers contain 256 routed experts and one shared expert. For every generated token, eight routed experts plus the shared expert are activated, for roughly 49B active parameters per token.
The MoE architecture does not activate all 770B parameters for every token, but the complete expert weights still place enormous pressure on RAM and VRAM. Even after aggressive 1-bit quantization, storing the Hy4 preview 770B parameters requires more than 200GB. That pushed our question to an extreme:
Without buying any new hardware for Hy4 preview, how far could I run this 770B model using only the devices already available to me?
The first device: an ordinary 4090 Laptop
My first device was the laptop I use every day:
| Hardware | Configuration |
|---|---|
| CPU | Intel Core Ultra 9 185H |
| System memory | 32GB |
| GPU | NVIDIA RTX 4090 Laptop |
| VRAM | 16GB |
I initially wanted to try FreeToken, but the laptop had only 32GB of system memory—enough for just a fraction of Hy4 preview IQ1. Continuing down the full-memory-residency path would require at least 256GB of RAM. On a laptop, that is not as simple as adding a few memory modules; the motherboard would have to change as well. At that point, I might as well call the result a high-memory workstation.
I did not want to build or buy an expensive high-memory workstation for one model. Apart from electricity, my hardware budget was zero.
Instead, I used llama.cpp with mmap and disk streaming to run Hy4 preview 770B IQ1 directly on the laptop.
The model ran. But its per-token latency reached 5.9 s/token, or approximately 0.17 TPS.
From the narrow perspective of whether the model could start, this was a success. In practice, it was painfully slow. About 0.17 TPS was the laptop’s single-device limit under this model and quantization, before introducing accelerators such as MTP, DFlash2, or DSpark.
The second device: a modest four-A4000 server
At my workplace, I also had access to a GPU server:
| Hardware | Configuration |
|---|---|
| CPU | Intel Core i7-12700 |
| System memory | 32GB |
| GPU | NVIDIA RTX A4000 × 4 |
| VRAM per GPU | 16GB |
The RTX A4000 dates to 2021. Each card has only 16GB of VRAM, and both its compute performance and price are less than half those of the 4090 Laptop. Its lower cost was precisely why the server had been configured with four cards to expand VRAM.
Even with four GPUs, the server had only 96GB of system memory and VRAM combined—less than half of the model’s 200GB-plus parameter footprint. FreeToken could not rescue this configuration either.
We therefore used llama.cpp again. It ran at approximately 2.7 s/token, or 0.37 TPS.
It was faster than the laptop, but still painfully slow.
Using PRIMA to combine two insufficient machines
If we simply add the system memory and VRAM of the two devices, we get:
- Laptop: 32GB RAM + 16GB VRAM;
- GPU server: 32GB RAM + 64GB VRAM;
- Total: 144GB of combined RAM and VRAM.
That is still smaller than the model file itself, and those resources are scattered across two machines, five GPUs, multiple PCIe links, and different storage devices.
The machines are not even on the same LAN. The laptop reaches the GPU server on a remote LAN over Wi-Fi and a VPN. Network RTT is approximately 50ms; the laptop’s downlink is only 145 Mbps, and its uplink is lower still at 27 Mbps.
From an HPC perspective, this is almost exactly the kind of hardware and network setup one would be told not to use for distributed large-model inference. Yet it reflects the real world of local AI: heterogeneous devices, limited memory, and wireless networking.
PRIMA did not try to squeeze more than 200GB of model weights into 144GB of aggregate memory. Instead, it used a layered, distributed execution strategy:
- Run some MoE layers on the 4090 Laptop;
- Assign most MoE layers to the four-A4000 server;
- Keep frequently used hot experts on the GPUs;
- Leave temporarily inactive cold experts in host memory or on SSD;
- Learn dynamically which experts are worth caching from the routing observed in the current request;
- Prefetch experts that the next stage is likely to use from SSD;
- Overlap disk reads, GPU computation, and network communication wherever possible;
- Execute experts in parallel within each node, distributing expert work across multiple GPUs;
- Reduce unnecessary data copies and repeated loading;
- Transmit only intermediate activations and control messages between devices, not enormous expert weights.
Think of the system as an enormous tool warehouse. Hy4 preview has hundreds of tools, but a specific problem needs only a few of them at a time. The GPU is a fast workbench close to the worker, but it has little space. The SSD is a vast warehouse, but retrieving a tool takes time. PRIMA tries to predict which tools will be needed next, move them close to the workbench in advance, and keep multiple workers and warehouses busy at the same time.
From 6 seconds to 1.5 TPS
With PRIMA coordinating the two devices, we measured:
| Configuration | Throughput |
|---|---|
| 4090 Laptop + llama.cpp | 0.17 TPS |
| 4× A4000 Server + llama.cpp | 0.37 TPS |
| 4090 Laptop + 4× A4000 + PRIMA | 1.5 TPS |
With the two devices working together, throughput increased by 8.8× over the laptop alone and by 4.1× over the four-A4000 server alone.
1.5 TPS is not a speed worth boasting about. What matters is this:
Without spending anything on new hardware, we accelerated a 770B model by 8.8×.
1.5 TPS is nowhere near PRIMA’s performance ceiling
More importantly, the primary bottleneck in this two-machine system is still not CPU or GPU compute. It is streaming model data from SSD. The complete Hy4 preview IQ1 weights remain larger than the RAM and VRAM that can stay resident across both devices. Every generated token still requires substantial cold-expert data to be read from SSD. Prefetching, the page cache, expert caching, and computation overlap hide as much disk latency as possible, but SSD bandwidth remains the clearest bottleneck.
Therefore:
1.5 TPS is the limit of these two devices, not the performance limit of PRIMA.
Replacing the SSDs with higher-throughput storage in the future would leave significant room for improvement.
Adding another device—a neighbor’s desktop or a colleague’s Mac Mini—could also create meaningful headroom.
A new device contributes more than CPU or GPU compute. It also adds system memory, GPU memory, and parallel SSD bandwidth.
The model can be distributed further, each machine can read fewer weights from disk, and multiple SSDs can operate simultaneously. Eventually, the bottleneck will move from storage to compute or networking.
Only as requirements continue to grow do we need to introduce more advanced compute, high-speed wired interconnects, optical wireless links, or other advanced technologies into the local cluster.
This is the point of a scalable system:
Do not begin by paying for maximum performance. Begin with the requirements of the application, identify the current bottleneck, and expand only the resource that limits it.
PRIMA complements single-device techniques
PRIMA’s emphasis on scalability is what most clearly distinguishes it from many high-performance local AI approaches.
PRIMA does not reject better GPUs, more powerful AI chips such as Xring, larger memory, faster SSDs, or better quantization. Nor does it compete with FreeToken, llama.cpp, or future single-machine optimizations.
On the contrary:
The stronger each machine becomes, the stronger the foundation of a PRIMA cluster becomes.
If an exceptionally powerful local AI inference machine appears in the future, PRIMA can make it the origin of the cluster. The 4090 Laptop, A4000 Server, and other devices we already own can remain expansion nodes.
If models keep growing, we add more devices around that AI machine.
If context keeps growing, or if we want to move from IQ1 to a higher-precision quantization, the 4090 and four-A4000 server can expand the system RAM and GPU memory available to the AI machine. We do not need to discard it and pay the full cost of an even stronger replacement.
If smaller, more capable models arrive, the PRIMA cluster can scale down at any time and release our laptops and desktops. After all, local AI was not the only reason we bought them.
When we need a 1M-token context, even longer context, or greater concurrency, we can wake those devices again.
From “Can this device run it?” to “What can it contribute?”
PRIMA is making the question “Which AI computer should I buy next?” less important.
When evaluating local AI hardware, we have traditionally asked: “Can this device still run the model?” If the answer is no, a machine with a high sunk cost is put aside.
PRIMA reframes the question: What can this device still contribute to my AI? It may not run Hy4 preview alone, but it has a GPU. The GPU may not be fast, but it has 16GB of VRAM and the machine has 32GB of RAM. The CPU may be old, but the device has a fast NVMe SSD. None of it may be flagship hardware, yet several such devices together can support something no single one of them can do.
For personal and home AI, this matters more than chasing the highest TPS in a single benchmark. Because:
Real-world user-side computing resources are heterogeneous, and they already surround us. What local AI lacks is the ability to unify those heterogeneous resources.
The system may be slow, but slow systems still have useful applications, and we can add capacity to make them faster.
The model may be less capable, but most real-world tasks do not require the most capable model. We can add capacity until it becomes capable enough.
PRIMA + Hy4 preview 770B was a successful stress test. It did not create a local AI throughput miracle. It showed that 0.37 TPS on one device was not the limit of what I could deploy without new hardware, and that 1.5 TPS across two devices is not the end of the performance curve.
Where will that boundary move when the next device joins?
That is the question PRIMA intends to keep answering.
不可忽视的可扩展性:PRIMA 的 Hy4 Preview 770B 压测揭示本地 AI 新方向
PRIMA 不追求单机奇迹,而是让已有设备一起,把本地 AI 的边界推得更远。
本地 AI 的每一个性能数字背后,都有取舍
人生处处是取舍,本地 AI 也是如此。
今天,我们已经看到许多令人惊叹的本地 AI 吞吐。例如,在定制的硬件条件下,两张改装到 22GB 显存、通过 NVLink 互联的 RTX 2080 Ti,可以让 Qwen 3.8 27B 实现超过 100 TPS 的单请求生成速度。
又例如, FreeToken 在 RTX PRO 6000 96GB 上将 GLM-5.2 753B 加速到 15 TPS,但要求 512 GB 主机内存。
另一些方案通过低比特量化、让上百 B 的 MoE 模型在消费级工作站上达到可交互的吞吐。
这些方案都很有价值,但它们隐含着不同的“智能-速度-成本”的取舍:
- 更大的模型、越接近满血,背后是速度的显著下降;
- 调低量化精度,隐含着模型能力损失;
- 换上定制/更强的 CPU 和 GPU,更大的系统内存、显存带宽,隐含着更高的硬件成本。
- 已经购买的笔记本电脑,显存小,主存也小,只能降级到更小模型或更低精度。
这些方案很出色,但:
选择特定硬件,也就选择了它的上限:SOTA 模型变大,它很快不够用;SOTA 模型变小,它又可能买多了。最终,昂贵的固定配置很容易变成沉没成本/不必要成本。
这并不是说我们不应该购买更强的硬件。问题在于,本地 AI 的需求变化得太快,而硬件是固定的。
今天为了某个 100B 模型购买的大内存工作站,明天可能因为模型增长到 700B 而再次不够。于是,我们继续寻求一台更强的整机,购买新的 GPU、更多/更大的内存卡、更强的 CPU、更快的 SSD,甚至新的主板、电源、散热系统和机箱。与此同时,之前已经购买的设备将变成沉睡资产。
反过来,如果新的模型通过 MoE、稀疏化或更高效的架构,在更小参数量下获得了更强能力,那么今天为了“大模型”额外购买的高昂硬件,又会被浪费。
所以,我们开始思考另一个问题:
与其不断寻找一台仅能满足当前需求的新机器,能否让我们已经拥有的机器随需求的变化持续扩展?
PRIMA 追求的不是“速度奇迹”,而是可扩展性
PRIMA 的目标不是在某一套精心选择的硬件上刷新本地 AI 的吞吐纪录。它更关注现实世界中的另一种情况:
我们已经有一台笔记本,也许还有一台旧工作站、一台 Mac Mini、一台办公室里的 GPU 服务器,甚至几台邻居或朋友家里、不同局域网中的设备。它们单独看,都不够强。但它们加在一起呢?
PRIMA 希望把这些原本彼此独立的设备组织成一个可以按需扩展的本地 AI 集群,唤醒沉睡资产,让每一台设备贡献自己仍然有价值的部分。当新的设备加入时,整个集群的容量可以持续增长。
PRIMA 所追求的不是“最快”, 而是按需扩展本地 AI 的四个边界: 更大的模型、更快的生成速度、更长的上下文,或更高的模型精度。换句话说:
不是每次需求增长都重新买一台机器。当需求增长时,我们往本地 AI 集群增加新设备;当需求削减时,我们从本地 AI 集群撤出设备。而这些设备,是我们已经购买的。
这也是 PRIMA 所关注的“可扩展本地 AI”。
当 Hy4 preview 770B 发布,我们想做一个极端实验
在腾讯发布 Hy4 preview 后,我们看到了一个非常适合验证这个想法的模型。
Hy4 preview 是一个 770B 参数规模的超大 MoE 模型,它的 MoE 层包含 256 个路由专家和 1 个共享专家,每生成一个 token,会激活其中 8 个路由专家和共享专家。模型每个 token 的激活参数约为 49B。
虽然 MoE 架构并不会在每个 token 上激活全部 770B 参数,但完整的专家权重仍然给主存和显存带来巨大压力。即使经过激进的 1-bit 量化, Hy4 preview 770B 的模型参数存储需求仍然高达 200 GB+,这把我们的问题推到一个极端规模:
如果不为了 Hy4 preview 购买任何新硬件,仅凭我手上的现有设备,能把这个 770B 模型跑到什么程度?
第一台设备:一台普通的 4090 Laptop
我手里的第一台设备,是一台日常使用的笔记本电脑:
| 硬件 | 配置 |
|---|---|
| CPU | Intel Core Ultra 9 185H |
| 系统内存 | 32GB |
| GPU | NVIDIA RTX 4090 Laptop |
| 显存 | 16GB |
我本想尝试 FreeToken,但我发现: 这台笔记本的系统内存太小了,只有 32 GB,只够放 Hy4 preview IQ1 的一个零头。要沿着全内存驻留路线继续,我需要扩展内存到至少 256 GB。但这不是“再插几根内存条”这么简单,笔记本主板得跟着一起换。升级完以后,我或许该称它为高内存工作站。
而我并不想为了一个模型,大价钱打造/重新买一台大内存工作站。除了电费,我一分钱预算都没有。
于是,我选择了 llama.cpp,通过 mmap 和磁盘流式读取,在这台笔记本上直接运行 Hy4 preview 770B IQ1。
模型确实跑起来了。但它的单 token 延迟高达 5.9 s/token,约等于 0.17 TPS。
从“模型能否启动”的角度看,这是成功的,但这个速度很难受。0.17 TPS 基本就是这台笔记本在当前模型和量化条件下的单机性能边界(这里还没有引入 MTP/DFlash2/DSpark 等加速技术)。
第二台设备:一台低配的四卡 A4000 服务器
在我的单位工位上,还有一台可以使用的 GPU 服务器:
| 硬件 | 配置 |
|---|---|
| CPU | Intel Core i7-12700 |
| 系统内存 | 32GB |
| GPU | NVIDIA RTX A4000 × 4 |
| 单卡显存 | 16GB |
RTX A4000 是 2021 年发布的古董 GPU 卡,每张卡只有 16GB 显存,算力和价格不及 4090 laptop 的一半。但也正是因为它便宜,当时配了 4 张卡扩容了 VRAM。
即便是一台四卡服务器,它的系统内存和显存总计也只有 96 GB,不及模型参数 200 GB+ 的一半,FreeToken 对此也表示救不了。
于是我们仍然使用 llama.cpp 来运行它,速度约为:2.7 s/token,约等于 0.37 TPS。
它比笔记本快,但依然很难受。
用 PRIMA 把两台不够用的机器拼在一起
把两台设备的系统内存和显存简单相加,我们获得了:
- 笔记本:32GB RAM + 16GB VRAM;
- GPU 服务器:32GB RAM + 64GB VRAM;
- 合计:144GB RAM + VRAM 容量。
这仍然小于模型文件本身,而且这些资源分散在两台机器、五张 GPU、多个 PCIe 链路和不同的存储设备上。
它们甚至不在同一个局域网里:笔记本通过 Wi-Fi 和 VPN 访问远端局域网中的 GPU 服务器,网络 RTT 约为 50ms,笔记本的下行带宽仅为 145 Mbps,上行带宽更低,仅为 27 Mbps。
从 HPC 的角度看,这几乎是一套“不应该拿来做分布式大模型推理”的硬件和网络设施。但这正是本地 AI 面对的真实世界:异构设备、小内存、无线网络。
PRIMA 没有尝试把超过 200GB 的模型权重全部塞入 144GB 的聚合内存。它采取的是一种分层、分布式的执行方式:
- 将一部分 MoE 层放在 4090 Laptop 上运行;
- 将大部分 MoE 层分配给四卡 A4000 服务器;
- 把高频使用的热专家保留在 GPU;
- 把暂时不活跃的冷专家留在主机内存或 SSD;
- 根据当前请求实际发生的专家路由,动态学习哪些专家值得缓存;
- 提前从 SSD 预取下一阶段可能使用的专家;
- 让磁盘读取、GPU 计算、网络通信尽可能重叠;
- 单机内专家并行,将多个专家任务分散到多张 GPU 上并行执行;
- 减少不必要的数据复制和重复加载;
- 设备之间只传中间激活和控制信息,不传庞大的专家权重。
可以把它理解成一个非常大的工具仓库。 Hy4 preview 有几百种工具,但解决一个具体问题时,一次只需要其中少数几种。 GPU 是离工人最近的工作台,但空间很小。 SSD 是巨大的仓库,但取工具比较慢。 PRIMA 要做的事情,就是尽可能预测“接下来最可能用什么工具”,提前把它们放到工作台附近,同时让多个工人、多个仓库一起工作。
从 6 秒,到 1.5 TPS
在 PRIMA 的协调下,我们得到:
| 配置 | 吞吐 |
|---|---|
| 4090 Laptop + llama.cpp | 0.17 TPS |
| 4× A4000 Server + llama.cpp | 0.37 TPS |
| 4090 Laptop + 4× A4000 + PRIMA | 1.5 TPS |
两设备协同下,相对于笔记本单机,吞吐提高 8.8 倍;相对于四卡 A4000 服务器单机,吞吐提高 4.1 倍。
1.5 TPS 不是一个值得炫耀的速度。真正重要的是:
我们没有付出任何成本,就把一个 770B 模型加速 8.8 倍。
1.5 TPS 远不是 PRIMA 的性能上限
更重要的是, 目前这套两机系统的主要瓶颈依然不是 CPU/GPU 算力,而是 SSD 的磁盘流式读取。因为 Hy4 preview IQ1 的完整模型权重仍然大于两台设备能够常驻的内存和显存, 每生成一个 token,仍然有大量冷专家权重需要从 SSD 中读取。即使我们已经通过预取、page cache、专家缓存和计算重叠尽量隐藏磁盘延迟,SSD 带宽依然是当前系统最明显的瓶颈。
因此:
1.5 TPS 只是这两台设备的极限,并不是 PRIMA 的性能极限。
如果我们把 SSD 换成未来吞吐更高的存储,性能仍有显著提高空间。
如果我们再加入一台设备, 比如邻居家的台式机、工位旁朋友的 Mac Mini,同样有显著提高空间。
因为新设备带来的不仅是 CPU/GPU 算力,它同时增加:系统内存、GPU 显存、SSD 并行带宽。
模型可以被进一步分散,每台机器需要从磁盘读取的权重变少,多个 SSD 可以同时读取。最终,瓶颈将从磁盘转移到算力或网络。
随着需求进一步提高,我们才需要考虑向本地集群中引入更先进的算力,或有线高速互联,或无线光通信等更先进技术。
这正是可扩展系统的意义:
不是一开始就追求高成本的极致性能,而是以满足应用实际需求为目标,定位当前瓶颈,再只扩容对应的资源。
PRIMA 与高性能单机技术并不矛盾
PRIMA 关注可扩展,这是它与很多本地 AI 高性能方案最大的不同。
PRIMA 不排斥更好的 GPU、更强力的 AI 芯片(如玄戒)、更大的内存、更快的 SSD、更好的量化方法,也不排斥 FreeToken、llama.cpp 或未来更先进的单机优化技术。
恰恰相反:
单机能力越强,PRIMA 集群的基础能力就越强。
如果未来出现一台性能极强的本地 AI 推理机,PRIMA 将把它作为集群原点,而我们原来的 4090 Laptop、A4000 Server 或其他设备仍然可以作为扩容节点。
模型继续变大,我们以 AI 推理机为原点,继续增加设备。
上下文继续变长,或希望从 IQ1 提高到更高量化精度,我们用 4090、四卡 A4000 Server 为 AI 推理机扩充系统主存和 GPU 显存。不需要丢弃原推理机,为更强推理机重新支付高昂费用。
如果未来出现了更小、更强的模型,PRIMA 集群可以随时缩容,解放我们的笔记本和台式机,毕竟这些设备也不是为了本地 AI 而购买的。
当我们需要 1M 甚至更长上下文、更高并发时,又可以再次唤醒这些设备。
从“这台设备能不能跑”到“这台设备能贡献什么”
PRIMA 正在让“未来最值得买哪一台 AI 电脑?”变得没那么重要。
过去,我们评估本地 AI 硬件时,经常问:“这台设备还能不能跑这个模型?” 如果不能,这台已经支付了高沉没成本的机器将被尘封。
PRIMA 旨在把这个问题换成:这台设备还能为我的 AI 提供什么? 也许它无法独立运行 Hy4 preview, 但它有一张 GPU;也许 GPU 不强,但它有 16GB 显存和 32GB 内存; 也许 CPU 很旧,但它有一块高速 NVMe SSD。也许它什么都不是旗舰,但几台这样的设备放在一起,就可能支撑一件任何单台设备都做不到的事情。
对于家庭和个人 AI 来说,这比追求某一次 benchmark 中的极限 TPS 更重要。因为:
现实世界中的用户侧计算资源,本来就是异构的, 而且它们已经在我们身边。本地 AI 缺少的,只是整合这些异构资源的能力。
它可能很慢,但慢有慢的应用场景,我们可以通过扩容尽量提速它。
它可能不聪明,但现实世界大部分真实任务,其实不需要那么聪明,我们通过扩容把它变得更聪明,就足够了。
PRIMA + Hy4 preview 770B 是一次成功的压力测试,它没有创造本地 AI 吞吐的奇迹,但它证明了单设备 0.37 TPS 不是我零成本部署的极限,而两设备 1.5 TPS 也不是性能的终点。
那么,下一台设备加入之后,这个边界会在哪里?
这正是 PRIMA 接下来想继续回答的问题。
1 Installation and run guide: 部署与运行教程: Inside the PRIMA Hy4 Preview 770B Experiment: How We Ran It Across Two Machines. 解密 PRIMA:如何在两台异构设备上运行 Hy4 Preview 770B。
A shared runtime
for the lab.
Turn mixed CPU and CUDA machines into a single inference service.
Edge intelligence,
kept close.
Serve apps and agents from infrastructure you control, near the work and the data.
One runtime.
Many devices.
Continuous inference.
Tokens move across assigned CPU and GPU resources. Membership changes are applied between requests.
- Active token flow
- Standby path
- Node joining
- Node leaving
Explain how transformers work.
Collaborate across
locations. On hardware
you control.
Coordinate inference over operator-provided reachable networks while execution stays on operator-controlled devices.
Choose a model, testbed, and prompt, then replay real measurements side by side: laptop only, GPU server only, and both devices with PRIMA.
Useful AI capacity
is already around you.
Build from compatible hardware that has already been purchased.
Use what you have.
Laptops, desktops, mini PCs and consumer GPUs become useful capacity.
Keep data local.
Prompts and model execution stay on infrastructure you control.
Resilient collaboration.
Eligible devices can join, leave and recover at controlled boundaries.
Evidence you can inspect
Built in the open.
Measured on real hardware.
- ICLR
2026 - Published evaluation
- 80+
- GitHub stars
- MIT
- Licensed
- 674ms / token
- 70B TPOT · four-device home testbed
- <6%
- 70B · per-device memory overhead
Additional large-model and MoE evaluations are underway. Results will be published with reproducible artifacts when they are ready.
Published results depend on the cited model, quantization, hardware, networking and workload; they are not universal performance claims.
Start with Prima.cpp
Build private intelligence
where your data lives.
Open source. Self-hosted. Built for heterogeneous hardware.
git clone https://github.com/OpenCPIL/prima.cpp
Read the ICLR 2026 paper