Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add qk_obs_compose(_map) #13950

Merged
merged 3 commits into from
Mar 3, 2025
Merged

Add qk_obs_compose(_map) #13950

merged 3 commits into from
Mar 3, 2025

Conversation

Cryoris
Copy link
Contributor

@Cryoris Cryoris commented Mar 3, 2025

Summary

Adds composition for the C-side SparseObservable.

Goes on top of #13766.

Details and comments

  • No reno as C API not yet released
  • Is the pointer-reading in compose_map legit?

@Cryoris Cryoris added the C API Related to the C API label Mar 3, 2025
@Cryoris Cryoris requested a review from a team as a code owner March 3, 2025 16:28
@qiskit-bot
Copy link
Collaborator

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

  • @Qiskit/terra-core

@coveralls
Copy link

coveralls commented Mar 3, 2025

Pull Request Test Coverage Report for Build 13637252625

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 3 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.03%) to 87.11%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 1 92.23%
crates/accelerate/src/unitary_synthesis.rs 2 94.39%
Totals Coverage Status
Change from base Build 13636184568: 0.03%
Covered Lines: 75845
Relevant Lines: 87068

💛 - Coveralls

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
Copy link
Member

@jakelishman jakelishman left a comment

Choose a reason for hiding this comment

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

Thanks for writing the tests to not rely on the particular factorisation, haha.

edit: this review is mostly just formalising conversations Julien and I had offline, for posterity. They should already be resolved by 5d7a5a9.

Comment on lines 686 to 692
/// # Safety
///
/// To call this function safely
///
/// * ``left`` or ``right`` must be valid, non-null pointers to ``QkObs``\ s
/// * ``qargs`` must point to an array of ``uint32_t``, readable for ``qk_obs_num_qubits(left)``
/// elements (meaning the number of qubits in ``left``)
Copy link
Member

Choose a reason for hiding this comment

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

Let's comment that qargs can be null if left.num_qubits is 0 (this is useful behaviour for C and C++), and then make sure our own code handles that safely too.

Copy link
Member

@jakelishman jakelishman left a comment

Choose a reason for hiding this comment

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

Ace, the changes in the latest commit address everything I'd said (as expected), thanks.

We might have included explicit documentation that qargs can be null if second.num_qubits was zero, but in C land that's usually the case, so it's no big deal at all. I'll just merge as-is.

@jakelishman jakelishman enabled auto-merge March 3, 2025 18:04
@jakelishman jakelishman added the Changelog: None Do not include in changelog label Mar 3, 2025
@jakelishman jakelishman added this to the 2.0.0 milestone Mar 3, 2025
@jakelishman jakelishman added this pull request to the merge queue Mar 3, 2025
Merged via the queue into Qiskit:main with commit 731e474 Mar 3, 2025
21 checks passed
@Cryoris Cryoris deleted the qkobs-compose branch March 4, 2025 07:15
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: None Do not include in changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants