Skip to content

trtllm: forward routing.priority to the engine waiting queue - #28

Merged
sopwg612 merged 2 commits into
feat-deepinfra-runtime-07-09from
feat-trtllm-routing-priority
Aug 3, 2026
Merged

trtllm: forward routing.priority to the engine waiting queue#28
sopwg612 merged 2 commits into
feat-deepinfra-runtime-07-09from
feat-trtllm-routing-priority

Conversation

@sopwg612

@sopwg612 sopwg612 commented Aug 3, 2026

Copy link
Copy Markdown

Problem

generate_locally reads the engine scheduling priority off the top level of the request:

priority = request.get("priority", DEFAULT_REQUEST_PRIORITY)

But the Rust frontend puts it at routing.priorityPreprocessedRequest.routing is a nested RoutingHints, not flattened. Its sibling routing.dp_rank is read correctly two lines above.

The result: every real inference request falls back to DEFAULT_REQUEST_PRIORITY (0.5), so per-request priority never reaches TRT-LLM — even on a worker booted with scheduler_config.waiting_queue_policy=priority. RoutingHints.priority is documented as "Backend engine scheduling priority forwarded to the generate call", so the intent is clear; only the read is wrong.

The existing test documents the current behavior as intentional, but it is describing the bug:

Regular inference requests (built by the Rust frontend as PreprocessedRequest, which has no priority field) must fall back to DEFAULT_REQUEST_PRIORITY (0.5).

The top-level key stays as the health-check path (TrtllmHealthCheckPayload pins 1.0) and keeps precedence.

Value range

deepapi sends TRT-LLM's own scale, restricted to the rails the integer-typed header can express: 1 urgent, 0 reserved for a future flex tier, header omitted for the 0.5 default. So this is a plain pass-through — no encoding for this file to carry across rebases.

The clamp stays because TRT-LLM rejects anything outside [0.0, 1.0] outright (tensorrt_llm/executor/request.py), and degrading beats failing the request.

An earlier revision of this branch scaled the value by 10 to carry pytrtllm's graded clamp(0.5 - 0.1 * score); that was dropped as machinery for a gradation the integer header cannot represent anyway.

Testing

⚠️ The new tests have not been run. tensorrt_llm is not importable on the host these were written on, so test_trtllm_handler_base.py needs a run in the build container before this merges. Only py_compile was verified.

Added: routing.priority unscaling (parametrized 0/5/6/10), out-of-range clamping, and health-check precedence over routing.

Companion

deepinfra/backend PR — emits the header and adds the Engine.DYNAMO branch to PriorityInfo.engine_value.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QqzQrZR2qrvxM6DsxqGciu

generate_locally read `priority` off the top level of the request, but the
Rust frontend puts it at `routing.priority` (PreprocessedRequest.routing is
not flattened) -- the sibling `routing.dp_rank` two lines up is read
correctly. So every real request fell back to DEFAULT_REQUEST_PRIORITY and
per-request priority never reached TRT-LLM, even with
scheduler_config.waiting_queue_policy=priority set on the worker. The
top-level key stays the health-check path, which pins 1.0.

deepapi scales the [0.0, 1.0] engine priority to an integer before putting it
on x-dynamo-request-priority, because nvext.agent_hints.priority is typed as
an i32 while TRT-LLM rejects anything outside [0.0, 1.0]. Divide it back and
clamp, so a malformed value degrades instead of erroring the request.

NOT YET RUN: tensorrt_llm is not importable on the host these were written
on, so the new tests need a run in the build container before merge.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QqzQrZR2qrvxM6DsxqGciu
Drops the DEEPINFRA_PRIORITY_SCALE divide added in the previous commit.
deepapi now sends TRT-LLM's own rails (1.0 urgent, 0.0 reserved for flex,
default omitted) rather than a scaled integer, because the integer-typed
header cannot express the graded values the scale existed to carry. That
makes this a plain pass-through with a clamp, and removes a deepinfra-local
encoding this file would otherwise have to keep explaining across rebases.

The clamp stays: TRT-LLM rejects anything outside [0.0, 1.0] outright, and
degrading is better than failing the request.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QqzQrZR2qrvxM6DsxqGciu
@sopwg612
sopwg612 had a problem deploying to external_collaborator August 3, 2026 21:06 — with GitHub Actions Failure
@sopwg612
sopwg612 marked this pull request as ready for review August 3, 2026 21:13
@sopwg612
sopwg612 merged commit 82514b5 into feat-deepinfra-runtime-07-09 Aug 3, 2026
13 of 20 checks passed
sopwg612 added a commit that referenced this pull request Aug 4, 2026
revert: trtllm routing.priority engine hand-off (#28)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant