Text Generation
GGUF
llama.cpp
pocketpal
on-device
Mixture of Experts
multilingual
quantization
distillation
1-bit
2-bit
3-bit
conversational
Instructions to use RegalInvader/Marco-Nano-Instruct-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use RegalInvader/Marco-Nano-Instruct-GGUF with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf RegalInvader/Marco-Nano-Instruct-GGUF:TQ1_0 # Run inference directly in the terminal: llama cli -hf RegalInvader/Marco-Nano-Instruct-GGUF:TQ1_0
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf RegalInvader/Marco-Nano-Instruct-GGUF:TQ1_0 # Run inference directly in the terminal: llama cli -hf RegalInvader/Marco-Nano-Instruct-GGUF:TQ1_0
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf RegalInvader/Marco-Nano-Instruct-GGUF:TQ1_0 # Run inference directly in the terminal: ./build/bin/llama cli -hf RegalInvader/Marco-Nano-Instruct-GGUF:TQ1_0
Use Docker
docker model run hf.co/RegalInvader/Marco-Nano-Instruct-GGUF:TQ1_0
- Llama new
- LM Studio
- Jan
- vLLM
How to use RegalInvader/Marco-Nano-Instruct-GGUF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "RegalInvader/Marco-Nano-Instruct-GGUF" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "RegalInvader/Marco-Nano-Instruct-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/RegalInvader/Marco-Nano-Instruct-GGUF:TQ1_0
- Ollama
How to use RegalInvader/Marco-Nano-Instruct-GGUF with Ollama:
ollama run hf.co/RegalInvader/Marco-Nano-Instruct-GGUF:TQ1_0
- Unsloth Desktop
- Pi
How to use RegalInvader/Marco-Nano-Instruct-GGUF with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf RegalInvader/Marco-Nano-Instruct-GGUF:TQ1_0
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "RegalInvader/Marco-Nano-Instruct-GGUF:TQ1_0" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use RegalInvader/Marco-Nano-Instruct-GGUF with Docker Model Runner:
docker model run hf.co/RegalInvader/Marco-Nano-Instruct-GGUF:TQ1_0
- Lemonade
How to use RegalInvader/Marco-Nano-Instruct-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull RegalInvader/Marco-Nano-Instruct-GGUF:TQ1_0
Run and chat with the model
lemonade run user.Marco-Nano-Instruct-GGUF-TQ1_0
List all available models
lemonade list
- Hermes Agent
How to use RegalInvader/Marco-Nano-Instruct-GGUF with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf RegalInvader/Marco-Nano-Instruct-GGUF:TQ1_0
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default RegalInvader/Marco-Nano-Instruct-GGUF:TQ1_0
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use RegalInvader/Marco-Nano-Instruct-GGUF with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf RegalInvader/Marco-Nano-Instruct-GGUF:TQ1_0
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "RegalInvader/Marco-Nano-Instruct-GGUF:TQ1_0" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
File size: 5,477 Bytes
e5235fb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | #!/usr/bin/env python3
"""D-57 · the teacher's routed experts quantised by our own trainer grids (round-to-nearest with the trainer's scale
search, no training) and written as a GGUF: the QAT starting point, measured in llama.cpp beside its own PTQ files.
python scripts/rtn_gguf.py --method iq4xs --out teacher-ours-iq4xs-rtn.gguf
python scripts/rtn_gguf.py --ckpt runs/<run>/full_N/state.pt --method int2 --down-method iq4nl --out x.gguf
With --ckpt, a trained student instead: its fp32 expert latents re-quantised (gate/up with --method, the down
projection with --down-method, default the method's own) and its trained attention and norms; the frozen router
and embedding are the teacher's. The checkpoint's torchao optimiser state is skipped (gen has no torchao).
Experts go through `quant.ternary.export_packed` with `model.student.proj_spec` (so the down projection gets its
32-block grid), everything else is written as the teacher holds it (bf16; norms and the router f32), in the template
GGUF's tensor order; `export.gguf.check_round_trip` then confirms the GGUF dequantises to the packed weights.
"""
from __future__ import annotations
import argparse
import json
import sys
from pathlib import Path
import torch
from safetensors import safe_open
REPO = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO / "src"))
from lowbit.export.gguf import check_round_trip, gguf_module, student_tensors, write_gguf # noqa: E402
from lowbit.model.student import proj_spec # noqa: E402
from lowbit.quant.importance import load as load_importance # noqa: E402
from lowbit.quant.ternary import GRIDS, METHODS, QuantSpec, export_packed # noqa: E402
TEACHER = Path("/path/to/data/models/Marco-Nano-Instruct")
TEMPLATE = Path("/path/to/data/ptq/teacher-bf16.gguf")
LLAMA = Path("/path/to/llama.cpp")
def load_ckpt(path: str) -> dict:
"""torch.load of a full checkpoint with torchao's optimiser classes replaced by inert stubs."""
import pickle
import types
class StubT(torch.Tensor):
@classmethod
def __torch_dispatch__(cls, func, types_, args=(), kwargs=None):
raise RuntimeError("optimiser-state stub")
def __setstate__(self, st):
pass
class StubO:
def __init__(self, *a, **k):
pass
def __setstate__(self, st):
pass
class U(pickle.Unpickler):
def find_class(self, mod, name):
if mod.startswith("torchao"):
return StubT if ("Tensor" in name or "State" in name or "Optim" in name) else StubO
return super().find_class(mod, name)
pm = types.SimpleNamespace(Unpickler=U, load=pickle.load, __name__="pickle")
return torch.load(path, map_location="cpu", mmap=True, weights_only=False, pickle_module=pm)
def main() -> None:
p = argparse.ArgumentParser()
p.add_argument("--method", required=True, choices=METHODS)
p.add_argument("--out", required=True)
p.add_argument("--ckpt", help="a full checkpoint's state.pt: re-quantise its trained latents")
p.add_argument("--down-method", choices=METHODS)
p.add_argument("--importance", help="D-57 quant.importance safetensors: weight the scale search")
p.add_argument("--dense-as", choices=["bf16", "q8_0"], default="bf16",
help="attention and embedding: bf16, or q8_0 (the phone build)")
a = p.parse_args()
gguf = gguf_module(LLAMA)
def mk(m: str) -> QuantSpec:
return QuantSpec(method=m, group_size=GRIDS[m].group if m in GRIDS else 128)
spec = mk(a.method)
down_spec = mk(a.down_method) if a.down_method else proj_spec(spec, "down")
params = load_ckpt(a.ckpt)["params"] if a.ckpt else {}
imp = load_importance(a.importance) if a.importance else {}
cfg = json.loads((TEACHER / "config.json").read_text())
wmap = json.loads((TEACHER / "model.safetensors.index.json").read_text())["weight_map"]
files = {f: safe_open(TEACHER / f, "pt") for f in set(wmap.values())}
def get(name: str) -> torch.Tensor:
return files[wmap[name]].get_tensor(name)
dense, packed = {}, {}
for name in wmap:
if ".mlp.experts." not in name:
dense[name] = params[name] if name in params else get(name)
for i in range(cfg["num_hidden_layers"]):
pre = f"model.layers.{i}.mlp.experts"
n = cfg["num_experts"]
if params:
gate_up, down = params[f"{pre}.gate_up_latent"], params[f"{pre}.down_latent"]
else:
gate = torch.stack([get(f"{pre}.{e}.gate_proj.weight") for e in range(n)])
up = torch.stack([get(f"{pre}.{e}.up_proj.weight") for e in range(n)])
down = torch.stack([get(f"{pre}.{e}.down_proj.weight") for e in range(n)])
gate_up = torch.cat([gate, up], 1)
packed[f"{pre}.gate_up_proj"] = export_packed(gate_up.float(), proj_spec(spec, "gate_up"),
importance=imp.get(f"layers.{i}.gate_up"))
packed[f"{pre}.down_proj"] = export_packed(down.float(), down_spec, importance=imp.get(f"layers.{i}.down"))
print(f"layer {i} quantised", flush=True)
info = write_gguf(TEMPLATE, a.out, student_tensors(dense, packed, gguf, dense_as=a.dense_as), gguf)
rt = check_round_trip(a.out, packed, gguf)
print(json.dumps({**info, "bit_exact": rt["bit_exact"], "mismatched": rt["mismatched_tensors"][:3]}, indent=1))
if __name__ == "__main__":
main()
|