Skip to content

Implement ProgramNode#16106

Open
ihincks wants to merge 9 commits intoQiskit:mainfrom
ihincks:ih/quantum_program_operation
Open

Implement ProgramNode#16106
ihincks wants to merge 9 commits intoQiskit:mainfrom
ihincks:ih/quantum_program_operation

Conversation

@ihincks
Copy link
Copy Markdown
Contributor

@ihincks ihincks commented Apr 29, 2026

This PR closes #16029 by defining a trait called ProgramNode. It also implements a simple core node (Store) just to show the idea of what a simple node definition will be, albeit a slightly weird one in that it requires an empty input tree.

PR Stack

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: Claude 4.6

@ihincks ihincks requested a review from a team as a code owner April 29, 2026 19:58
@ihincks ihincks added Rust This PR or issue is related to Rust code in the repository mod: providers Related to the backend and job abstractions labels Apr 29, 2026
@qiskit-bot
Copy link
Copy Markdown
Collaborator

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

  • @Qiskit/terra-core

@ihincks ihincks marked this pull request as draft April 29, 2026 20:04
@ihincks ihincks mentioned this pull request Apr 29, 2026
@coveralls
Copy link
Copy Markdown

coveralls commented Apr 29, 2026

Coverage Report for CI Build 25382081104

Coverage decreased (-0.1%) to 87.501%

Details

  • Coverage decreased (-0.1%) from the base build.
  • Patch coverage: 182 uncovered changes across 3 files (259 of 441 lines covered, 58.73%).
  • 6 coverage regressions across 2 files.

Uncovered Changes

File Changed Covered %
crates/providers/src/tensor.rs 341 170 49.85%
crates/providers/src/store.rs 86 76 88.37%
crates/providers/src/data_tree.rs 11 10 90.91%

Coverage Regressions

6 previously-covered lines in 2 files lost coverage.

File Lines Losing Coverage Coverage
crates/qasm2/src/lex.rs 5 91.52%
crates/circuit/src/parameter/symbol_expr.rs 1 74.21%

Coverage Stats

Coverage Status
Relevant Lines: 122267
Covered Lines: 106985
Line Coverage: 87.5%
Coverage Strength: 960960.62 hits per line

💛 - Coveralls

@ShellyGarion ShellyGarion added this to the 2.5.0 milestone Apr 30, 2026
@ihincks ihincks force-pushed the ih/quantum_program_operation branch 2 times, most recently from cb4cdba to bda047a Compare April 30, 2026 20:30
Comment thread crates/providers/src/program_node.rs Outdated
Comment thread crates/providers/src/program_node.rs Outdated
Comment thread crates/providers/src/store.rs Outdated
Comment on lines +70 to +71
static EMPTY: OnceLock<DataTree<TensorType>> = OnceLock::new();
EMPTY.get_or_init(DataTree::new)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you move the static definition outside of the method definition and give it a comment about having a single empty data tree definition to avoid reallocation on each store. The other thing is why do we need a OnceLock here? Couldn't we use a OnceCell, unless you're thinking we're going to be calling this from a threaded context. The other thought is lazy_static is an option here too.

Copy link
Copy Markdown
Contributor Author

@ihincks ihincks May 1, 2026

Choose a reason for hiding this comment

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

Could you move the static definition outside of the method definition

I'm happy to, but I'd like to know why. Isn't it a bit more readable to put it inside the method when only one method needs it?

The other thing is why do we need a OnceLock here? Couldn't we use a OnceCell

It's because static variables are always Sync and OnceCell is explicitly not Sync. Looking into lazy_static, it looks like it's been superseded by LazyOnce and LazyCell.

I made a change in 1c2eb52, but am happy to iterate it. It's worth getting the pattern right because many other nodes will want to copy it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I normally move it to the top of the module just to make the scoping clear. A static is global so it can be a bit confusing to see it inline. It's not a big deal either way.

@ihincks ihincks force-pushed the ih/quantum_program_operation branch from 1cf3d38 to 1c2eb52 Compare May 1, 2026 14:32
@ihincks ihincks marked this pull request as ready for review May 1, 2026 14:57
@qiskit-bot
Copy link
Copy Markdown
Collaborator

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

  • @Qiskit/terra-core

@ihincks ihincks force-pushed the ih/quantum_program_operation branch from 1c2eb52 to 6276fcc Compare May 5, 2026 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod: providers Related to the backend and job abstractions Rust This PR or issue is related to Rust code in the repository

Projects

Status: Ready

Development

Successfully merging this pull request may close these issues.

Implement ProgramNode trait

5 participants