Spaces:
Running
Running
Aaryan Parik
fix: harden HF Space Docker runtime, session isolation, hardware profiles, and tests
0a7b128 |
Download setup_arm_inference.md from SnippyCodes/Libratio: direct link, hf CLI and curl.
- Browser
- Download file 2.95 kB
-
https://huggingface.co/spaces/SnippyCodes/Libratio/resolve/main/setup_arm_inference.md
- Command line
-
hf download hf://spaces/SnippyCodes/Libratio/setup_arm_inference.md
-
curl -L -o setup_arm_inference.md https://huggingface.co/spaces/SnippyCodes/Libratio/resolve/main/setup_arm_inference.md
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: | |
| ```bash | |
| 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: | |
| ```bash | |
| 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: | |
| * **Phi-3-mini-4k-instruct-q4 (recommended):** [HuggingFace GGUF Page](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct-gguf) | |
| * **Llama-3-8B-Instruct-Q4_K_M:** [HuggingFace GGUF Page](https://huggingface.co/QuantFactory/Meta-Llama-3-8B-Instruct-GGUF) | |
| 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: | |
| ```env | |
| # 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: | |
| ```bash | |
| python test_local_inference.py | |
| ``` | |
| To run a live precision assignment episode using the local engine, start the server and run the inference loop: | |
| ```bash | |
| # 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! | |