Prioritizing Compute on the GB10

Hi everyone,

I am running a local LLM setup LiteLLM → Lama Swap → vLLM on my NVIDIA DGX Spark serving multiple household and home-lab applications simultaneously.

I have some vibecoding agents running with Multica AI, some System Maintenance Agents, a , A Voice pipeline / real-time chat
and sometimes heavy, long-running batch jobs (Immich Picture Library Face detection and Tagging, PDF OCR document processing, text-to-speech Audio Book preparation).

The Challenge: When a long batch task is running, real-time chat and voice queries experience noticeable Time-To-First-Token (TTFT) degradation and stuttered output.
Sometimes I have to wait over 5min for a reply. Cause the GPU is maxed out.
I want interactive tasks to immediately preempt or take priority over background batch processing.

What I’m currently looking into:

  • Is there a Priory Lane for Prompts/Tasks ? Read about X-LiteLLM-Priority
  • can the vLLM scheduling be fine-tuned (--enable-chunked-prefill, priority scheduling headers).

For those running DGX systems under mixed multi-tenant / multi-service loads:

  • How are you handling request prioritisation between interactive low-latency and bulk batch throughput?

Would love to hear real-world experiences and recommended configuration flags.

Thanks!

It’d be really cool if someone knows an advanced solution, but I’m thinking the best you could do is have the batch tasks running overnight or whenever you don’t need interactive LLM use. If that’s not possible then I think the next best option would be run everything in containers and only provision a percentage of resources to each, or similar. Am I missing something?

In for ideas. I put aux models onto my dev box with an old 8GB card and run embedding, ASR, diarization, alignment, and TTS as a mix of GPU/CPU as a work around. This is where a solo 64GB spark would make a ton of sense if they didn’t price it so ignorantly.

You’re doing a hardware version of what using containers to do the same segregation on a single Spark would achieve, except the single Spark would then have 8GB of memory and 4 CPU cores, or however many are chosen for each, less for LLMs.

very interesting topic I will have to deal with too.
I just asked the big gpt brother how he would do that.
No guarantee it works (gist) but if you could try and share your experience… :)

Only two nodes here, not your enviously huge cluster (strongly considering bumping to four though)… I’ve spilled over out of necessity, not as a tactic, but llama-swap IS containerizing each model’s deployment. When using 27B I can cram everything onto the sparks directly. That’s just not the case with glm53f. The perk is the short, bursty stuff comes through right away and avoids the scheduling headache OP is running into.

That’s overall a very clever idea, but I wonder if it’ll have the desired result or if the potential gains would get eaten up by loading/unloading or similar. Hopefully the OP can test the idea out. Part 4 in the gist is the main point.

I’d definitely think four would be worth it as long as you need the intelligence or throughput it can provide over two. With the way pricing is going my advice to anyone would be to get the most they can as long as they’re sure they can utilize it productively. Are you considering a switch or switchless?

Someone should play around with pausing a container mid-turn to free up the engine for another request like gpt brought up. One thing it didn’t mention is instead of using a priority system, use a proxy before swap where the rules are based upon endpoint.

The hop to four depends on a few things hitting which necessitate the added concurrency. I’ve built out a thorough harness so am able to actually schedule things and make the dual setup work 24/7. The question is how many dependencies get put onto the harness as their backbone. If I do bump, it’ll likely be with a switch though.

ok the LLM told me that it is possible with lite-llm

basically you set up API Keys for every priority you like.

What I am trying: I created five virtual keys in the LiteLLM UI, each with metadata: {"priority": N} and a Max Parallel Requests limit.

Key Metadata priority Max parallel Used for
P0-Realtime 100 unlimited STT and TTS
P1-Interactive 80 8 chat UIs
P2-Normal 60 4 agents
P3-Automation 40 2 scheduled jobs
P4-Background 20 1 OCR and image tagging

A FEW MOMENTS LATER…
did not work..

I let the AI sum it up for you guys. So the text from here on is AI generated.

Thanks everyone for the ideas. Here’s what I tried since the original post, including what didn’t work.

1. LiteLLM priorities (didn’t do what I hoped)
I made five virtual keys (realtime, interactive, normal, automation, background) with a priority in the key metadata and a different Max Parallel Requests limit for each. On LiteLLM 1.100.0 I found three things:

  • There is no enable_request_prioritization setting.
  • The key metadata priority is ignored by the request queue.
  • The queue reads a priority field in the request body, where lower means first. X-LiteLLM-Priority is only a response header, not something you can send.

I wrote a small pre-call hook that sets the body priority from the key. Then I read the router code: its scheduler holds a request back only when a model has no healthy deployment. With any healthy deployment, everything passes straight through. So LiteLLM can’t reorder requests under load. It does consume the priority field, so it never reaches vLLM.

2. What does help: concurrency caps per key
A background key limited to 1 or 2 parallel requests can’t take all the slots, so there’s always room for interactive traffic. It isn’t real prioritization, but it’s the part that works today.

3. What I haven’t tested yet: vLLM’s own scheduler
Every vLLM image I use has --scheduling-policy priority and a per-request priority field (lower runs first, with preemption when KV runs out). From reading the code, it can work if LiteLLM forwards the value as extra_body. I haven’t tried it yet. Open questions:

  • Does it work together with speculative decoding (DFlash/MTP)?
  • How much does batch throughput drop when background requests are preempted?

4. Things priorities won’t fix

  • llama-swap: it won’t evict a model with a request in flight, so a background request for a different model can still stall an interactive one behind a model swap.
  • llama.cpp backends: no per-request priority.
  • Separate containers: STT/TTS run as their own services and don’t go through LiteLLM.
  • SGLang: it needs its own flags and serves higher values first by default.

@jrsphd, the hardware split is the most reliable idea in this thread, and I may end up there. My constraint is that everything shares one GPU with unified memory. I’m curious about your idea of pausing containers. I haven’t looked at whether pausing a container actually frees GPU compute on the GB10, and I’d welcome anyone’s experience with that.

My plan is to try vLLM priority scheduling and measure interactive TTFT under batch load, once with the default policy and once with priority.

Ok it is done - here is how it works

the following is AI generated

Hi all,

this is a follow-up to the question in this thread: how do you keep a chat or voice request snappy while background jobs are hammering the same GB10? I tried the obvious things, hit a few walls, and ended up with a setup that works and that I can measure. Short version first, then a step-by-step guide.

Everything is open source: GitHub - mARTin-B78/dgx-spark_lite-llm_llama-swap_vllm_llama-cpp_ollama: LLM Stack for nVidia DGX Spark containing LiteLLM, LamaSwap, vLLM, Llama.cpp and ollama · GitHub (release v0.16.0, branch feat/headroom-external-canary). The relevant files are LiteLLM/priority_hook.py, LiteLLM/gpu_priority_hook.py, LiteLLM/gpu_admission.py, scripts/test-priority.sh and docs/PRIORITY.md.

The short version

What did not help

  • A priority in the LiteLLM virtual key metadata, or in the request body, does not reorder anything while your deployment is healthy. LiteLLM’s scheduler only kicks in when no deployment is available.
  • It is worse than “does nothing”: with coordination_redis enabled, a priority in the body gave me random HTTP 500s under concurrent load in LiteLLM 1.100.0. The scheduler mixes tuples and lists that come back from Redis and then cannot compare them.
  • Backend-side priority (vLLM/SGLang) orders the waiting queue, but a request that is already running is not kicked out when a more important one arrives. In the vLLM source I run, a running request is only preempted when the KV cache runs out.

What worked

  1. One LiteLLM key per app and priority level (P0 = realtime … P4 = background).
  2. A tiny hook that takes the priority only from the key (never from the client) and drops any priority the client sends.
  3. A small queue in Redis in front of the GPU: more important requests go first, and there is one extra lane that only P0 may use.
  4. Background keys (P4) can only generate 64 tokens per request, so they never hog the GPU for long.
  5. The backend has to be able to run two requests at once.

Result

Qwen3.8-27B NVFP4 with DFlash on SGLang, one GB10, 5 rounds per test:

Situation First token for P0
Idle machine 0.27 s
A 256-token background request is running, no P0 lane about 10.9 s
Same, with the P0 lane 0.35 s (p95 0.55 s)

The order was correct (P0, P1, P2, P3, P4) in every round.

Honest limits

  • Nothing is interrupted. P1 to P3 still wait for the running request. Only P0 gets the fast lane.
  • Two P0 requests at the same time use both lanes; a third P0 waits.
  • Anything that bypasses LiteLLM (direct calls to a container, STT/TTS/OCR on their own ports) is not covered unless you route it through the gate as well.
  • This is priority, not fairness: constant P0 traffic can starve the rest.

How it works

Think of a single-lane road to the GPU with one extra emergency lane. A P4 request can be generating in lane A while a P0 request starts immediately in lane B. It does not interrupt the P4 request, it just does not have to wait for it.

apps (one key per priority)
  P0 realtime ----+
  P1 chat --------+
  P2 normal ------+--> LiteLLM --> hook: priority from the key only,
  P3 automation --+                      P4 limited to 64 tokens
  P4 background --+                            |
                                               v
                       +--------------------------------------+
                       | Redis gate                           |
                       |  queue: most important first,        |
                       |         same priority = first come   |
                       |  lane A: anyone, one at a time       |
                       |  lane B: P0 only                     |
                       +------------------+-------------------+
                                          |
                                          v
                       llama-swap --> SGLang / vLLM / llama.cpp
                                      (must allow 2 requests at once)

Tutorial

0. What you need

  • LiteLLM proxy with Postgres (for virtual keys) and Redis
  • llama-swap or any OpenAI-compatible backend that can run two requests at the same time
  • a way to mount a Python file into the LiteLLM container (callbacks)

1. Create one key per app and level

Use the admin API. A higher number means more important.

curl -s -X POST http://localhost:4000/key/generate \
  -H "Authorization: Bearer $LITELLM_MASTER_KEY" \
  -H "Content-Type: application/json" \
  -d '{"key_alias":"voice-P0","metadata":{"priority":100},"max_parallel_requests":null}'

I use these five levels:

Tier metadata.priority max_parallel_requests
P0 realtime 100 none
P1 interactive 80 8
P2 normal 60 4
P3 automation 40 2
P4 background 20 2

max_parallel_requests is only a cap (extra requests get a 429). It does not do priority, but it stops one tier from filling the whole queue. Give an app only the levels it really needs, and keep the keys in a password manager.

2. The hook

This is the whole idea in one place: the priority comes from the key, the client cannot fake it, and background keys get a token limit.

# priority_hook.py  (registered as a LiteLLM callback)
import os
from litellm.integrations.custom_logger import CustomLogger

class PriorityHook(CustomLogger):
    async def async_pre_call_hook(self, user_api_key_dict, cache, data, call_type):
        # never forward it: it triggers LiteLLM's buggy scheduler
        data.pop("priority", None)

        cap = int(os.getenv("PRIORITY_BACKGROUND_MAX_TOKENS", "64"))
        meta = getattr(user_api_key_dict, "metadata", None)
        prio = meta.get("priority") if isinstance(meta, dict) else None

        # background keys only
        if cap and "messages" in data and type(prio) is int and prio <= 20:
            for f in ("max_tokens", "max_completion_tokens"):
                if type(data.get(f)) is int and data[f] > cap:
                    data[f] = cap
            if "max_tokens" not in data and "max_completion_tokens" not in data:
                data["max_tokens"] = cap
        return data

proxy_handler_instance = PriorityHook()

A shortened answer ends with finish_reason: "length", so your background job knows it should simply continue in the next request.

3. The gate (Redis)

The gate is a small piece of Python around a Lua script, so the queue and the two lanes are updated atomically, even with several LiteLLM workers. The heart of it:

-- a request may only start when it is first in the sorted queue
local first = redis.call('ZRANGE', q, 0, 0)[1]
if member ~= first then return 0 end

-- lane A
local got = redis.call('SET', active, id, 'NX', 'PX', lease_ms)
-- lane B, P0 only
if not got and p0_lane == '1' and redis.call('ZSCORE', q, member) == '0' then
  got = redis.call('SET', active_p0, id, 'NX', 'PX', lease_ms)
end

A few details that matter in real life:

  • A running request holds a lease that is renewed while the answer streams and released when it ends or the client disconnects. If a worker dies, the lease expires, so the GPU is never blocked forever.
  • The queue is limited to 128 waiting requests and one spot is kept free for P0. Too many waiting requests give a 429; a queue timeout or a Redis problem gives a 503.
  • The gate only applies to the local backends you list, so requests to remote providers do not take up the GPU lane.

The full implementation is LiteLLM/gpu_admission.py and LiteLLM/gpu_priority_hook.py.

4. Switch it on in LiteLLM

litellm_settings:
  callbacks: ["priority_hook.proxy_handler_instance", "gpu_priority_hook.proxy_handler_instance"]
general_settings:
  coordination_redis:
    host: os.environ/REDIS_HOST
    port: os.environ/REDIS_PORT

Environment variables for the LiteLLM container:

GPU_PRIORITY_ENABLED=true
GPU_PRIORITY_ENDPOINTS=llama-swap:8080
GPU_PRIORITY_P0_EXECUTION_SLOTS=1
GPU_PRIORITY_P0_RESERVED_WAITERS=1
PRIORITY_BACKGROUND_MAX_TOKENS=64
REDIS_HOST=litellm-redis
  • GPU_PRIORITY_ENDPOINTS is the host:port of your local backends, comma separated.
  • GPU_PRIORITY_P0_EXECUTION_SLOTS=0 removes the extra lane, so P0 queues like everyone else.
  • PRIORITY_BACKGROUND_MAX_TOKENS=0 removes the token cap.

Mount priority_hook.py, gpu_priority_hook.py and gpu_admission.py read-only into /app and restart LiteLLM.

5. Let the backend run two requests

Without this the second request just waits inside the backend and you are back where you started.

  • SGLang: --max-running-requests 2. I left SGLang’s own priority scheduling off, because the gate never sends more than two requests anyway.
  • vLLM: --max-num-seqs of at least 2 (many setups already use a much higher value).
  • llama.cpp: --parallel 2 (the context is split between the slots).

On a unified-memory GB10, check MemAvailable before raising concurrency on a model that already uses most of your memory.

6. Measure it

Please do not just trust the config. My probe starts one long background request and then, at the same moment, one request per tier. It prints the time to first token and the order the first tokens arrived in.

export MODEL=default
for t in P0 P1 P2 P3 P4; do read -rsp "$t key: " v; echo; export ${t}_KEY="$v"; done
scripts/test-priority.sh --rounds 5 --p0-max-ttft 5 --blocker-tier P3 --load-tokens 256

MODEL is the model name or alias you really use. My results (first token, p50 over 5 rounds):

Background request P0 P1 P4 Order
256 tokens from P4, no P0 lane 10.9 s 11.7 s 14.4 s correct
256 tokens from P3, with P0 lane 0.35 s 9.7 s 12.1 s correct
P4 asks for 256, gets cut to 64 0.35 s 1.4 s 3.8 s correct

Five rounds on one model on one machine is a smoke test, not a proper latency study. Your numbers will depend on your model and your decode speed.

There is also scripts/validate-priority.sh, which checks the ordering logic against a throwaway Redis, without any keys and without touching the GPU.

Things that bit me

  • A body priority plus coordination_redis gives intermittent 500s in LiteLLM 1.100.0. Strip it, as in the hook above.
  • Virtual keys usually cannot read their own info (/key/info returns 403 for LLM-only keys). For the test script I verify the tier with the admin key via POST /v2/key/info.
  • /model/info does not show router aliases or the api_base. To confirm that a request really went to your local backend, look at the x-litellm-model-api-base response header.
  • Memory floors: my launchers refuse to start a model when MemAvailable is below their floor, instead of swapping and risking an OOM. Good for a shared box, confusing in the middle of a benchmark.

Where this stops

If you need P1 to P3 to jump the queue as well, or you want to cancel a running request the moment a P0 arrives, this setup does not do that. The next step would be one lane per tier, or aborting the lower-priority stream at the gate and letting the caller retry. I have not built that.

Questions and corrections are very welcome, especially if you run vLLM and can confirm how the second lane behaves with your --max-num-seqs settings.