Skip to content

fix: nanobind build due to undeclared CommType #6149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

Linda-Stadter
Copy link
Collaborator

@Linda-Stadter Linda-Stadter commented Jul 17, 2025

Fix nanobind build

A recent PR changed bindings for pybind that weren't applied to nanobind yet. This caused the nanobind build in the CI to fail.
This PR applies these changes to nanobind.

GitHub Bot Help

/bot [-h] ['run', 'kill', 'skip', 'reuse-pipeline'] ...

Provide a user friendly way for developers to interact with a Jenkins server.

Run /bot [-h|--help] to print this help message.

See details below for each supported subcommand.

run [--disable-fail-fast --skip-test --stage-list "A10-1, xxx" --gpu-type "A30, H100_PCIe" --add-multi-gpu-test --only-multi-gpu-test --disable-multi-gpu-test --post-merge --extra-stage "H100_PCIe-[Post-Merge]-1, xxx"]

Launch build/test pipelines. All previously running jobs will be killed.

--disable-fail-fast (OPTIONAL) : Disable fail fast on build/tests/infra failures.

--skip-test (OPTIONAL) : Skip all test stages, but still run build stages, package stages and sanity check stages. Note: Does NOT update GitHub check status.

--stage-list "A10-1, xxx" (OPTIONAL) : Only run the specified test stages. Examples: "A10-1, xxx". Note: Does NOT update GitHub check status.

--gpu-type "A30, H100_PCIe" (OPTIONAL) : Only run the test stages on the specified GPU types. Examples: "A30, H100_PCIe". Note: Does NOT update GitHub check status.

--only-multi-gpu-test (OPTIONAL) : Only run the multi-GPU tests. Note: Does NOT update GitHub check status.

--disable-multi-gpu-test (OPTIONAL) : Disable the multi-GPU tests. Note: Does NOT update GitHub check status.

--add-multi-gpu-test (OPTIONAL) : Force run the multi-GPU tests. Will also run L0 pre-merge pipeline.

--post-merge (OPTIONAL) : Run the L0 post-merge pipeline instead of the ordinary L0 pre-merge pipeline.

--extra-stage "H100_PCIe-[Post-Merge]-1, xxx" (OPTIONAL) : Run the ordinary L0 pre-merge pipeline and specified test stages. Examples: --extra-stage "H100_PCIe-[Post-Merge]-1, xxx".

For guidance on mapping tests to stage names, see docs/source/reference/ci-overview.md.

kill

kill

Kill all running builds associated with pull request.

skip

skip --comment COMMENT

Skip testing for latest commit on pull request. --comment "Reason for skipping build/test" is required. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.

reuse-pipeline

reuse-pipeline

Reuse a previous pipeline to validate current commit. This action will also kill all currently running builds associated with the pull request. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.

Summary by CodeRabbit

  • New Features

    • Introduced a new Python enum for backend types, allowing explicit selection of cache transceiver backends.
    • Added support for configuring backend type and maximum tokens in buffer in the cache transceiver configuration.
  • Bug Fixes

    • Updated serialization and deserialization logic to correctly handle new configuration fields for cache transceiver settings.
  • Tests

    • Updated tests to reflect changes in cache transceiver configuration, ensuring compatibility with new backend enum.

Signed-off-by: Linda-Stadter <57756729+Linda-Stadter@users.noreply.github.com>
Copy link

coderabbitai bot commented Jul 17, 2025

Walkthrough

The changes update Python bindings for cache transceiver configuration and buffer management. The CommType enum is removed from bindings, and a new CacheTransceiverBackendType enum is introduced. Constructor signatures and serialization logic for CacheTransceiverConfig are revised to support explicit backend selection and improved property naming. Corresponding tests are updated.

Changes

File(s) Change Summary
cpp/tensorrt_llm/nanobind/batch_manager/cacheTransceiver.cpp Removed CommType enum binding, updated CacheTransceiver constructor and buffer size method args.
cpp/tensorrt_llm/nanobind/executor/executorConfig.cpp Added CacheTransceiverBackendType enum, revised CacheTransceiverConfig constructor, properties, and serialization.
tests/unittest/bindings/test_executor_bindings.py Updated test to use new enum for backend parameter in CacheTransceiverConfig.

Sequence Diagram(s)

sequenceDiagram
    participant Python as Python User
    participant NB as Nanobind Bindings
    participant Cpp as C++ CacheTransceiverConfig

    Python->>NB: Create CacheTransceiverConfig(backend, max_tokens_in_buffer)
    NB->>Cpp: Construct with backend, max_tokens_in_buffer
    Cpp-->>NB: Instance
    NB-->>Python: Python object

    Python->>NB: Use CacheTransceiverBackendType enum
    NB-->>Python: Enum values (DEFAULT, MPI, UCX, NIXL)
Loading

Poem

In the warren of code, a new enum appears,
Old CommType hops away, no longer near.
Backend types now clearly defined,
With pickles and configs neatly aligned.
🥕 A rabbit’s delight, these bindings anew—
Simpler, explicit, and easier to chew!


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 10dbf4f and 501eaa8.

📒 Files selected for processing (3)
  • cpp/tensorrt_llm/nanobind/batch_manager/cacheTransceiver.cpp (1 hunks)
  • cpp/tensorrt_llm/nanobind/executor/executorConfig.cpp (1 hunks)
  • tests/unittest/bindings/test_executor_bindings.py (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
cpp/tensorrt_llm/nanobind/executor/executorConfig.cpp (1)
Learnt from: amitz-nv
PR: NVIDIA/TensorRT-LLM#5616
File: tensorrt_llm/executor/worker.py:375-384
Timestamp: 2025-07-17T09:01:27.374Z
Learning: In tensorrt_llm/executor/worker.py, the LoRA adapter cache optimization logic that checks `is_adapter_in_cpu_cache()` and conditionally passes None for weights/config has a known race condition issue that cannot be solved with simple error handling or verification checks. This is a known limitation that requires a more comprehensive solution.
🔇 Additional comments (7)
tests/unittest/bindings/test_executor_bindings.py (1)

2481-2483: LGTM! Test correctly updated for new CacheTransceiverConfig API.

The test has been properly updated to use the new CacheTransceiverBackendType.UCX enum instead of the string "UCX", which aligns with the updated binding changes that introduced the CacheTransceiverBackendType enum to replace the removed CommType. This ensures the test validates the new constructor signature and serialization behavior.

cpp/tensorrt_llm/nanobind/executor/executorConfig.cpp (4)

427-428: LGTM: Serialization updated to include both backend type and max tokens.

The serialization logic correctly extracts both the backend type and max tokens in buffer, replacing the previous single parameter approach.


429-437: LGTM: Deserialization updated to match new constructor signature.

The deserialization logic correctly handles the new tuple structure with 2 elements and properly constructs the CacheTransceiverConfig with backend type and max tokens.


439-456: LGTM: Well-implemented enum binding with case-insensitive string conversion.

The enum binding correctly exposes the backend types with a useful from_string method that handles both uppercase and lowercase variants. The error handling provides a clear message for invalid backend types.


458-466: LGTM: Class binding updated to match new configuration structure.

The constructor and properties are correctly updated to support the new backend type and max tokens configuration. The use of optional parameters with appropriate defaults maintains backward compatibility.

cpp/tensorrt_llm/nanobind/batch_manager/cacheTransceiver.cpp (2)

91-97: LGTM: Constructor updated to use CacheTransceiverConfig instead of CommType.

The constructor binding correctly reflects the API change from explicit CommType parameter to optional CacheTransceiverConfig, providing better configurability and consistency with the executor module changes.


103-103: LGTM: Static method signature improved with better parameter separation.

The updated pre_alloc_buffer_size method signature provides better separation of concerns by having distinct parameters for cache size calculation and transceiver configuration.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Linda-Stadter
Copy link
Collaborator Author

/bot run

@Linda-Stadter Linda-Stadter requested a review from chuangz0 July 17, 2025 16:17
@Linda-Stadter Linda-Stadter self-assigned this Jul 17, 2025
@tensorrt-cicd
Copy link
Collaborator

PR_Github #12218 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #12218 [ run ] completed with state FAILURE
/LLM/main/L0_MergeRequest_PR pipeline #9073 completed with status: 'FAILURE'

@Linda-Stadter
Copy link
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #12240 [ run ] triggered by Bot

config = trtllm.CacheTransceiverConfig(backend="UCX",
max_tokens_in_buffer=1024)
config = trtllm.CacheTransceiverConfig(
backend=trtllm.CacheTransceiverBackendType.UCX,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a lot of tests that use the string format, do we have something similar to "implicitly convertible" in Nanobind?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which tests do you mean? I only found this test and a test in kv_cache_transceiver. But the latter accesses the enum member directly and not through a string

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have cache_transceiver_config.backend: <str> in tests/integration/defs/disaggregated/test_configs, the type of field of backend is string.

@tensorrt-cicd
Copy link
Collaborator

PR_Github #12240 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #9090 completed with status: 'FAILURE'

.value("MPI", tle::CacheTransceiverConfig::BackendType::MPI)
.value("UCX", tle::CacheTransceiverConfig::BackendType::UCX)
.value("NIXL", tle::CacheTransceiverConfig::BackendType::NIXL)
.def("from_string",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that nanobind

nb::class_<MyType>(m, "MyType")
    .def(nb::init_implicit<MyOtherType>());

more suitable here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would it work? Unfortunately, I don't see a way to define an init function for an enum with nanobind.

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.

4 participants