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

Expose hardware prng sequence #515

Merged
merged 1 commit into from
Feb 18, 2025

Conversation

erichulburd
Copy link
Contributor

@erichulburd erichulburd commented Nov 25, 2024

This PR supports two new features:

  • A CALL choose_random_real_sub_regions instruction.
  • A RandomizedMeasurement struct / class that will add per-shot randomized measurements to a program, as well as support the client in ascertaining which random unitary was played on each qubit per shot.

The documentation should stand on its own here. One note, I've put all of this functionality into qpu/experimental (both in Rust and Python). It is experimental both in the sense that it is an experimental feature in the QCS SDK that should not be considered stable as well as in the sense that it supports features relevant to QIS experimentalists.

Review Guidance:

  1. Start with crates/lib/src/qpu/experimental/random.rs.
  2. crates/lib/src/qpu/experimental/randomized_measurements.rs measurements builds off the primitives defined in the file above.
  3. Stubs for these features are defined in crates/python/qcs_sdk/qpu/experimental.pyi. Their implementation is defined in crates/python/src/qpu/experimental.pyi.
  4. There are corresponding tests for randomized measurements in crates/lib/src/qpu/experimental/randomized_measurements.rs and crates/python/tests/qpu/test_experimental.py.

@erichulburd erichulburd changed the title Expose hardware prng sequence Draft: Expose hardware prng sequence Nov 25, 2024
@erichulburd erichulburd force-pushed the expose_hardware_prng_sequence branch from 05c6136 to 276ea18 Compare November 25, 2024 16:46
@erichulburd erichulburd changed the title Draft: Expose hardware prng sequence Expose hardware prng sequence Dec 2, 2024
Copy link
Contributor

@Shadow53 Shadow53 left a comment

Choose a reason for hiding this comment

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

Partial review, will do more later.

Copy link
Contributor

@kalzoo kalzoo left a comment

Choose a reason for hiding this comment

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

Looking good, about ready to approve. I'm as uneasy as before about merging this experimental utility into the SDK itself, but it's the best option we have at the moment because of python binding & distribution. Your take here is neat, compartmentalized, and tested.

Things I'd like to see before merge:

  • A module doc as a general explainer about what's going on here. Doesn't have to specify a higher-level application but should give some context - as it is, I think almost any user might miss the point here.
  • A trustworthy explainer link for LFSR for context
  • A Rust e2e example under examples since it would require live QPU access

Thinking ahead: I'm also wondering if "program builder" or "program operator" is going to be a common pattern going forward and what that might look like. Doesn't block this PR, but I do wonder if a trait might help conceptually group tools like this in the mind of a user and help them understand how they're used:

trait ProgramOperator {
  fn apply(&self, program: Program) -> Result<Program, Self::Error> {
     ...
  }
}

@erichulburd
Copy link
Contributor Author

Looking good, about ready to approve. I'm as uneasy as before about merging this experimental utility into the SDK itself, but it's the best option we have at the moment because of python binding & distribution. Your take here is neat, compartmentalized, and tested.

Things I'd like to see before merge:

  • A module doc as a general explainer about what's going on here. Doesn't have to specify a higher-level application but should give some context - as it is, I think almost any user might miss the point here.
  • A trustworthy explainer link for LFSR for context
  • A Rust e2e example under examples since it would require live QPU access

Thinking ahead: I'm also wondering if "program builder" or "program operator" is going to be a common pattern going forward and what that might look like. Doesn't block this PR, but I do wonder if a trait might help conceptually group tools like this in the mind of a user and help them understand how they're used:

trait ProgramOperator {
  fn apply(&self, program: Program) -> Result<Program, Self::Error> {
     ...
  }
}
  • I've added a bit more flesh to the Rust and Python module documentation.
  • The e2e integration test passed for me locally.
  • I think Wikipedia is a good entrypoint for the LFSR algorithm and have linked it.

@erichulburd
Copy link
Contributor Author

I think Wikipedia is a good entrypoint for the LFSR algorithm and have linked it.

It's actually kind of difficult to find a concise and effective summary of LFSR that is not Wikipedia. If we want to avoid linking Wikipedia,: https://pylfsr.github.io/ may be our best best.

@erichulburd erichulburd force-pushed the expose_hardware_prng_sequence branch from 6eb7a7b to 3e4776b Compare February 18, 2025 23:23
@erichulburd
Copy link
Contributor Author

I've decided to separate out the random module from the randomized measurements. The latter is more feature complete, but the research thrust here does not strictly require it. If we want to extend support for that feature we can merge #536 .

@erichulburd erichulburd merged commit ed6b038 into rigetti:main Feb 18, 2025
1 of 2 checks passed
@erichulburd erichulburd deleted the expose_hardware_prng_sequence branch February 18, 2025 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants