Skip to content

Add impls of ProgramNode for various math operations#16107

Open
ihincks wants to merge 3 commits into
Qiskit:mainfrom
ihincks:program-node-math
Open

Add impls of ProgramNode for various math operations#16107
ihincks wants to merge 3 commits into
Qiskit:mainfrom
ihincks:program-node-math

Conversation

@ihincks
Copy link
Copy Markdown
Contributor

@ihincks ihincks commented Apr 29, 2026

This PR closes #16031 by implementing ProgramNode for various math-y structs.

  • Add
  • Subtract
  • Multiply
  • Divide
  • Remainder
  • Power

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 20:04
@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 26910781949

Coverage decreased (-0.08%) to 87.387%

Details

  • Coverage decreased (-0.08%) from the base build.
  • Patch coverage: 201 uncovered changes across 4 files (471 of 672 lines covered, 70.09%).
  • 12 coverage regressions across 5 files.

Uncovered Changes

File Changed Covered %
crates/providers/src/math_nodes/reduction.rs 238 142 59.66%
crates/providers/src/math_nodes/bitwise.rs 177 106 59.89%
crates/providers/src/math_nodes/binary.rs 161 132 81.99%
crates/providers/src/tensor.rs 93 88 94.62%
Total (5 files) 672 471 70.09%

Coverage Regressions

12 previously-covered lines in 5 files lost coverage.

File Lines Losing Coverage Coverage
crates/qasm2/src/parse.rs 6 97.63%
crates/providers/src/tensor.rs 2 94.71%
crates/qasm2/src/lex.rs 2 92.29%
crates/circuit/src/parameter/parameter_expression.rs 1 91.03%
crates/circuit/src/parameter/symbol_expr.rs 1 74.29%

Coverage Stats

Coverage Status
Relevant Lines: 125129
Covered Lines: 109346
Line Coverage: 87.39%
Coverage Strength: 955327.5 hits per line

💛 - Coveralls

@ShellyGarion ShellyGarion added this to the 2.5.0 milestone Apr 30, 2026
@ihincks ihincks force-pushed the program-node-math branch 2 times, most recently from b429b8d to a437668 Compare April 30, 2026 20:31
@ihincks ihincks changed the title Add impls of Program node for various math operations Add impls of ProgramNode for various math operations May 1, 2026
@ihincks ihincks force-pushed the program-node-math branch 4 times, most recently from 31adc4f to 768edb2 Compare May 16, 2026 11:07
@ihincks ihincks marked this pull request as ready for review May 16, 2026 11:07
@qiskit-bot
Copy link
Copy Markdown
Collaborator

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

  • @Qiskit/terra-core

@ihincks ihincks requested a review from mtreinish May 16, 2026 11:07
let Tensor::Bit(y_arr) = y else {
unreachable!()
};
// TODO: I think this call will panic on bad broadcast? we need an error
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Flagging TODO with comment. There's more than one like this.

Comment on lines +75 to +78
let x = require_typed_leaf_arg(args, "x", DType::Bit)?;
let Tensor::Bit(x_arr) = x else {
unreachable!()
};
Copy link
Copy Markdown
Contributor Author

@ihincks ihincks May 16, 2026

Choose a reason for hiding this comment

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

I'm not entirely happy with this pattern that involves the unreachable statement...but I'm also not sure exactly how to best refactor.

@ihincks ihincks force-pushed the program-node-math branch 3 times, most recently from a590a50 to 2be78bc Compare May 21, 2026 19:02
@ihincks ihincks force-pushed the program-node-math branch 2 times, most recently from 73504ec to d590df2 Compare May 28, 2026 11:08
@ihincks ihincks self-assigned this May 28, 2026
@ihincks ihincks removed this from Qiskit 2.5 May 28, 2026
@ihincks ihincks force-pushed the program-node-math branch from d590df2 to 2faeeae Compare June 3, 2026 20:23
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 on hold Can not fix yet 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 built-in math ProgramNodes

5 participants