Metadata-Version: 2.4
Name: llmfit-local
Version: 0.1.0
Summary: Zero-dependency CLI that inspects your CPU, RAM, and GPU/VRAM to recommend local open-weight LLMs and quantization levels.
Author: Staggerlee60
License: MIT
Project-URL: Homepage, https://github.com/staggerlee60/llmfit-local
Project-URL: Repository, https://github.com/staggerlee60/llmfit-local
Project-URL: Issues, https://github.com/staggerlee60/llmfit-local/issues
Keywords: llm,ollama,gguf,onnx,quantization,vram,local-ai,cli
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Utilities
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Dynamic: license-file

# llmfit-local

[![CI](https://github.com/staggerlee60/llmfit-local/actions/workflows/ci.yml/badge.svg)](https://github.com/staggerlee60/llmfit-local/actions/workflows/ci.yml)
[![PyPI](https://shields.io)](https://pypi.org/project/llmfit-local/)
[![Python 3.10+](https://shields.io)](https://python.org)
[![License: MIT](https://shields.io)](LICENSE)
[![Platform: Windows | macOS | Linux](https://shields.io)](#cross-platform-support)

A zero-dependency CLI tool that inspects your local CPU, RAM, GPU/VRAM, and free disk space to recommend open-weight LLMs and quantization levels (`FP16`, `Q8_0`, `Q5_K_M`, `Q4_K_M`, and `ONNX INT4`) that fit your machine—complete with MoE-aware speed estimates (`tok/s`), Hugging Face repo inspection, local Ollama audits, and `Modelfile` generation.

## Quick Demo

```console
\$ llmfit --use-case coding
System:   Windows (AMD64) | 16 CPU cores
Memory:   32.0 GB RAM | Free Disk: 145.2 GB
GPU:      NVIDIA GeForce RTX 4070 (12.0 GB VRAM)
--------------------------------------------------------------------------------------------
Model                   Quant        Est. Mem   Fit        Speed          Run Command
--------------------------------------------------------------------------------------------
Qwen 3 8B               Q8_0          10.1 GB   GPU_FULL   37-63 tok/s    ollama run qwen3:8b
Qwen 2.5 Coder 7B       Q8_0           9.4 GB   GPU_FULL   40-68 tok/s    ollama run qwen2.5-coder:7b
DeepSeek-R1 Distill 8B  Q8_0           9.9 GB   GPU_FULL   38-65 tok/s    ollama run deepseek-r1:8b
Qwen 3 4B               Q8_0           5.3 GB   GPU_FULL   76-130 tok/s   ollama run qwen3:4b
Phi-4 Mini 3.8B         Q8_0           5.0 GB   GPU_FULL   80-137 tok/s   ollama run phi4-mini:3.8b
Qwen 3 32B              Q4_K_M        23.4 GB   HYBRID     10-16 tok/s    ollama run qwen3:32b
Qwen 2.5 Coder 32B      Q4_K_M        23.4 GB   HYBRID     10-16 tok/s    ollama run qwen2.5-coder:32b
Qwen 3 30B-A3B (MoE)    Q4_K_M        21.8 GB   HYBRID     34-63 tok/s    ollama run qwen3:30b-a3b
```

```console
\$ llmfit --hf Qwen/Qwen3-32B --context 16384
Hardware:    32.0 GB RAM | GPU: NVIDIA GeForce RTX 4070 (12.0 GB VRAM)
HF Model:    Qwen/Qwen3-32B (32.76B params via safetensors metadata)
Context:     16,384 tokens
----------------------------------------------------------------
Quantization   Est. Mem     Fit          Est. Speed
----------------------------------------------------------------
FP16            72.3 GB     TOO_LARGE    N/A
Q8_0            41.6 GB     TOO_LARGE    N/A
Q5_K_M          30.1 GB     HYBRID       10-16 tok/s
Q4_K_M          26.4 GB     HYBRID       10-16 tok/s
```

## Features
- **Automatic Hardware Detection:** Probes system RAM, CPU cores, free disk space, NVIDIA GPUs (`nvidia-smi`), AMD ROCm GPUs (`rocm-smi`), Windows discrete GPUs, and Apple Silicon unified memory using only the Python standard library.
- **26+ Curated Dense & MoE Models:** Includes Qwen 3, Gemma 3, Phi-4, DeepSeek-R1 Distill, Devstral Small 24B, Mistral Small 3.2 24B, Llama 3.1/3.2/3.3, Qwen 3 30B-A3B (MoE), and Mixtral 8x7B (MoE).
- **MoE-Aware Speed & Fit Tiers:** Categorizes models into `GPU_FULL`, `HYBRID` (GPU + RAM offload), or `CPU_ONLY` while scaling `tok/s` estimates from active parameters (`active_params_b`) for Mixture-of-Experts architectures.
- **Hugging Face Repo Lookup (`--hf`):** Fetches parameter metadata directly from Hugging Face (`llmfit --hf Qwen/Qwen3-32B`) and evaluates `FP16`, `Q8_0`, `Q5_K_M`, and `Q4_K_M` against your hardware.
- **Custom Model Sizing (`--params`, `--active-params`, `--context`):** Evaluate any arbitrary dense or MoE model size and context length before downloading.
- **Local Ollama Audit (`--check-ollama`) & `Modelfile` Export (`--modelfile`):** Audits installed `ollama list` models against detected VRAM/RAM or prints a ready-to-save `Modelfile` configuring `PARAMETER num_ctx`.
- **GGUF / Ollama & ONNX Modes:** Outputs `ollama run` commands by default, or `olive run --model` ONNX INT4 recommendations with `--onnx`.

## Cross-Platform Support

`llmfit-local` runs natively on **Windows, macOS, and Linux** with zero third-party dependencies:
- **Windows:** Uses `GlobalMemoryStatusEx` via `ctypes` for physical RAM detection, plus `nvidia-smi` and Windows video controller queries for GPU VRAM.
- **macOS:** Detects Apple Silicon (`arm64`) unified memory and budgets GPU allocation automatically.
- **Linux:** Reads POSIX `sysconf` memory pages alongside `nvidia-smi` and `rocm-smi` GPU telemetry.

## Installation

```bash
# Run directly without installing
uvx llmfit-local

# Or install via pip
pip install llmfit-local
```

## Usage

```bash
# Detect local hardware and recommend top models
llmfit

# Filter for coding models that fit 100% in GPU VRAM
llmfit --use-case coding --fit gpu

# Inspect any Hugging Face model repo directly
llmfit --hf Qwen/Qwen3-32B

# Evaluate a custom MoE model (30.5B total, 3.3B active parameters) at 16k context
llmfit --params 30.5 --active-params 3.3 --context 16384

# Audit your locally installed Ollama models against detected VRAM/RAM
llmfit --check-ollama

# Generate an Ollama Modelfile with a 32k context window for your top fitting model
llmfit --modelfile --context 32768

# Recommend ONNX INT4 models instead of GGUF / Ollama
llmfit --onnx

# Simulate a 24 GB VRAM workstation
llmfit --ram 64 --vram 24

# Output structured JSON for scripts
llmfit --format json
```

## Running Tests

```bash
pytest -v
```

## License

MIT
