Skip to content

[None][fix] serialize CPU tensor sharing strategy changes - #20950

Closed
yechank-nvidia wants to merge 1 commit into
NVIDIA:mainfrom
yechank-nvidia:yechank/trtllm-cpu-sharing
Closed

yechank-nvidia wants to merge 1 commit into
NVIDIA:mainfrom
yechank-nvidia:yechank/trtllm-cpu-sharing

Conversation

@yechank-nvidia

Copy link
Copy Markdown
Collaborator

Description

CPU tensor export temporarily changes a process-wide multiprocessing sharing strategy. Concurrent exports can interleave these changes, and an exception can leave the strategy changed.

Protect strategy changes and storage reduction with one class-wide lock. Restore the previous strategy in a finally block. CUDA and byte exports keep their existing paths.

Related: ai-dynamo/dynamo#15951. This protects shared state when input processing uses multiple threads.

CPU export throughput and GPU serving performance are not measured yet.

Test Coverage

test_shared_tensor_cpu.py checks exact values and restoration of the original strategy after 40 exports from four threads. It is independent of portable-byte handoff support.

Test Plan

  • The standalone concurrency test passed: 1 test, 40 exact tensor round trips, four threads.
  • CPU checks on an older TensorRT-LLM/Dynamo release with these changes applied: 94 passed, 42 deselected.
  • Ruff 0.9.4: lint and formatting passed; no new violations in files that use the older formatting rules.
  • The sharing code matches the code used for the earlier correctness checks; repository CI is pending.

Maintainers: please run repository CI.

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 available CI bot commands, use the repository's /bot help command.

Problem: CPU tensor export temporarily changes the process-wide multiprocessing sharing strategy. Concurrent input preprocessing threads can interleave these changes, select the wrong reducer, and restore the wrong strategy. An exception in reduction can also leave the strategy changed. This correctness risk follows from the shared state; a production concurrency failure has not been measured.

Solution: Protect CPU storage reduction with a class-wide lock and restore the previous strategy in a finally block. CUDA exports and portable byte exports retain their existing paths. The lock covers only the strategy mutation and storage-handle creation.

Performance: Not measured. GPU kernel, module throughput and end-to-end performance are not measured. This change is a correctness 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 after completion. Portable byte transport and generation-only validation have separate regression coverage. No multi-host or TP scaling measurement was performed.

Signed-off-by: Yechan Kim <[email protected]>
@yechank-nvidia

Copy link
Copy Markdown
Collaborator Author

Closing: main already fixed this in #20446, which shares CPU tensor storage without changing the process-wide sharing strategy, so the race this PR guarded against no longer exists.

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