Skip to content

Resolve the pybind develop-path lookups once instead of per call - #4793

Open
fangche123 wants to merge 1 commit into
mainfrom
chefang/ffi-pybind-dispatch-overhead
Open

Resolve the pybind develop-path lookups once instead of per call#4793
fangche123 wants to merge 1 commit into
mainfrom
chefang/ffi-pybind-dispatch-overhead

Conversation

@fangche123

@fangche123 fangche123 commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Motivation

Technical Details

Test Plan

Test Result

image

Submission Checklist

@fangche123
fangche123 requested review from a team and a lite review from Copilot August 17, 2026 07:07
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs; main branch always runs both MI35X and MI300X
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 4793 --add-label <label>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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_t pybind class in torch_to_aiter_pybind() to avoid repeated module lookups.
  • Add a _pybind_develop_hooks() cache in aiter.jit.core to 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=True wrapper.

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 thread aiter/utility/dtypes.py
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 thread aiter/utility/dtypes.py
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(),
)
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.

2 participants