Skip to content

fix(inference): AUT-2539 handle string prompts and rejections in KV hand - #8258

Closed
svcnemo-autobot wants to merge 1 commit into
NVIDIA:mainfrom
svcnemo-autobot:fix/inference-handoff-string-prompt
Closed

svcnemo-autobot wants to merge 1 commit into
NVIDIA:mainfrom
svcnemo-autobot:fix/inference-handoff-string-prompt

Conversation

@svcnemo-autobot

@svcnemo-autobot svcnemo-autobot commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Background

Decode engines in disaggregated serving admit prefilled requests through add_request_with_kv_handoff(). The inference review found two gaps:

  • InferenceClient.add_request_with_kv_handoff() accepts a string or a token list and forwards a string unchanged. The decode side called torch.tensor() on the prompt, so a string prompt raised inside the engine loop.
  • Unlike SUBMIT_REQUEST, the SUBMIT_REQUEST_WITH_KV handler in schedule_requests() had no try/except. That error, or any other handoff validation error, escaped the loop and the client never got a reply.

What changed

  • inference_state_handoff.py: prompt is typed str | list[int]. A string prompt is tokenized once with controller.tokenize_prompt(tokenizer, prompt, sampling_params.add_BOS) before block hashing. The deferred and pending import records and the finalizer's add_request() then all carry the same token IDs.
  • dynamic_engine.py: the SUBMIT_REQUEST_WITH_KV handler wraps add_request_with_kv_handoff() and sends any exception to _fail_submission(). That registers the same FAILED placeholder the plain submit path already uses. The _fail_submission docstring now mentions this caller.
  • New tests: test_schedule_requests_fails_a_rejected_kv_handoff_and_continues in test_dynamic_engine.py and test_string_handoff_prompt_is_tokenized_once_before_import in test_disagg_handoff_lifecycle.py.

Details

Every MP rank processes the same broadcast message, so the failure path keeps request state mirrored across ranks. One behavior change: a non-disaggregated engine that receives SUBMIT_REQUEST_WITH_KV now fails that one request with a reply instead of raising out of the loop. This was split out of the inference review. It is independent of #8255, which handles replying to a failed KV import.

Tested

  • black, isort, pylint (10.00/10) and ruff are clean on the 4 changed files.
  • Run on 8×H100 at this head merged with main 3914483f, using main's CI image (sha256:7b4e22a3):
    • tests/unit_tests/inference/**/*.py: 3675 passed, 37 skipped, 0 failed.
    • tests/unit_tests/inference/engines/test_dynamic_engine.py: 254 passed, 2 skipped.
  • No functional test case exercises disaggregation.

The inference client accepts a string or a token list for
add_request_with_kv_handoff() and passes a string through unchanged. On the
decode engine, add_request_with_kv_handoff() called torch.tensor() on the
prompt, so a string prompt raised inside the engine loop. The
SUBMIT_REQUEST_WITH_KV handler had no try/except, unlike SUBMIT_REQUEST, so
that error, or any other handoff validation error, escaped schedule_requests()
and the client never got a reply.

Tokenize a string prompt once, with the request's add_BOS, before block
hashing. The deferred and pending import records and the finalizer's
add_request() then all carry the same token IDs. Wrap the handler call so a
rejected handoff goes through _fail_submission(), which registers the FAILED
placeholder the plain path already uses. Every MP rank processes the same
broadcast message, so their request state stays mirrored.

Signed-off-by: svcnemo-autobot <svcnemo-autobot@nvidia.com>
@svcnemo-autobot
svcnemo-autobot requested review from a team as code owners October 15, 2026 15:56
@copy-pr-bot

copy-pr-bot Bot commented Oct 15, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@svcnvidia-nemo-ci
svcnvidia-nemo-ci marked this pull request as draft October 15, 2026 15:57
@github-actions

Copy link
Copy Markdown
Contributor

This PR has been automatically converted to draft because all PRs must start as drafts.

When you are ready for review, click Ready for Review to begin the review process. This will:

  1. Add the oncall reviewer (optional reviewer)
  2. Add required review teams based on your changes

See the contribution guide for more details.

@svcnvidia-nemo-ci

Copy link
Copy Markdown
Contributor

/ok to test a9000e1

@santhnm2
santhnm2 requested a review from wdykas October 15, 2026 16:05
@svcnemo-autobot svcnemo-autobot changed the title fix(inference): AUT-2539 handle string prompts and rejections in KV handoff fix(inference): AUT-2539 handle string prompts and rejections in KV hand Oct 15, 2026
@svcnemo-autobot
svcnemo-autobot marked this pull request as ready for review October 15, 2026 17:32
@ko3n1g ko3n1g closed this Oct 17, 2026

This branch was successfully deployed

2 active deployments
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.

3 participants