[Refactor] update get_c_pointers to c_abi_spec#682
Open
sjfeng1999 wants to merge 4 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors FlyDSL’s host-side argument packing from the legacy __get_c_pointers__ / _reusable_slot_spec approach to a unified __c_abi_spec__ protocol, and updates tests/kernels to use the new torch-native tensor wrapper (from_torch_tensor). It also introduces a C++ MemRefSpec binding to centralize memref-type + cache-signature derivation and reduce duplicated Python-side state.
Changes:
- Replace
get_c_pointerswithc_abi_specand migrate scalar/stream/struct/tensor argument implementations to__c_abi_spec__. - Introduce
MemRefSpec(C++/nanobind) and refactor tensor JIT args intoMemRefJitArg+ concreteTorchTensorJitArg/DLTensorJitArg. - Update unit/system/kernel tests and some kernels to prefer
flyc.from_torch_tensor(...)overflyc.from_dlpack(...).
Reviewed changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/test_universal_atomic.py | Switch tensor adaptation to from_torch_tensor for atomic tests. |
| tests/unit/test_tensor_cache_signature.py | Update cache-signature tests to TorchTensorJitArg / __c_abi_spec__ terminology and behavior. |
| tests/unit/test_struct.py | Migrate struct ABI assertions from pointer lists to slot fills via c_abi_spec. |
| tests/unit/test_math_ops.py | Switch tensor adaptation to from_torch_tensor for math-op launches. |
| tests/unit/test_for_auto_iter_args.py | Switch output tensor adaptation to from_torch_tensor. |
| tests/unit/test_callstate_dispatch.py | Update dispatch/packing tests to the new __c_abi_spec__ slot-fill model. |
| tests/system/test_while_e2e.py | Switch output tensor adaptation to from_torch_tensor. |
| tests/system/test_inline_compare_scf_if.py | Switch tensor adaptation to from_torch_tensor for control-flow system tests. |
| tests/system/test_ifexp_e2e.py | Switch output tensor adaptation to from_torch_tensor. |
| tests/system/test_if_liveout_minimal.py | Switch output tensor adaptation to from_torch_tensor. |
| tests/system/test_for_auto_iter_args_e2e.py | Switch output tensor adaptation to from_torch_tensor. |
| tests/system/test_control_flow_compile.py | Switch tensor adaptation to from_torch_tensor for compile tests. |
| tests/system/test_closure_freevars_mismatch.py | Switch output tensor adaptation to from_torch_tensor. |
| tests/kernels/test_vec_add.py | Switch tensor adaptation to from_torch_tensor in benchmark test. |
| tests/kernels/test_fp8_gemm_rowscale.py | Switch static-weight tensor wrappers to from_torch_tensor. |
| python/flydsl/expr/typing.py | Replace stream C-pointer extraction with __c_abi_spec__ fill protocol. |
| python/flydsl/expr/struct.py | Replace struct __get_c_pointers__ with recursive __c_abi_spec__ slot fills; add struct-type helpers to exports. |
| python/flydsl/expr/numeric.py | Replace scalar pointer extraction with __c_abi_spec__ fill protocol for numeric types. |
| python/flydsl/compiler/protocol.py | Replace get_c_pointers with c_abi_spec in compiler protocol layer. |
| python/flydsl/compiler/jit_function.py | Rework CallState construction to use c_abi_spec fills; remove old fallback dispatch generation. |
| python/flydsl/compiler/jit_executor.py | Centralize CallState implementation and switch CompiledArtifact dispatch to slot-fill based packing. |
| python/flydsl/compiler/jit_argument.py | Major refactor: introduce MemRefJitArg, TorchTensorJitArg, DLTensorJitArg, and new from_torch_tensor. |
| python/flydsl/compiler/init.py | Export from_torch_tensor from the compiler package. |
| lib/Bindings/Python/MemRefSpec.h | New C++ class binding for memref type + cache signature + dynamic-dim indices. |
| lib/Bindings/Python/FlyExtension.cpp | Bind MemRefSpec into _mlirDialectsFly; slim down DLTensorAdaptor binding API. |
| lib/Bindings/Python/DLTensorAdaptor.h | Simplify adaptor to metadata-only + dtype reporting; remove dynamic-mark and memref-desc building. |
| kernels/qk_norm_rope_quant.py | Switch static tensor wrappers to from_torch_tensor. |
| kernels/fused_rope_cache_kernel.py | Switch fallback wrapping to from_torch_tensor. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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