Serve a model within memory budgets
Plan weights, context and workspace, validate a fitted load and serve through one shared context.
// Requires a compatible installed runtime with the selected native capabilities.
// Replace the GGUF path and budgets for the actual machine. Budgets use MiB.
// Auto selects a supported local device; CPU-only builds use host RAM.
import aner.llm
import aner.api
print(llm.devices())
print(llm.plan("models/local-instruct-q4.gguf", context: 2048,
device: "auto", kv_cache_type: "f16", flash_attention: "auto",
gpu_budget_mib: 7168, ram_budget_mib: 24576, reserve_mib: 512))
// Load recomputes admission against the current machine and validates allocation.
let serving = llm.load_fitted("models/local-instruct-q4.gguf", context: 2048,
device: "auto", kv_cache_type: "f16", flash_attention: "auto",
gpu_budget_mib: 7168, ram_budget_mib: 24576, reserve_mib: 512)
let warmup = serving.generate("Say hello.", max_tokens: 1)
print(warmup.text())
print(serving.load_summary())
print(serving.memory_summary())
let app = api.app("Aner fitted chat").llm(path: "/chat", model: serving)
.bind(host: "127.0.0.1", port: 11435)
.limits(max_rows: 64, timeout_ms: 120000)
.output_limit(max_tokens: 128)
app.serve()
serving.close()
Make it your experiment.
Use Aner 0.1.0 or newer. Save this program as examples/llm_fitted_server.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.
aner check examples/llm_fitted_server.aner
aner run examples/llm_fitted_server.anerThe aner command must be on your PATH. Follow the installation guide if your terminal cannot find it.
Requires Aner 0.1.0 or newer. Requires Aner 0.0.9 or newer. Requires a matching native inference runtime and a separately supplied compatible local GGUF model. Checking loads no model and opens no listener or connection. Running loads weights, performs a short warmup and serves on loopback until stopped. Adjust context and budgets to the actual machine.
aner check examples/llm_fitted_server.aner
aner run examples/llm_fitted_server.anerClient construction and syntax checking send no inference request. Running this program calls its explicit model service. Inspect the returned finish reason and reported usage; unavailable token counts remain unknown and usage does not verify charges.
Read token accounting and provider requirements