Skip to content

Add data tree struct#15901

Draft
mtreinish wants to merge 2 commits intoQiskit:mainfrom
mtreinish:data-tree-program-graph
Draft

Add data tree struct#15901
mtreinish wants to merge 2 commits intoQiskit:mainfrom
mtreinish:data-tree-program-graph

Conversation

@mtreinish
Copy link
Copy Markdown
Member

Summary

This commit adds a new data structure to the new providers crate
DataTree. The DataTree is a generic tree structure that will be used to
define the operation ports in the QuantumProgram's tensor compute
graph's nodes. Right now this is just one of the building blocks towards
defining the QuantumProgram. As it isn't being used right now since the
rest of the components don't exist yet, this is solely self tested. When
subsequent components are added tests using the DataTree as part of
Operation types and eventually in a QuantumProgram will be needed as
well.

Details and comments

This is based on top of #15892 and will need to be rebased after that PR merges. To view just the contents of this PR you can refer to the HEAD commit: 6433027

This commit adds a new crate to the qiskit crate collection for defining
the BackendV3 interface in Qiskit. The backendv3 interface will be a
Rust first construct that will expose a shared interface to both Python
and C, while the current BackendV2 interface is only exposed to Python.
As a first step to facilitate it's development this commit adds a new
empty crate where we'll slowly build up the functionality of that
interface. Right now it's just empty but in subsequent commits we'll add
onto it.
This commit adds a new data structure to the new providers crate
DataTree. The DataTree is a generic tree structure that will be used to
define the operation ports in the QuantumProgram's tensor compute
graph's nodes. Right now this is just one of the building blocks towards
defining the QuantumProgram. As it isn't being used right now since the
rest of the components don't exist yet, this is solely self tested. When
subsequent components are added tests using the DataTree as part of
Operation types and eventually in a QuantumProgram will be needed as
well.
@mtreinish mtreinish added this to the 2.5.0 milestone Mar 30, 2026
@mtreinish mtreinish added on hold Can not fix yet Rust This PR or issue is related to Rust code in the repository labels Mar 30, 2026
@qiskit-bot
Copy link
Copy Markdown
Collaborator

One or more of the following people are relevant to this code:

  • @Qiskit/terra-core

@mtreinish mtreinish marked this pull request as draft March 30, 2026 12:06
@jakelishman
Copy link
Copy Markdown
Member

I think we could do with a public textual overview of what all these data structures are, and are going to be. It's pretty hard to comment on / review any PR that adds core data structures without any use of them.

@mtreinish
Copy link
Copy Markdown
Member Author

This is still a draft. There will be an issue with epics outlining the high level structure of what we're building for the tensor compute graph QuantumProgram struct (this is just a starting piece of that) and all the subcomponents of that and then the abstract Backendv3 class that takes a QuantumProgram as the input to its execute method.

@ihincks ihincks mentioned this pull request Mar 30, 2026
/// let result = tree.get_by_str_key("x.y").unwrap().as_leaf_ref();
/// assert_eq!(*result.unwrap(), 10);
/// ```
pub fn get_by_str_key(&self, key: &str) -> Option<&TreeEntry<'_, T>> {
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.

This method looks like a useful component of an end-user API for accessing deep leafs. However, it only works if every node in the path can be accessed by a string key. I wonder if we can consider replacing this method with one that works in terms of a new struct TreePath that handles indexing by both string and integer?

I suggest "replace" because the string-splitting seems very useful, but it also seems very user-focused, so that I wonder whether it should be delegated to the bindings rather than the core object. Let me know if I'm thinking about this wrong.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah that's fair. I was thinking too mechanically about what the prototype was doing a path struct that can handle either index or string key based access is a more natural pattern for the rust data structure and should be good building block for the Python API and C APIs we'll build on top of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

on hold Can not fix yet Rust This PR or issue is related to Rust code in the repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants