Spaces:
Running

Libratio / setup_arm_inference.md
Aaryan Parik
fix: harden HF Space Docker runtime, session isolation, hardware profiles, and tests
0a7b128
|
Raw History Blame Contribute Delete
2.95 kB

Setting Up Local Arm64 Inference Engine with ARM NEON Acceleration

This guide explains how to configure Libratio Fleet to run its multi-agent optimization and predictive SRE loops locally on Arm64 CPU hardware (such as local Apple Silicon, Raspberry Pi, or AWS Graviton instances) using llama.cpp and ARM NEON acceleration.


📋 Prerequisites

  • An Arm64 compatible CPU (Apple M-series, AWS Graviton, Raspberry Pi 4/5, or Snapdragon Windows Arm64).
  • C/C++ compiler toolchain (GCC / Clang) installed on the host system to build llama.cpp.

🛠️ Step-by-Step Installation

1. Compile llama-cpp-python with ARM NEON Vector Instructions

To enable ARM NEON hardware acceleration, compile llama-cpp-python from source. Specify the native C compiler flags:

On macOS (Apple Silicon):

NEON acceleration is enabled by default in Apple Silicon compilers. Run:

pip install --force-reinstall --no-cache-dir llama-cpp-python

On Linux Arm64 (AWS Graviton, Raspberry Pi):

Specify the CMake flags to target NEON explicitly:

CMAKE_ARGS="-DLLAMA_NEON=ON -DLLAMA_F16C=ON -DLLAMA_AVX512=OFF" pip install --force-reinstall --no-cache-dir llama-cpp-python

2. Download a GGUF Model

Choose a lightweight model (under 8B parameters) for fast local execution. We recommend downloading from Hugging Face:

Save the downloaded .gguf file to a local path (e.g., C:\models\phi-3-mini.gguf or /home/user/models/phi-3-mini.gguf).


3. Configure Environment Variables

Create or update your .env file in the project directory to route requests to the local engine:

# Enable local inference engine routing
USE_LOCAL_ARM_ENGINE=True

# Set the path to your GGUF model file
LOCAL_MODEL_PATH="C:/models/phi-3-mini-4k-instruct-q4.gguf"

Note: If LOCAL_MODEL_PATH is left blank, or if MOCK_LOCAL_INFERENCE=True is set, the engine operates in a Mock mode—convenient for testing and CI/CD pipelines without downloading models.


🧪 Verifying the Local Engine

To verify that the engine initialized, compiled with NEON, and parsed GGUF outputs correctly, run the local unit tests:

python test_local_inference.py

To run a live precision assignment episode using the local engine, start the server and run the inference loop:

# In one terminal, start the environment server
uvicorn server.app:app --host 0.0.0.0 --port 7860

# In another terminal, run fleet inference with the local engine active
USE_LOCAL_ARM_ENGINE=True LOCAL_MODEL_PATH="C:/models/phi-3-mini.gguf" python fleet_inference.py

Check the console output for [Routing inference to Local Arm64 GGUF Engine] log messages!