Remote language model devices
Keep the application on one computer and explicitly run native inference on a trusted worker with separate memory and verified model caching.
ImplementedAner 0.1.0 or newerStable 0.0.9 includes the explicitly connected native LLM worker introduced
in 0.0.9-dev.5. Computer 2 runs the Aner program, model management and aner.api
listener. Computer 1 runs aner-llm-worker, the complete native inference engine,
the model weights and its one fitted context on the selected CPU/GPU. Computer 2
can have a smaller GPU or no GPU.
The optional persistent cache of verified model weights introduced in
0.0.9-dev.6 is also included in stable 0.0.9. Existing configurations retain session only behavior;
choose cache_policy: "persistent" explicitly to reuse model bytes after
disconnecting or restarting the controller. The cache does not retain prompts,
generated text or KV state.
This first implementation is an aner.llm execution backend. It does not turn a
remote GPU into an aner.nn Tensor device, split layers across these computers,
pool their RAM, or use numerical cluster workers. CPU layers offloaded by the
worker execute on computer 1 and use computer 1's RAM. See local memory
placement for the existing CPU/GPU budget contract.
Prepare both computers
Obtain compatible controller and worker executables built from the same reviewed native implementation and pinned inference backend. Confirm package and backend availability in Downloads; the editor does not install a worker or CUDA. A matching version label alone is insufficient. The worker must include the selected CPU/GPU backend and its dependencies; controller GPU memory is not used for its model.
The worker command is aner-llm-worker --stdio. Aner launches it through the explicitly configured absolute path over SSH. It opens no public worker socket. An administrator must install the approved worker and enroll its SSH account, authentication key and host key before connecting. Aner uses noninteractive SSH with strict known host checks and never silently accepts a new key. Trust the worker: it receives the model bytes, prompts and generated text.
Create an explicit connection configuration
Copy the configuration template to a private
file such as private.remote-worker.json and replace the placeholders:
{
"schema": "aner.llm.remote/1",
"id": "Atlas-01",
"transport": "ssh",
"endpoint": "aner@gpu-worker.example",
"executable": "/opt/aner/bin/aner-llm-worker",
"device": "cuda:0",
"cache_policy": "persistent",
"timeout_ms": 120000,
"upload_timeout_ms": 600000
}id is the logical worker alias used in diagnostics. endpoint is your enrolled
SSH target, not an inference URL. executable is the approved absolute portable
POSIX path on computer 1. This SSH command route targets a POSIX worker
installation; native Windows SSH launch paths are outside this first route.
device selects one worker cuda:N device (for example cuda:0) or metal;
explicit cpu is also available for validation. An unavailable device fails.
timeout_ms and upload_timeout_ms are optional operation deadlines in
milliseconds, defaulting to 120000 and 600000 respectively, with a maximum of
3600000. They do not make a running GPU kernel preemptible.
cache_policy is optional: "session" is the default and does not retain model
files beyond their session staging lifetime; "persistent" enables the private
worker cache described below. The example opts into persistence. Persistent
caching currently requires a POSIX worker; Windows workers reject that policy
explicitly. Controller and worker must use compatible controller and worker builds.
Optional SSH fields are port (1..65535, default 22), identity_file and known_hosts_file.
The enrollment files must already exist as absolute regular nonsymlink files.
Their paths admit only ASCII letters, digits, underscore, period, slash, colon,
hyphen and backslash. Spaces, quotes, percent expansion and tilde syntax are
rejected so SSH reads literal enrollment files. Specify port explicitly when
your enrolled target uses a nondefault port.
These fields select previously prepared credentials/host-key records; they do
not create keys, alter enrollment or weaken strict host verification.
The configuration is a bounded UTF-8 JSON regular file, at most 64 KiB, with no
leaf symlink and no unknown fields. Keep endpoint and installation details in
the private configuration rather than public reports. One connection is active
per controller process; disconnect it before selecting another worker. The
returned remote:<id>/<device> selector is valid for that connection's lifetime;
it is not a general network URL or durable handle across worker restarts.
Connect, plan and load
import aner.llm
let device = llm.remote_connect("private.remote-worker.json")
print(device)
print(llm.devices())
print(llm.plan("models/local-instruct-q4.gguf", context: 2048,
device: device, kv_cache_type: "f16", flash_attention: "auto",
gpu_budget_mib: 7168, ram_budget_mib: 24576, reserve_mib: 512))
let model = llm.load_fitted("models/local-instruct-q4.gguf", context: 2048,
device: device, kv_cache_type: "f16", flash_attention: "auto",
gpu_budget_mib: 7168, ram_budget_mib: 24576, reserve_mib: 512)
let answer = model.generate("Explain the experiment.", max_tokens: 128)
print(answer.text())
model.close()
llm.remote_disconnect(device)remote_connect executes the connection handshake and returns the normalized
selector. llm.devices() includes the registered remote device; it does not
perform network discovery. Local auto selection does not opt into remote
execution. Pass the returned selector explicitly to plan and load_fitted.
Ordinary llm.load retains its local loading contract.
The model path names a compatible single file GGUF on computer 2. The controller verifies its identity. With persistent caching enabled, the worker first checks for that exact artifact in its private cache. A verified hit reuses those bytes without uploading the GGUF again. A miss uploads the model once, verifies it on the worker and publishes the verified cache entry. Session policy uploads to private temporary staging instead. The same admitted hash can be reused by plan/load calls during that connection.
Both policies load from a private ephemeral staging file. The worker removes
that staged file after validated resident loading; persistent policy additionally
keeps its verified cache entry. Orderly cleanup removes temporary staging data.
Abrupt termination or power loss can leave private temporary data requiring
operator cleanup. A connection still admits one artifact and one fixed loaded
profile; selecting another requires disconnect/reconnect. The transfer limit
remains 512 GiB, distinct from llm.fetch_artifact's existing 16 GiB download
limit. Disk space, transfer time and supported architecture still apply.
Persistent model weight cache
The worker selects its cache root from its own environment, in this order:
ANER_LLM_CACHE_DIR, when explicitly set.$XDG_CACHE_HOME/aner/llm/models, whenXDG_CACHE_HOMEis set.$HOME/.cache/aner/llm/modelsotherwise.
These are worker side absolute paths, not controller configuration fields.
The cache directory must be owned by the worker user and private (0700);
artifact files are private (0600) regular files, with no symlinks. Committed
entries use the full lowercase SHA256 as <sha256>.gguf. The cache stores GGUF
weight artifacts only; prompt, output and KV caching are separate concepts and
are not enabled by this policy. Choose "session" when persistent model file
retention is unwanted.
Every hit verifies exact byte count and the complete file SHA256 while copying
to private staging before admission. A filename, size or modification timestamp
alone is not a verified hit. New uploads are published atomically only after
successful content verification, with file and directory synchronization.
Corrupt or incomplete data cannot be reported as hit_verified.
The worker environment variable ANER_LLM_CACHE_MAX_MIB sets the retention
budget: default 65536 MiB (64 GiB), range 1..524288 MiB. There are at most 1024
committed entries. Admission also preserves 512 MiB of available disk headroom
and requires temporary staging capacity; a hit still creates a full local copy.
There is no automatic eviction in this increment. Capacity failures require
explicit operator action or a different policy/budget. Entries remain until a
local operator purges them. Stop workers using the cache before manually
removing unneeded recognized .gguf entries; no purge RPC or new worker command
is introduced here.
Persistent cache admission takes one nonblocking lock for the cache root.
Concurrent admission reports cache_busy promptly. Retry explicitly after the
first admission finishes, using disconnect/reconnect as described below;
requests are not automatically replayed. This lock
does not merge model contexts or change the single context inference contract.
Cache errors invalidate the current connection. Disconnect it, resolve the reported condition, then connect and request admission again:
| Error | Explicit recovery |
|---|---|
cache_busy | Wait for the other admission to finish, then disconnect/reconnect. |
cache_full | With workers stopped, free cache space, raise the worker quota or select session policy. |
cache_unsafe | Correct the worker cache path, ownership or permissions. |
cache_unsupported | Select session policy on the unsupported worker platform. |
cache_io | Resolve the worker disk/I/O failure before reconnecting. |
Plan, load and memory diagnostics expose an artifact_cache receipt:
| Field | Meaning |
|---|---|
policy | persistent or session |
status | hit_verified, miss_uploaded or session_uploaded |
sha256, artifact_bytes | Exact admitted model identity and size |
upload_bytes, upload_chunks | Model payload actually transmitted in this connection |
verified_bytes, verified | Artifact verification accounting and successful verification outcome |
A completed verified reconnect hit reports hit_verified, verified: true,
upload_bytes: 0 and upload_chunks: 0. Zero uploaded model bytes does not mean
zero disk reads or zero network traffic: checksum/copy work and SSH control
messages remain. The receipt excludes SSH/framing overhead, unrelated disk IO
and later model loader verification passes. It contains no cache filesystem
paths. Inspect actual receipts rather than assuming a hit merely because
persistence was requested.
Planning and actual fitted allocation execute on computer 1. Its GPU budget, host RAM budget and reserve use the same MiB meanings as local fitted loading. Computer 2's RAM/VRAM is not added to those capacities. The controller retains application/transport buffers; model weights, KV, compute workspace, rendering, tokenization, inference and sampling stay on the worker. All explicit device, precision, context and model compatibility checks remain active; no failure selects a different device or model silently.
Like local fitted loading, the remote profile admits one resident execution context. Stateless API worker leases share the connection and serialize requests. Sessions, new context pools, optimizers, sampling profile builders, adapters and continuous batching builders cannot expand this fixed profile. Per request output, temperature and seed remain explicit. Model metadata and diagnostics identify the remote execution and worker side accounting; they do not report controller RAM as worker allocation or establish peak process RSS. Remote inventory is retained from the handshake. Model memory diagnostics use the worker snapshot from loading or the last completed response; reading these cached records does not send a new request.
Keep the application and HTTP API on computer 2
The complete server example connects the
worker, prints the plan, loads and warms up the model, then registers that
LLMModel with the usual api.llm builder. Its loopback HTTP listener is on
computer 2. The remote GPU worker opens no public API socket.
After preparing the private configuration and model path, use the matching controller runtime:
aner check examples/llm_remote_server.aner
aner run examples/llm_remote_server.anerChecking validates source without connecting, uploading or loading weights. Running performs the explicit connection and artifact cache check or upload. API authentication/TLS, output limits and request deadlines retain their ordinary contracts. Requests cannot change the preloaded device, model or SSH configuration.
curl http://127.0.0.1:11435/chat \
-H 'Content-Type: application/json' \
-d '{"prompt":"Explain quantization simply.","max_tokens":128,"temperature":0.0}'Failure and lifetime
model.close() closes that controller lease; it does not disconnect the worker
connection. Call llm.remote_disconnect(device) to end its ownership, invalidate
all associated leases and tear down the worker. Normal controller process exit
also releases its owned connection resources; closing a notebook model lease
alone does not end this process wide connection.
Cancellation, timeout, protocol failure, transport loss or explicit disconnect poisons the entire connection and its model leases. Do not retry a generation implicitly: the worker may have executed part of it. A partially delivered stream is incomplete; it is not replayed and does not become a successful response. Disconnect, reconnect and reload explicitly before accepting new work. Native device cancellation is cooperative; kernels drain before their resources can be released safely. No local CPU/GPU or service provider fallback is performed. With persistent policy, reconnect can reuse a fully verified retained weight artifact. Model/context allocation still runs again; a disk cache hit is not a resident GPU model or conversation state resume. Session policy requires another upload after disconnect.
Validation scope
The explicit transport: "local" mode starts a separate process on the same machine. It validates the worker protocol and does not establish two computer execution or network speed. The GPU correctness qualification records a separate local worker and loopback API check on one L40; it does not establish WAN performance, a smaller physical GPU, multi GPU inference or model quality.
See the Language model connections module reference for the shared API.