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

[Quantum Resource Estimation] Add support for executing Q# files/projects #1923

Open
Manvi-Agrawal opened this issue Sep 18, 2024 · 3 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@Manvi-Agrawal
Copy link
Contributor

Manvi-Agrawal commented Sep 18, 2024

Is your feature request related to a problem? Please describe.
It would be nice for the resource estimator tool to be able to support resource estimation for code in Q# file/Q# projects. I would like to know the opinion of QDK folks. @msoeken @tcNickolas @swernli @billti thoughts? If majority of people think that its not very useful, I am happy to close this issue :-)

Describe the solution you'd like
An abstract layer in the resource estimator tool provided by Q#. See #1915 (comment) for more details.

Describe alternatives you've considered
Write the code to compile the Q# code when the need arises. I feel that might be an extra burden for users who might not be familiar with interpreter and Package store API in Q# compiler.

Additional context
In #1915, Mathias introduced a sample detailing how to do that. I appreciate the sample detailing ability to do resource estimation from Q# file. Given that interpreter and Package store objects might be unfamiliar to many users, I think it might be helpful to provide a more abstract layer in the resource estimator tool provided by Q#. See #1915 (comment) for more details.

@Manvi-Agrawal Manvi-Agrawal added enhancement New feature or request needs triage labels Sep 18, 2024
@Manvi-Agrawal Manvi-Agrawal changed the title [Quantum Resource Estimation] Add support for executing Q# sample [Quantum Resource Estimation] Add support for executing Q# files/projects Sep 18, 2024
@swernli
Copy link
Collaborator

swernli commented Sep 30, 2024

If I understand correctly, you are looking for an easy way to compile Q# files from Rust, correct? We do have ways to accomplish this from Python/Jupyter, specifically either the qsharp.eval function used on the contents read from a single file or using qsharp.init with optional project path parameter to load a project with multiple files from disk. Given the input to the customized resource estimation in Rust is logical counts, I would expect someone to use these existing methods to compile and estimate their Q# from Python, grab the logical counts, and either programmatically or manually feed those as input to their customized resource estimation. If that flow is followed, exposing additional Rust APIs for processing Q# files directly wouldn't be needed. If the user is not engaging with a customized, Rust-based resource estimation and instead just wants to use the existing algorithms and parameters of the product Resource Estimator, they can follow samples like this one to perform the estimation via Python: https://github.com/microsoft/qsharp/blob/main/samples/estimation/estimation-hardcoded-circuit.ipynb.

Does that match your question, or have I misunderstood the desired functionality?

@sezna sezna added question Further information is requested and removed needs triage labels Oct 14, 2024
@Manvi-Agrawal
Copy link
Contributor Author

Thanks @swernli for the explanation. I didn't look thoroughly into the Rust example added. Based on the above explanation and quick glance over the sample and the abstract of the research paper, it seems to me that one should use rust resource estimator for :

  • experimental features
  • Lesser used functionality: like PSSPC layout for physical count calculation from logical count.

Is my understanding correct? This time I am curious to know how does one decide between using Python+Q# or Rust based estimator.

@swernli
Copy link
Collaborator

swernli commented Oct 16, 2024

@msoeken should chime in here, but essentially there are two main resource estimation scenarios that we document and recommend right now:

  1. Within VS Code - ideal for quickly getting started and trying algorithms that are expressed as one or Q# files, where estimates can be calculated from a selection of preconfigured types with some settable values (like error budget).
  2. Using Python/Jupyter - the majority case, where you either are using longer-runner or larger Q# algorithms (or bringing logical counts from some other tooling) and want to configure specific details about the estimation by setting values directly in the json inputs. I expect this is what most folks using RE to support papers where they want to use the PSSPC layout that the estimator uses by default.

Only these two are described in our documentation for now. The newer configurability that @msoeken is working on at the Rust layer is for folks who want to customize deeper elements of how the RE infrastructure calculates its estimates, including changing from PSSPC to other layout strategies. For now, that is only documented in the readme files and code comments within the repo and is targeted at advanced users who aren't afraid to dive into writing Rust code to access these newer, more detailed configuration features.

To give scenario 1 a try yourself to see how easy it is to get started, you can navigate to the VS Code Playground, open the "Shor (Resource Estimation).qs" file, and either use the command palette entry "Q#: Calculate Resource Estimates" or the handy "Estimate" code lens:
Image
Configure your options, and then generate a set of estimates across a frontier of trade-offs between time and number of qubits for each of the chosen qubit technologies:
Image

You can read more about this in the docs at Different ways to run the Resource Estimator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants