Resolve the pybind develop-path lookups once instead of per call - #4793
Open
fangche123 wants to merge 1 commit into
Open
Resolve the pybind develop-path lookups once instead of per call#4793fangche123 wants to merge 1 commit into
fangche123 wants to merge 1 commit into
Conversation
Contributor
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces overhead on the develop=True / ffi_type="pybind" execution path by caching repeated lookups (pybind tensor wrapper class, tensor conversion hooks, and raw CUDA stream retrieval) instead of resolving them on every op invocation.
Changes:
- Cache the
module_aiter_core.aiter_tensor_tpybind class intorch_to_aiter_pybind()to avoid repeated module lookups. - Add a
_pybind_develop_hooks()cache inaiter.jit.coreto avoid repeated per-call imports/lookups and to set the current HIP stream using a raw-stream fast path when available. - Simplify per-call argument/kwarg conversion logic in the
develop=Truewrapper.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
aiter/utility/dtypes.py |
Caches the pybind tensor wrapper class and adjusts device ordinal retrieval for pybind tensor construction. |
aiter/jit/core.py |
Adds cached “develop hooks” to reduce per-call overhead for pybind develop-mode wrappers. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+76
to
+80
| global _aiter_tensor_cls | ||
| if _aiter_tensor_cls is None: | ||
| from ..jit.core import get_module | ||
|
|
||
| _aiter_tensor_cls = get_module("module_aiter_core").aiter_tensor_t |
Comment on lines
+94
to
98
| # get_device() returns the ordinal directly, and already answers -1 for a | ||
| # CPU tensor; `.device.index` materializes a torch.device to say the same | ||
| # thing and then needs None folded to -1. | ||
| tensor.get_device(), | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Technical Details
Test Plan
Test Result
Submission Checklist