Skip to content

[Refactor] update get_c_pointers to c_abi_spec#682

Open
sjfeng1999 wants to merge 4 commits into
mainfrom
pr/refactor-c_abi_spec
Open

[Refactor] update get_c_pointers to c_abi_spec#682
sjfeng1999 wants to merge 4 commits into
mainfrom
pr/refactor-c_abi_spec

Conversation

@sjfeng1999

Copy link
Copy Markdown
Collaborator

Motivation

Technical Details

Test Plan

Test Result

Submission Checklist

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 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_pointers with c_abi_spec and migrate scalar/stream/struct/tensor argument implementations to __c_abi_spec__.
  • Introduce MemRefSpec (C++/nanobind) and refactor tensor JIT args into MemRefJitArg + concrete TorchTensorJitArg / DLTensorJitArg.
  • Update unit/system/kernel tests and some kernels to prefer flyc.from_torch_tensor(...) over flyc.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.

Comment thread python/flydsl/compiler/jit_argument.py
Comment thread python/flydsl/compiler/jit_argument.py
Comment thread python/flydsl/compiler/jit_argument.py
Comment thread python/flydsl/compiler/jit_argument.py
Comment thread lib/Bindings/Python/DLTensorAdaptor.h
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