-
Notifications
You must be signed in to change notification settings - Fork 136
[WIP] add pybind for IChannel #1265
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
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @FollyCoolly, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Python-C++ interoperability for the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces pybind11 bindings for yacl::link::transport::IChannel
, allowing Python classes to implement this interface. This is a significant feature that enables more flexible and custom communication channel implementations from Python. The changes include the necessary C++ binding code, a trampoline class, type casters for yacl::Buffer
, and a new Python test to verify the integration.
The C++ implementation is well-done, especially the zero-copy buffer-to-numpy-array conversion and the safe handling of brpc flags. The Python test is a good starting point.
My review includes a few suggestions for cleanup and improving the robustness of the test mock. Overall, this is a solid contribution.
|
||
import spu.libspu.link as link | ||
import spu.libspu as spu | ||
from typing import Dict, Optional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print(dir(link)) | ||
print(spu.__file__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def Recv(self, key: str) -> bytes: | ||
"""Receive data""" | ||
final_key = f"{key}_{self.remote_rank}_{self.local_rank}" | ||
print(f"[{self.name}] Recv: key={final_key}") | ||
return self.storage.get(final_key, b"") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Recv
method in SimpleChannel
is a mock that doesn't block and doesn't respect the recv_timeout
. It immediately returns from the storage
dictionary. While this works for the current synchronous tests, it's not a realistic simulation of a channel's behavior and could lead to race conditions or flaky tests if used in asynchronous scenarios. Consider implementing a blocking wait with a timeout to make the mock more robust.
}; | ||
|
||
} // namespace detail | ||
} // namespace pybind11 No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PYBIND11_OVERRIDE_PURE(void, yacl::link::transport::IChannel, | ||
SetChunkParallelSendSize, size); | ||
} | ||
}; No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No description provided.