Skip to content

[WIP] Add ways of querying CustomOperations from C - #16808

Draft
raynelfss wants to merge 25 commits into
Qiskit:mainfrom
raynelfss:query-c-custom
Draft

[WIP] Add ways of querying CustomOperations from C#16808
raynelfss wants to merge 25 commits into
Qiskit:mainfrom
raynelfss:query-c-custom

Conversation

@raynelfss

@raynelfss raynelfss commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #16622

Based on top of #16549 (changes start at fdc9a91)

  • Initial functions to expose a QkCustomOperation directly from a circuit or dag in C. This also adds methods for querying properties associated with the Operation and CustomOperation traits in Rust.

AI/LLM disclosure

  • I didn't use LLM tooling, or only used it privately.
  • I used the following tool to help write this PR description:
  • I used the following tool to generate or modify code:

@raynelfss raynelfss added this to the 2.6.0 milestone Aug 20, 2026
@raynelfss raynelfss added on hold Can not fix yet Changelog: Added Add an "Added" entry in the GitHub Release changelog. labels Aug 20, 2026
@raynelfss raynelfss added mod: circuit Related to the core of the `QuantumCircuit` class or the circuit library C API Related to the C API labels Aug 20, 2026
@raynelfss raynelfss changed the title Add ways of querying CustomOperations from C [WIP] Add ways of querying CustomOperations from C Aug 20, 2026
@raynelfss raynelfss moved this from Ready to In development in Qiskit 2.6 Aug 24, 2026
…ations

- Make `CustomOp` the private representation of `C Custom`.
- Make `BoxedCustomOperation` public and use it as the way to expose `CustomOperation` to C as it already is a `Boxed` pointer.
- Update each usage to leverage `Boxed` pointer.
- Rename `qk_custom_op_new_vtable` to `qk_custom_op_vtable_new`.
- Initial functions to expose a `QkCustomOperation` directly from a circuit or dag in C. This also adds methods for querying properties associated with the `Operation` and `CustomOperation` traits in Rust.
- Renaming error  `CCustomOperation` via the C API: `QkQkCustomOperation` is now `QkCustomOperation`.
- All ``qk_custom_inst`` functions are now ``qk_custom_operation``.
- ``qk_custom_operation`` methods will now decide whether the operation originated from Rust or C and behave accordingly.
- Fixed how the ``qk_custom_operation_free`` function behaves, to not panic at null pointers.
- Circuit querying methods now return mutable pointers instead of `const`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C API Related to the C API Changelog: Added Add an "Added" entry in the GitHub Release changelog. mod: circuit Related to the core of the `QuantumCircuit` class or the circuit library on hold Can not fix yet

Projects

Status: In development

Development

Successfully merging this pull request may close these issues.

Retrieve and Query Custom Operations from the C API

1 participant