A GPU fallback policy lets Hivenet Router send a new inference request to a backup replica when the preferred replica is ineligible. In this Hivenet Router test, an NVIDIA H100 and an NVIDIA A100 both serve the same chat model. You change the Router threshold for video memory (VRAM) use, send the same chat three times, and match each request to a replica in the audit log. Both GPUs keep running throughout the test.
This walkthrough uses Router v0.1.8 and two local vLLM replicas. The three outcomes below are expected results from the documented policy behavior. We have not run this experiment on a two-GPU deployment. It tests which replica receives a request. Measuring speed or cost would require a separate workload.
For each new request, Router checks the primary policy first. If the H100 passes its memory threshold and the other eligibility checks, Router can send it the request. If the memory reading excludes the H100, Router evaluates the A100 fallback step. The client keeps the same API endpoint and model ID. On the next request, Router starts with the primary policy again. This is why restoring the threshold makes a useful third check. See the local fallback chain reference.
Use a quiet test deployment with one Router and exactly two healthy agents serving the same concrete chat model. For this test, assign one GPU to each replica and give each engine its own agent. Record the two peer IDs. The audit log identifies the agent, so this one-to-one mapping is what lets you identify a GPU tier from a request. Keep both replicas in the shared pool and use the same inference key for all three checks. If you need to register the agents first, follow the two-replica vLLM setup.
In the examples, the preferred agent is registered as NVIDIA H100 and the backup as NVIDIA A100. Substitute your actual GPU labels. Router matches the registered strings exactly, including capitalization. If you set a label explicitly, use the agent’s --gpu-model option. Both engines must have enough memory to serve the test model independently.
Use Bash, curl, and jq. Set ROUTER_URL to the test Router’s HTTPS base URL without /v1 and MODEL_ID to the model ID shared by both agents. Load ADMIN_KEY and INFERENCE_KEY from your usual credential store. Use the admin credential to inspect the routing table and the inference credential to send chat requests.
snapshot() {
curl -fsS -H "Authorization: Bearer $ADMIN_KEY" \
"${ROUTER_URL%/}/admin/routing-table" |
jq --arg model "$MODEL_ID" '.agents[]
| select(.metadata.model == $model and .metadata.engine == "vllm")
| {peer_id, gpu_model: .metadata.gpu_model,
healthy: .status.healthy, backend_healthy: .status.backend_healthy,
sample_time: .hardware.timestamp, gpus: .hardware.gpu}'
}
snapshotWrite down the peer ID beside each GPU label. Check that both agents and backends are healthy. For the preferred agent, divide vram_used_bytes by vram_total_bytes for each reported GPU and take the highest fraction. For example, 64 GiB used out of 80 GiB gives 0.80. This is device memory used by all allocations, including model weights. It differs from the fraction of vLLM’s KV cache occupied by requests.
Before each chat, check the hardware sample time. If the reading predates the test conditions, wait for a fresh sample. If the GPU list is missing or empty, or a device reports zero total bytes, pause here. A healthy agent can report CPU and host memory while GPU telemetry is unavailable. Router skips the GPU gate when there is no GPU sample. Check what devices the agent can see and whether NVIDIA’s management library, NVML, is available. See the v0.1.8 hardware metrics reference.
Use a single global policy file on the test Router. Start it with --policy-file pointing to that file, with no policy directory or model-specific policy. Use a test key without an external fallback provider and leave provider fallback out of the policy. That way an external service cannot supply the successful response you expect from a local agent. Save a copy of the test deployment’s previous policy so you can restore it afterward. The example below uses 0.90 as a starting threshold. Choose a value above the preferred GPU’s current reading, with enough margin for ordinary variation.
routing_policy:
match:
engine: vllm
gpu_model: "NVIDIA H100"
exclude_if:
gpu_vram_used_percent:
gt: 0.90
strategy: least-loaded
fallback_chain:
- name: a100-backup
match:
engine: vllm
gpu_model: "NVIDIA A100"
strategy: least-loadedThe primary step selects eligible H100 agents and excludes one when its highest reported VRAM fraction is strictly greater than the threshold. For this field, 0.90 means 90%. With one agent in each tier, excluding the H100 leaves the local A100 as the next candidate. The backup step has its own GPU match and no VRAM threshold in this example. It still needs a healthy, available agent serving the requested model. See the hardware-aware routing reference.
You can trigger this fallback without filling GPU memory or causing an out-of-memory error. For example, at a stable 0.80 reading, the H100 remains eligible with gt: 0.90. Changing that value to 0.70 excludes it. In the second case, Router can exclude the H100 before it forwards the chat. The client sends that chat only once. A failed backend call and a client retry are separate events.
After each edit, send SIGHUP to the test Router process and check its log for a successful reload. An invalid edit leaves the previously active policy in use. Before each chat, check the threshold Router actually loaded by running the command below with the admin credential. See the v0.1.8 policy reload reference.
curl -fsS -H "Authorization: Bearer $ADMIN_KEY" \
"${ROUTER_URL%/}/admin/policy" |
jq -e '.routing_policy.exclude_if.gpu_vram_used_percent.gt'Define this helper once. Each call prints the response headers and body. Keep the model, prompt, credential, and endpoint fixed. A new call should produce a new Router request ID.
chat() {
jq -nc --arg model "$MODEL_ID" '{
model: $model,
messages: [{role: "user", content: "Name one color."}],
max_tokens: 8,
stream: false
}' |
curl -sS -i -H "Authorization: Bearer $INFERENCE_KEY" \
-H "Content-Type: application/json" --data-binary @- \
"${ROUTER_URL%/}/v1/chat/completions"
}After each chat completes, copy the Router’s X-Request-ID response header into REQUEST_ID. On the Router host or in its container, set AUDIT_LOG to the readable JSON Lines file. The default is /var/log/hivenet-router/audit.jsonl. Deployments can override it with HIVENET_ROUTER_AUDIT_LOG_PATH. If Router could not open the file at startup, check its standard output or your log collector for an audit event with the same request_id.
jq -ec --arg id "$REQUEST_ID" \
'select(.log_type == "audit" and .request_id == $id)
| {request_id, status_code, agent_id, error_code}' \
"$AUDIT_LOG"Record the active threshold, the preferred agent’s VRAM fraction and sample time, the HTTP status, the request ID, and the audit agent_id for each check. Compare that last value with the peer IDs you recorded before the test. The audit field reference explains how the response header and log record are connected.
Run snapshot and confirm the preferred agent’s VRAM fraction is below the active threshold. With the preferred agent healthy and idle, run chat once and look up its request ID.
Expected result: HTTP 200 and the H100 agent’s peer ID in agent_id. If the A100 already served this request, resolve that discrepancy before changing the threshold. Otherwise the second request cannot establish that the threshold caused a switch.
Lower only the primary step’s gt value to a fraction below the H100’s measured usage. For a stable 0.80 reading, 0.70 works as a test value. Leave the workload and A100 policy alone. Reload the file, confirm the lower threshold is active, run snapshot again, then run chat and look up the new request ID.
Expected result: HTTP 200 and the A100 agent’s peer ID. The H100 can still show as healthy. Its VRAM reading made it ineligible for this primary step. If telemetry is missing or another failure intervened, the backup’s ID alone cannot establish the reason it was selected.
Put back the threshold that passed in check 1. Reload the policy and confirm the preferred agent’s latest fraction is below that value. Run chat once more and find its audit record.
Expected result: HTTP 200 and the original H100 peer ID. The three distinct request IDs should now map to H100, A100, and H100 in that order. After recording the results, restore the deployment’s pre-test policy and confirm the reload.
Use the request audit record to identify the replica. HTTP 200 confirms that a chat completed, and either GPU can generate the same answer. The routing table connects the recorded peer ID to a GPU tier. To attribute a switch to the VRAM rule, keep the active threshold and the preferred agent’s reading alongside each request ID. A busy or unavailable primary can also send a request down the fallback path.
For an overview across requests, compare hivenet_policy_primary_routed_total and hivenet_policy_fallback_routed_total for the test model over the same interval. Other clients can move those counters. Use the individual audit records when you need to answer which GPU handled one chat. See the routing metrics reference.
The preferred GPU handled all three requests. Inspect the active threshold, its units, and the reported devices. A reading equal to gt passes. GPU values are sampled, so use a clear margin between the reading and the threshold. A label in the routing table identifies a tier even when the GPU reading itself is missing.
The backup handled the first or last request. Compare the policy labels with the current registrations, then check the preferred agent’s health, eligibility, and available capacity. If the agent restarted during the test, read its current peer ID before interpreting an older mapping.
The client received an error or the audit record is missing. Record the HTTP status, response error code, and request ID. Check whether a matching backup was available and whether you are reading the log for the Router that received the request. A response without a matching audit record leaves the serving GPU unverified. The Router troubleshooting guide walks through that investigation.
Pick one AI, compute, or storage workload and see the difference for yourself. Spin it up in minutes, or let our team map your fastest path to production.