llmfit-local 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Staggerlee60
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,141 @@
1
+ Metadata-Version: 2.4
2
+ Name: llmfit-local
3
+ Version: 0.1.0
4
+ Summary: Zero-dependency CLI that inspects your CPU, RAM, and GPU/VRAM to recommend local open-weight LLMs and quantization levels.
5
+ Author: Staggerlee60
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/staggerlee60/llmfit-local
8
+ Project-URL: Repository, https://github.com/staggerlee60/llmfit-local
9
+ Project-URL: Issues, https://github.com/staggerlee60/llmfit-local/issues
10
+ Keywords: llm,ollama,gguf,onnx,quantization,vram,local-ai,cli
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Programming Language :: Python :: 3.15
23
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
24
+ Classifier: Topic :: Utilities
25
+ Requires-Python: >=3.10
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Provides-Extra: dev
29
+ Requires-Dist: pytest>=8.0; extra == "dev"
30
+ Dynamic: license-file
31
+
32
+ # llmfit-local
33
+
34
+ [![CI](https://github.com/staggerlee60/llmfit-local/actions/workflows/ci.yml/badge.svg)](https://github.com/staggerlee60/llmfit-local/actions/workflows/ci.yml)
35
+ [![PyPI](https://shields.io)](https://pypi.org/project/llmfit-local/)
36
+ [![Python 3.10+](https://shields.io)](https://python.org)
37
+ [![License: MIT](https://shields.io)](LICENSE)
38
+ [![Platform: Windows | macOS | Linux](https://shields.io)](#cross-platform-support)
39
+
40
+ 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.
41
+
42
+ ## Quick Demo
43
+
44
+ ```console
45
+ \$ llmfit --use-case coding
46
+ System: Windows (AMD64) | 16 CPU cores
47
+ Memory: 32.0 GB RAM | Free Disk: 145.2 GB
48
+ GPU: NVIDIA GeForce RTX 4070 (12.0 GB VRAM)
49
+ --------------------------------------------------------------------------------------------
50
+ Model Quant Est. Mem Fit Speed Run Command
51
+ --------------------------------------------------------------------------------------------
52
+ Qwen 3 8B Q8_0 10.1 GB GPU_FULL 37-63 tok/s ollama run qwen3:8b
53
+ Qwen 2.5 Coder 7B Q8_0 9.4 GB GPU_FULL 40-68 tok/s ollama run qwen2.5-coder:7b
54
+ DeepSeek-R1 Distill 8B Q8_0 9.9 GB GPU_FULL 38-65 tok/s ollama run deepseek-r1:8b
55
+ Qwen 3 4B Q8_0 5.3 GB GPU_FULL 76-130 tok/s ollama run qwen3:4b
56
+ Phi-4 Mini 3.8B Q8_0 5.0 GB GPU_FULL 80-137 tok/s ollama run phi4-mini:3.8b
57
+ Qwen 3 32B Q4_K_M 23.4 GB HYBRID 10-16 tok/s ollama run qwen3:32b
58
+ Qwen 2.5 Coder 32B Q4_K_M 23.4 GB HYBRID 10-16 tok/s ollama run qwen2.5-coder:32b
59
+ Qwen 3 30B-A3B (MoE) Q4_K_M 21.8 GB HYBRID 34-63 tok/s ollama run qwen3:30b-a3b
60
+ ```
61
+
62
+ ```console
63
+ \$ llmfit --hf Qwen/Qwen3-32B --context 16384
64
+ Hardware: 32.0 GB RAM | GPU: NVIDIA GeForce RTX 4070 (12.0 GB VRAM)
65
+ HF Model: Qwen/Qwen3-32B (32.76B params via safetensors metadata)
66
+ Context: 16,384 tokens
67
+ ----------------------------------------------------------------
68
+ Quantization Est. Mem Fit Est. Speed
69
+ ----------------------------------------------------------------
70
+ FP16 72.3 GB TOO_LARGE N/A
71
+ Q8_0 41.6 GB TOO_LARGE N/A
72
+ Q5_K_M 30.1 GB HYBRID 10-16 tok/s
73
+ Q4_K_M 26.4 GB HYBRID 10-16 tok/s
74
+ ```
75
+
76
+ ## Features
77
+ - **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.
78
+ - **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).
79
+ - **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.
80
+ - **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.
81
+ - **Custom Model Sizing (`--params`, `--active-params`, `--context`):** Evaluate any arbitrary dense or MoE model size and context length before downloading.
82
+ - **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`.
83
+ - **GGUF / Ollama & ONNX Modes:** Outputs `ollama run` commands by default, or `olive run --model` ONNX INT4 recommendations with `--onnx`.
84
+
85
+ ## Cross-Platform Support
86
+
87
+ `llmfit-local` runs natively on **Windows, macOS, and Linux** with zero third-party dependencies:
88
+ - **Windows:** Uses `GlobalMemoryStatusEx` via `ctypes` for physical RAM detection, plus `nvidia-smi` and Windows video controller queries for GPU VRAM.
89
+ - **macOS:** Detects Apple Silicon (`arm64`) unified memory and budgets GPU allocation automatically.
90
+ - **Linux:** Reads POSIX `sysconf` memory pages alongside `nvidia-smi` and `rocm-smi` GPU telemetry.
91
+
92
+ ## Installation
93
+
94
+ ```bash
95
+ # Run directly without installing
96
+ uvx llmfit-local
97
+
98
+ # Or install via pip
99
+ pip install llmfit-local
100
+ ```
101
+
102
+ ## Usage
103
+
104
+ ```bash
105
+ # Detect local hardware and recommend top models
106
+ llmfit
107
+
108
+ # Filter for coding models that fit 100% in GPU VRAM
109
+ llmfit --use-case coding --fit gpu
110
+
111
+ # Inspect any Hugging Face model repo directly
112
+ llmfit --hf Qwen/Qwen3-32B
113
+
114
+ # Evaluate a custom MoE model (30.5B total, 3.3B active parameters) at 16k context
115
+ llmfit --params 30.5 --active-params 3.3 --context 16384
116
+
117
+ # Audit your locally installed Ollama models against detected VRAM/RAM
118
+ llmfit --check-ollama
119
+
120
+ # Generate an Ollama Modelfile with a 32k context window for your top fitting model
121
+ llmfit --modelfile --context 32768
122
+
123
+ # Recommend ONNX INT4 models instead of GGUF / Ollama
124
+ llmfit --onnx
125
+
126
+ # Simulate a 24 GB VRAM workstation
127
+ llmfit --ram 64 --vram 24
128
+
129
+ # Output structured JSON for scripts
130
+ llmfit --format json
131
+ ```
132
+
133
+ ## Running Tests
134
+
135
+ ```bash
136
+ pytest -v
137
+ ```
138
+
139
+ ## License
140
+
141
+ MIT
@@ -0,0 +1,110 @@
1
+ # llmfit-local
2
+
3
+ [![CI](https://github.com/staggerlee60/llmfit-local/actions/workflows/ci.yml/badge.svg)](https://github.com/staggerlee60/llmfit-local/actions/workflows/ci.yml)
4
+ [![PyPI](https://shields.io)](https://pypi.org/project/llmfit-local/)
5
+ [![Python 3.10+](https://shields.io)](https://python.org)
6
+ [![License: MIT](https://shields.io)](LICENSE)
7
+ [![Platform: Windows | macOS | Linux](https://shields.io)](#cross-platform-support)
8
+
9
+ 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.
10
+
11
+ ## Quick Demo
12
+
13
+ ```console
14
+ \$ llmfit --use-case coding
15
+ System: Windows (AMD64) | 16 CPU cores
16
+ Memory: 32.0 GB RAM | Free Disk: 145.2 GB
17
+ GPU: NVIDIA GeForce RTX 4070 (12.0 GB VRAM)
18
+ --------------------------------------------------------------------------------------------
19
+ Model Quant Est. Mem Fit Speed Run Command
20
+ --------------------------------------------------------------------------------------------
21
+ Qwen 3 8B Q8_0 10.1 GB GPU_FULL 37-63 tok/s ollama run qwen3:8b
22
+ Qwen 2.5 Coder 7B Q8_0 9.4 GB GPU_FULL 40-68 tok/s ollama run qwen2.5-coder:7b
23
+ DeepSeek-R1 Distill 8B Q8_0 9.9 GB GPU_FULL 38-65 tok/s ollama run deepseek-r1:8b
24
+ Qwen 3 4B Q8_0 5.3 GB GPU_FULL 76-130 tok/s ollama run qwen3:4b
25
+ Phi-4 Mini 3.8B Q8_0 5.0 GB GPU_FULL 80-137 tok/s ollama run phi4-mini:3.8b
26
+ Qwen 3 32B Q4_K_M 23.4 GB HYBRID 10-16 tok/s ollama run qwen3:32b
27
+ Qwen 2.5 Coder 32B Q4_K_M 23.4 GB HYBRID 10-16 tok/s ollama run qwen2.5-coder:32b
28
+ Qwen 3 30B-A3B (MoE) Q4_K_M 21.8 GB HYBRID 34-63 tok/s ollama run qwen3:30b-a3b
29
+ ```
30
+
31
+ ```console
32
+ \$ llmfit --hf Qwen/Qwen3-32B --context 16384
33
+ Hardware: 32.0 GB RAM | GPU: NVIDIA GeForce RTX 4070 (12.0 GB VRAM)
34
+ HF Model: Qwen/Qwen3-32B (32.76B params via safetensors metadata)
35
+ Context: 16,384 tokens
36
+ ----------------------------------------------------------------
37
+ Quantization Est. Mem Fit Est. Speed
38
+ ----------------------------------------------------------------
39
+ FP16 72.3 GB TOO_LARGE N/A
40
+ Q8_0 41.6 GB TOO_LARGE N/A
41
+ Q5_K_M 30.1 GB HYBRID 10-16 tok/s
42
+ Q4_K_M 26.4 GB HYBRID 10-16 tok/s
43
+ ```
44
+
45
+ ## Features
46
+ - **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.
47
+ - **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).
48
+ - **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.
49
+ - **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.
50
+ - **Custom Model Sizing (`--params`, `--active-params`, `--context`):** Evaluate any arbitrary dense or MoE model size and context length before downloading.
51
+ - **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`.
52
+ - **GGUF / Ollama & ONNX Modes:** Outputs `ollama run` commands by default, or `olive run --model` ONNX INT4 recommendations with `--onnx`.
53
+
54
+ ## Cross-Platform Support
55
+
56
+ `llmfit-local` runs natively on **Windows, macOS, and Linux** with zero third-party dependencies:
57
+ - **Windows:** Uses `GlobalMemoryStatusEx` via `ctypes` for physical RAM detection, plus `nvidia-smi` and Windows video controller queries for GPU VRAM.
58
+ - **macOS:** Detects Apple Silicon (`arm64`) unified memory and budgets GPU allocation automatically.
59
+ - **Linux:** Reads POSIX `sysconf` memory pages alongside `nvidia-smi` and `rocm-smi` GPU telemetry.
60
+
61
+ ## Installation
62
+
63
+ ```bash
64
+ # Run directly without installing
65
+ uvx llmfit-local
66
+
67
+ # Or install via pip
68
+ pip install llmfit-local
69
+ ```
70
+
71
+ ## Usage
72
+
73
+ ```bash
74
+ # Detect local hardware and recommend top models
75
+ llmfit
76
+
77
+ # Filter for coding models that fit 100% in GPU VRAM
78
+ llmfit --use-case coding --fit gpu
79
+
80
+ # Inspect any Hugging Face model repo directly
81
+ llmfit --hf Qwen/Qwen3-32B
82
+
83
+ # Evaluate a custom MoE model (30.5B total, 3.3B active parameters) at 16k context
84
+ llmfit --params 30.5 --active-params 3.3 --context 16384
85
+
86
+ # Audit your locally installed Ollama models against detected VRAM/RAM
87
+ llmfit --check-ollama
88
+
89
+ # Generate an Ollama Modelfile with a 32k context window for your top fitting model
90
+ llmfit --modelfile --context 32768
91
+
92
+ # Recommend ONNX INT4 models instead of GGUF / Ollama
93
+ llmfit --onnx
94
+
95
+ # Simulate a 24 GB VRAM workstation
96
+ llmfit --ram 64 --vram 24
97
+
98
+ # Output structured JSON for scripts
99
+ llmfit --format json
100
+ ```
101
+
102
+ ## Running Tests
103
+
104
+ ```bash
105
+ pytest -v
106
+ ```
107
+
108
+ ## License
109
+
110
+ MIT
@@ -0,0 +1,45 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "llmfit-local"
7
+ version = "0.1.0"
8
+ description = "Zero-dependency CLI that inspects your CPU, RAM, and GPU/VRAM to recommend local open-weight LLMs and quantization levels."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = { text = "MIT" }
12
+ authors = [{ name = "Staggerlee60" }]
13
+ keywords = ["llm", "ollama", "gguf", "onnx", "quantization", "vram", "local-ai", "cli"]
14
+ classifiers = [
15
+ "Development Status :: 4 - Beta",
16
+ "Environment :: Console",
17
+ "Intended Audience :: Developers",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Operating System :: OS Independent",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Programming Language :: Python :: 3.13",
25
+ "Programming Language :: Python :: 3.14",
26
+ "Programming Language :: Python :: 3.15",
27
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
28
+ "Topic :: Utilities",
29
+ ]
30
+ dependencies = []
31
+
32
+ [project.optional-dependencies]
33
+ dev = ["pytest>=8.0"]
34
+
35
+ [project.urls]
36
+ Homepage = "https://github.com/staggerlee60/llmfit-local"
37
+ Repository = "https://github.com/staggerlee60/llmfit-local"
38
+ Issues = "https://github.com/staggerlee60/llmfit-local/issues"
39
+
40
+ [project.scripts]
41
+ llmfit = "llmfit_local.cli:main"
42
+ llmfit-local = "llmfit_local.cli:main"
43
+
44
+ [tool.setuptools.packages.find]
45
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,8 @@
1
+ from importlib.metadata import PackageNotFoundError, version
2
+
3
+ try:
4
+ __version__ = version("llmfit-local")
5
+ except PackageNotFoundError:
6
+ __version__ = "0.1.0"
7
+
8
+ __all__ = ["__version__"]
@@ -0,0 +1,227 @@
1
+ import argparse
2
+ from dataclasses import asdict
3
+ import json
4
+ import sys
5
+ from . import __version__
6
+ from .hardware import detect_hardware
7
+ from .models import (
8
+ audit_ollama_models,
9
+ evaluate_custom_model,
10
+ fetch_hf_model_info,
11
+ format_ollama_modelfile,
12
+ recommend_models,
13
+ )
14
+
15
+
16
+ def main() -> int:
17
+ parser = argparse.ArgumentParser(
18
+ prog="llmfit",
19
+ description="Inspect local hardware and recommend open-weight LLMs and quantizations that fit.",
20
+ )
21
+ parser.add_argument(
22
+ "-V",
23
+ "--version",
24
+ action="version",
25
+ version=f"%(prog)s {__version__}",
26
+ )
27
+ parser.add_argument(
28
+ "--use-case",
29
+ choices=["general", "coding", "reasoning", "chat", "fast"],
30
+ help="Filter recommendations by workload type.",
31
+ )
32
+ parser.add_argument(
33
+ "--fit",
34
+ choices=["gpu", "hybrid", "cpu"],
35
+ help="Only show models matching a specific fit tier (gpu, hybrid, or cpu).",
36
+ )
37
+ parser.add_argument(
38
+ "--onnx",
39
+ action="store_true",
40
+ help="Recommend ONNX INT4 models instead of GGUF / Ollama models.",
41
+ )
42
+ parser.add_argument(
43
+ "--params",
44
+ type=float,
45
+ help="Evaluate a custom model size in billions of parameters (e.g. --params 22).",
46
+ )
47
+ parser.add_argument(
48
+ "--active-params",
49
+ type=float,
50
+ help="Active parameters per token in billions for MoE models (e.g. --active-params 3.3).",
51
+ )
52
+ parser.add_argument(
53
+ "--hf",
54
+ type=str,
55
+ help="Inspect a Hugging Face model repo ID (e.g. --hf Qwen/Qwen3-32B).",
56
+ )
57
+ parser.add_argument(
58
+ "--context",
59
+ type=int,
60
+ default=8192,
61
+ help="Target context window in tokens (default: 8192).",
62
+ )
63
+ parser.add_argument(
64
+ "--modelfile",
65
+ action="store_true",
66
+ help="Print a ready-to-use Ollama Modelfile configuring num_ctx for the top fitting model.",
67
+ )
68
+ parser.add_argument(
69
+ "--check-ollama",
70
+ action="store_true",
71
+ help="Audit locally installed Ollama models against detected hardware.",
72
+ )
73
+ parser.add_argument(
74
+ "--ram",
75
+ type=float,
76
+ help="Override detected system RAM in GB (e.g. --ram 32).",
77
+ )
78
+ parser.add_argument(
79
+ "--vram",
80
+ type=float,
81
+ help="Override detected GPU VRAM in GB (e.g. --vram 16).",
82
+ )
83
+ parser.add_argument(
84
+ "--limit",
85
+ type=int,
86
+ default=8,
87
+ help="Maximum number of model recommendations to display (default: 8).",
88
+ )
89
+ parser.add_argument(
90
+ "--format",
91
+ choices=["text", "json"],
92
+ default="text",
93
+ help="Output format (default: text).",
94
+ )
95
+ args = parser.parse_args()
96
+
97
+ hw = detect_hardware(ram_override_gb=args.ram, vram_override_gb=args.vram)
98
+
99
+ if args.check_ollama:
100
+ audit = audit_ollama_models(hw)
101
+ if audit is None:
102
+ print("Error: 'ollama' CLI not found or not running.", file=sys.stderr)
103
+ return 2
104
+ if args.format == "json":
105
+ print(json.dumps({"hardware": asdict(hw), "ollama_models": [asdict(a) for a in audit]}, indent=2))
106
+ return 0
107
+ if not audit:
108
+ print("No local Ollama models found (run `ollama pull <model>` first).")
109
+ return 0
110
+ print(f"{'Installed Model':<28} {'Disk':<9} {'Fit':<10} {'Assessment'}")
111
+ print("-" * 78)
112
+ for item in audit:
113
+ print(f"{item.name:<28} {item.size_gb:>5.1f} GB {item.fit_tier:<10} {item.note}")
114
+ return 0
115
+
116
+ if args.hf:
117
+ hf_info = fetch_hf_model_info(args.hf)
118
+ if hf_info is None:
119
+ print(
120
+ f"Error: Could not resolve parameter count for Hugging Face repo '{args.hf}'. "
121
+ "Check the repo ID or pass --params <B> directly.",
122
+ file=sys.stderr,
123
+ )
124
+ return 2
125
+ custom_fits = evaluate_custom_model(
126
+ hf_info.params_b,
127
+ hw,
128
+ context_tokens=args.context,
129
+ active_params_b=args.active_params,
130
+ )
131
+ if args.format == "json":
132
+ print(json.dumps({
133
+ "hardware": asdict(hw),
134
+ "huggingface_repo": hf_info.repo_id,
135
+ "params_b": hf_info.params_b,
136
+ "parameter_source": hf_info.source,
137
+ "context_tokens": args.context,
138
+ "quantizations": [asdict(c) for c in custom_fits],
139
+ }, indent=2))
140
+ return 0
141
+ gpu_label = f"{hw.gpu_name} ({hw.vram_gb:.1f} GB VRAM)" if hw.gpu_name else "None detected (CPU mode)"
142
+ print(f"Hardware: {hw.ram_gb:.1f} GB RAM | GPU: {gpu_label}")
143
+ print(f"HF Model: {hf_info.repo_id} ({hf_info.params_b:g}B params via {hf_info.source})")
144
+ print(f"Context: {args.context:,} tokens")
145
+ print("-" * 64)
146
+ print(f"{'Quantization':<14} {'Est. Mem':<12} {'Fit':<12} {'Est. Speed'}")
147
+ print("-" * 64)
148
+ for c in custom_fits:
149
+ print(f"{c.quantization:<14} {c.required_gb:>5.1f} GB {c.fit_tier:<12} {c.est_tok_per_sec}")
150
+ return 0
151
+
152
+ if args.params is not None:
153
+ custom_fits = evaluate_custom_model(
154
+ args.params,
155
+ hw,
156
+ context_tokens=args.context,
157
+ active_params_b=args.active_params,
158
+ )
159
+ if args.format == "json":
160
+ print(json.dumps({
161
+ "hardware": asdict(hw),
162
+ "params_b": args.params,
163
+ "active_params_b": args.active_params,
164
+ "context_tokens": args.context,
165
+ "quantizations": [asdict(c) for c in custom_fits],
166
+ }, indent=2))
167
+ return 0
168
+ gpu_label = f"{hw.gpu_name} ({hw.vram_gb:.1f} GB VRAM)" if hw.gpu_name else "None detected (CPU mode)"
169
+ active_note = f" ({args.active_params:g}B active MoE)" if args.active_params else ""
170
+ print(f"Hardware: {hw.ram_gb:.1f} GB RAM | GPU: {gpu_label}")
171
+ print(f"Custom Model: {args.params:g}B parameters{active_note} @ {args.context:,} context tokens")
172
+ print("-" * 64)
173
+ print(f"{'Quantization':<14} {'Est. Mem':<12} {'Fit':<12} {'Est. Speed'}")
174
+ print("-" * 64)
175
+ for c in custom_fits:
176
+ print(f"{c.quantization:<14} {c.required_gb:>5.1f} GB {c.fit_tier:<12} {c.est_tok_per_sec}")
177
+ return 0
178
+
179
+ recs = recommend_models(
180
+ hw,
181
+ use_case=args.use_case,
182
+ onnx_mode=args.onnx,
183
+ context_tokens=args.context,
184
+ fit_filter=args.fit,
185
+ limit=args.limit,
186
+ )
187
+
188
+ if args.modelfile:
189
+ if not recs:
190
+ print("No fitting catalog model found to generate a Modelfile.", file=sys.stderr)
191
+ return 1
192
+ print(format_ollama_modelfile(recs[0].ollama_tag, context_tokens=args.context))
193
+ return 0
194
+
195
+ if args.format == "json":
196
+ payload = {
197
+ "hardware": asdict(hw),
198
+ "context_tokens": args.context,
199
+ "recommendations": [asdict(r) for r in recs],
200
+ }
201
+ print(json.dumps(payload, indent=2))
202
+ return 0
203
+
204
+ gpu_label = f"{hw.gpu_name} ({hw.vram_gb:.1f} GB VRAM)" if hw.gpu_name else "None detected (CPU mode)"
205
+ print(f"System: {hw.os_name} ({hw.arch}) | {hw.cpu_cores} CPU cores")
206
+ print(f"Memory: {hw.ram_gb:.1f} GB RAM | Free Disk: {hw.free_disk_gb:.1f} GB")
207
+ print(f"GPU: {gpu_label}")
208
+ print("-" * 92)
209
+
210
+ if not recs:
211
+ print("No catalog models fit within current memory limits. Try a smaller quantization or --ram/--vram override.")
212
+ return 1
213
+
214
+ print(f"{'Model':<23} {'Quant':<12} {'Est. Mem':<10} {'Fit':<10} {'Speed':<14} {'Run Command'}")
215
+ print("-" * 92)
216
+ for r in recs:
217
+ warn = " [!disk]" if r.disk_warning else ""
218
+ print(
219
+ f"{r.model:<23} {r.quantization:<12} {r.required_gb:>5.1f} GB "
220
+ f"{r.fit_tier:<10} {r.est_tok_per_sec:<14} {r.runtime_cmd}{warn}"
221
+ )
222
+
223
+ return 0
224
+
225
+
226
+ if __name__ == "__main__":
227
+ raise SystemExit(main())