Skip to content
Proyek

Tentang

Honest local LLM deployment planning and benchmarking for high unified-memory Macs and future Linux/NVIDIA rigs.

AI dan pembelajaran mesin

Cara angka ini diukur

Pertumbuhan bintang terukur

dalam 24 jam
0
dalam 7 hari
0
dalam 15 hari
0
dalam 1 bulan
Mengumpulkan riwayat

Perubahan bersih pada periode yang tumpang tindih, bukan total harian. Pengukuran yang belum tersedia dibiarkan kosong. Bintang menunjukkan perhatian, bukan kualitas.

README.md

Asli

local-llm-lab

Can my 128GB Mac run this 600B model?

local-llm-lab gives you the uncomfortable answer before you waste a weekend downloading weights.

python3 -m local_llm_lab plan \
  --params 600B \
  --quant Q4_K_M \
  --ctx 32768 \
  --hardware fixture:apple-m4-max-128gb
VERDICT: DOES-NOT-FIT  risk=extreme  confidence=demo
Model: custom-600b (600B, dense)
Hardware: Mock Apple Silicon Max-class 128GB | memory=128 GiB | available=110 GiB
Backend: llama.cpp | Quantization: Q4_K_M
Weights: 325 GiB
KV cache: 32.0 GiB
Runtime required: 377 GiB
Available runtime memory: 110 GiB
Margin: -267 GiB
Estimated decode: 0.18-0.38 tokens/s
Recommended quantization: no-safe-local-quant
Downgrade options:
  - No supported quantization fits safely at this context on this hardware.
  - Consider remote inference, hybrid/offloaded inference, or a smaller distilled model.
  - For 600B+ models, avoid local-only deployment unless you have measured headroom.

It is a lightweight CLI for local LLM planning, dry-run deployment, benchmarking, stress simulation, and report generation. It is built for developers with 64GB, 128GB, 192GB, and 256GB unified-memory machines, especially Apple Silicon Max/Ultra users, with Linux + NVIDIA support as a future expansion path.

What it does

  • Detect local hardware: OS, CPU/GPU, unified memory/VRAM, disk, Metal/CUDA/AVX/NEON, backend binaries.
  • Save measured hardware profiles and reuse them in later planning runs.
  • Plan whether a model fits: weights, KV cache, overhead, OS reserve, margin, verdict, risk, backend, quantization.
  • Recommend the best local run plan across quantization, context, and backend options.
  • Deploy without downloading huge models: generate llama.cpp, MLX, and Ollama dry-run scripts/configs with a preflight runbook.
  • Benchmark with deterministic mock data or tiny local smoke checks.
  • Stress-test resource contention with reproducible LLM + Blender/GPU-style simulations.
  • Report in Markdown, JSON, SVG charts, and static HTML.
  • Serve reports locally with a localhost-only Web viewer.

Install

Run from source without installing:

git clone https://github.com/duongngocbinh56599-ui/local-llm-lab.git
cd local-llm-lab
python3 -m local_llm_lab --help

Install editable:

python3 -m pip install -e .
local-llm-lab --help

Optional enhancements:

python3 -m pip install -e ".[ui]"      # Rich terminal tables
python3 -m pip install -e ".[detect]"  # psutil-assisted telemetry
python3 -m pip install -e ".[charts]"  # matplotlib chart exports
python3 -m pip install -e ".[all]"

The core CLI has no required third-party dependencies.

Quick demo

Create demo data and browse all local reports:

python3 -m local_llm_lab demo --out examples
python3 -m local_llm_lab recommend --model llama-3.3-70b --hardware fixture:apple-m4-max-128gb
python3 -m local_llm_lab serve --dir sample_reports --port 8787

Then open http://127.0.0.1:8787/. If the directory contains multiple report folders, serve opens a local Report Hub. If it points at one report folder, it serves that report directly.

Commands

detect

python3 -m local_llm_lab detect
python3 -m local_llm_lab detect --json --skip-probes
python3 -m local_llm_lab detect --hardware fixture:apple-m4-ultra-256gb
python3 -m local_llm_lab detect --save-profile my-mac

Hardware detection redacts sensitive identifiers. It does not write serial numbers, hardware UUIDs, account names, tokens, or credentials.

Measured profiles are saved only when you ask for it:

python3 -m local_llm_lab list profiles
python3 -m local_llm_lab profile show my-mac --json
python3 -m local_llm_lab plan --params 120B --quant Q4_K_M --ctx 16384 --hardware profile:my-mac

Profiles live under .local-llm-lab/profiles/ by default and are ignored by Git. Backend paths are reduced to found/not found so your local username and filesystem layout are not copied into reports.

plan

Use --model for curated presets:

python3 -m local_llm_lab plan --model llama-3.3-70b --quant Q4_K_M --ctx 8192

Use --params for unknown, private, future, or hypothetical models:

python3 -m local_llm_lab plan --params 120B --quant Q5_K_M --ctx 16384
python3 -m local_llm_lab plan --params 600B --quant Q4_K_M --ctx 32768 --hardware fixture:apple-m4-max-128gb

Override architecture details when you know them:

python3 -m local_llm_lab plan \
  --params 200B \
  --layers 112 \
  --heads 96 \
  --kv-heads 12 \
  --head-dim 128 \
  --quant Q4_K_M \
  --ctx 16384

compare

Compare quantization, context length, and backend tradeoffs in one run:

python3 -m local_llm_lab compare \
  --model llama-3.3-70b \
  --quants Q6_K,Q5_K_M,Q4_K_M,Q3_K_M \
  --contexts 4096,8192,16384,32768 \
  --hardware fixture:apple-m4-max-128gb \
  --out sample_reports/compare-llama70b

This writes:

  • compare.json
  • compare.md
  • index.html
  • SVG charts for decode throughput and positive memory margin

Use it before deploy when you want the best safe compromise instead of testing one setting at a time. The HTML report includes local-only filters, sorting, best-candidate highlighting, and copyable dry-run deploy commands.

recommend

Ask local-llm-lab to scan a matrix and pick the best next action:

python3 -m local_llm_lab recommend \
  --model llama-3.3-70b \
  --hardware fixture:apple-m4-max-128gb

python3 -m local_llm_lab recommend \
  --params 600B \
  --hardware fixture:apple-m4-max-128gb \
  --target tight \
  --json

recommend returns one clear status: recommended when the target can be met, or no-fit when no scanned candidate is safe enough. It includes the selected backend, quantization, context length, risk, memory margin, estimated decode speed, alternatives, downgrade options, and a copyable deploy dry-run command.

deploy

python3 -m local_llm_lab deploy \
  --model llama-3.3-70b \
  --quant Q4_K_M \
  --ctx 8192 \
  --out .local-llm-lab/deploy/llama70b

This writes:

  • local-llm-lab-plan.json
  • README.md
  • preflight.sh
  • run-llama-cpp.sh
  • run-mlx.sh
  • Modelfile
  • run-ollama.sh

It does not download model weights. Run ./preflight.sh before launching a real backend; it checks the model path, recommended backend, verdict/risk, and obvious configuration problems.

bench

python3 -m local_llm_lab bench --mock --model llama-3.3-70b --quant Q4_K_M --ctx 8192
python3 -m local_llm_lab bench --mock --output examples/bench.json

Mock mode is deterministic demo data. Real backend benchmark support will expand in v0.2.

stress

python3 -m local_llm_lab stress --model llama-3.3-70b --quant Q4_K_M --ctx 8192

v0.1 simulates LLM inference competing with viewport rendering, Blender preview, and generic GPU pressure. It is safe by default and does not launch heavy GPU workloads.

report

python3 -m local_llm_lab report --input examples/demo-run.json --out sample_reports/demo
python3 -m local_llm_lab serve --dir sample_reports/demo --port 8787
python3 -m local_llm_lab serve --dir sample_reports --port 8787

Reports include Markdown, JSON, static HTML, a decision-first summary, memory waterfall SVG, and benchmark/stress charts. If matplotlib is installed, PNG charts are added. Serving a parent directory opens a local Report Hub that indexes report and compare folders without external assets or network services.

Model presets

Curated v0.1 presets include:

  • Llama: llama-3.1-8b, llama-3.3-70b, llama-3.1-405b
  • Qwen: qwen2.5-32b, qwen2.5-72b, qwen3-235b-a22b
  • DeepSeek: deepseek-v3-671b-a37b
  • Mixtral: mixtral-8x7b, mixtral-8x22b
  • Gemma: gemma-3-27b
  • Phi: phi-4-14b
  • Generic planning profiles: generic-70b, generic-120b, generic-200b, generic-400b, generic-600b

List them:

python3 -m local_llm_lab list models

Hardware fixtures

Fixtures are illustrative demo profiles, not measured machines:

python3 -m local_llm_lab list hardware

They let anyone reproduce 64GB/128GB/192GB/256GB unified-memory reports without owning those machines.

Estimation model

local-llm-lab uses explicit, inspectable formulas:

weights = params * quant_effective_bytes_per_param * format_overhead
kv_cache = ctx * concurrency * layers * kv_heads * head_dim * 2(K,V) * kv_dtype_bytes
runtime_required = weights + kv_cache + activation + backend_overhead
total_required = runtime_required + os_reserve

These are estimates. Backend kernels, model architecture, tokenizer behavior, prompt shape, thermal state, and memory pressure can move real results. The CLI labels low-confidence inputs and recommends validation benchmarks.

Roadmap

v0.1:

  • Honest planning for --model and --params
  • Compare matrices for quantization/context/backend tradeoffs
  • One-command recommendations from scanned planning matrices
  • Dry-run deploy generation for llama.cpp, MLX, Ollama with preflight runbooks
  • Mock bench/stress data
  • Structured Markdown/JSON/SVG/HTML reports with decision summaries and memory waterfall charts
  • Local report server and Report Hub

v0.2:

  • Real backend adapters for llama.cpp, Ollama, MLX
  • Better Linux + NVIDIA detection through nvidia-smi
  • Backend-specific context/batch/offload planning
  • Community benchmark fixture submissions
  • Optional Web panel controls

License

MIT

Jelajahi proyek terkait

Memuat…