Skip to content

[None][feat] configure input processor workers - #20977

Draft
yechank-nvidia wants to merge 2 commits into
NVIDIA:mainfrom
yechank-nvidia:yechank/mm-preprocess-num-workers
Draft

yechank-nvidia wants to merge 2 commits into
NVIDIA:mainfrom
yechank-nvidia:yechank/mm-preprocess-num-workers

Conversation

@yechank-nvidia

Copy link
Copy Markdown
Collaborator

Description

Add top-level num_input_processor_workers to TorchLlmArgs. It uses the existing --num_input_processor_workers flag and pool. The default stays 8 for chat and completion, including text-only models. Set 0 to run inline. An explicit CLI value overrides YAML; --set has final precedence.

Keep Qwen3-VL processors and tokenizers separate per thread, including video token counting. Other multimodal models keep starting with 8 workers. This includes the CPU-sharing fix from #20950 as the first commit. Schemas, the usage manifest and the CLI reference are regenerated.

Test Coverage

192 CPU tests passed. The real Qwen3-VL processor matched serial outputs for 12 images, 12 videos and 4 mixed requests with both 4 and 8 workers. Video token counting is included. No weights were loaded. Restoring the old shared video call makes the regression test fail.

The new CPU tests use existing test-list entries. The existing CLI stability module lacks cpu_only and is skipped by CPU collection; its 4 tests passed when selected explicitly. No test lists were changed.

Tests used current Python with native bindings from an earlier main build. A native build from this revision and GPU serving remain untested. This revision has no performance measurement.

PR Checklist

Please review the following before submitting your PR:

  • PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.

  • PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.

  • Test cases are provided for new code paths (see test instructions)

  • If PR introduces API changes, an appropriate PR label is added - either api-compatible or api-breaking. For api-breaking, include BREAKING in the PR title.

  • Any new dependencies have been scanned for license and vulnerabilities

  • CODEOWNERS updated if ownership changes

  • Documentation updated as needed

  • Update tava architecture diagram if there is a significant design change in PR.

  • The reviewers assigned automatically/manually are appropriate for the PR.

  • Please check this after reviewing the above items as appropriate for this PR.

GitHub Bot Help

To see a list of available CI bot commands, please comment /bot help.

Problem: CPU tensor export temporarily changes the process-wide multiprocessing sharing strategy. Concurrent preprocessing threads can interleave these changes, use the wrong reducer, and restore the wrong strategy. A reduction failure can also leave the strategy changed. This risk follows from shared state; no production failure rate is measured.

Solution: Protect CPU storage reduction with a class-wide lock and restore the previous strategy in finally. The critical section covers strategy mutation and storage-handle creation. CUDA exports retain their existing path. This is the CPU-sharing prerequisite from NVIDIA#20950, rebased onto current main with its regression in an existing input test file.

Performance: Not measured. CPU export throughput, GPU kernel time, module throughput, and end-to-end serving performance are not measured. This correctness change is a prerequisite for configurable concurrent preprocessing.

Validation: Four CPU worker threads export and restore 40 int32 tensors, verify exact values, and verify the original sharing strategy. Tests run with CUDA hidden in a release container. Native config binding sources match current main; the reused build predates an unrelated attention operator change. No GPU serving, multi-host, or TP scaling qualification is claimed.
Signed-off-by: Yechan Kim <161688079+yechank-nvidia@users.noreply.github.com>
Problem:
trtllm-serve already uses eight input-processing threads for chat and completion, including text-only models. Its serve-only flag does not provide a shared typed engine setting. Source inspection also found that Qwen3-VL video token counting still called the shared HF processor while the other preprocessing paths used thread-local copies. Mutable processor/tokenizer state and process-wide CPU tensor sharing need isolation; no production race frequency was measured.

Solution:
Add top-level TorchLlmArgs.num_input_processor_workers as NonNegativeInt with default 8. Preserve the existing --num_input_processor_workers spelling and the existing pool. Zero runs inline; explicit CLI values override YAML and --set has final precedence. Read the same field when preparing processor state. Keep Qwen3-VL processor/tokenizer copies per thread and use self.processor in the video token-count fallback. The base configuration hook accepts every worker count; there is no existing declaration of processor thread safety to justify rejecting other models. Keep the preceding NVIDIA#20950 CPU-sharing serialization commit unchanged. Regenerate schemas, the usage manifest and the CLI reference.

Performance:
The trtllm-serve default remains eight workers. CPU preprocessing throughput, module/kernel time, end-to-end serving throughput, copy startup cost and per-thread host memory for this exact revision are unmeasured. There is no measured baseline/change pair for this configuration revision and no new performance claim. No GPU measurements were run.

Validation:
192 CPU tests pass: 188 marked CPU cases and four explicitly selected CLI stability cases. Coverage includes default 8, top-level numeric constraints, YAML/CLI/--set precedence, pool/inline ownership, base-processor worker configuration, image/video thread isolation, CPU sharing, schema freshness and golden-manifest freshness. The real local Qwen3-VL processor matches serial execution exactly for 12 images, 12 videos and four mixed requests with both four and eight workers, without loading weights. Each pool includes 16 calls through video token counting without a supplied grid. A runtime-only negative control restores the old shared call and the new concurrent video test fails as expected. Run pytest -m cpu_only on the existing llm_args/schema/input/server tests and the preprocessing cases in test_modeling_qwen3vl.py; run tests/unittest/api_stability/test_serve_cli.py explicitly. That existing module lacks the cpu_only marker and is ignored by CPU collection. No test lists, Qwen2-VL tests or new test files were changed. Tests use current Python with earlier-main native bindings whose config sources match; an exact-revision native build, GPU serving, other-model concurrency correctness and TP scaling remain unvalidated.

Signed-off-by: Yechan Kim <161688079+yechank-nvidia@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant