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

docs(notebooks): add utility scaling demo #20

Merged
merged 10 commits into from
Mar 30, 2024
Merged

docs(notebooks): add utility scaling demo #20

merged 10 commits into from
Mar 30, 2024

Conversation

pedrorrivero
Copy link
Member

@pedrorrivero pedrorrivero commented Feb 28, 2024

Summary

Adds Utility Scaling demo notebook cleaned and updated to Qiskit 1.0.

Details and comments

Requires merging of the following PRs first:

All code plus notebook can be found in the scaling branch of this repository for ease of access and execution. This is the way it has been shared since it was ready with people that required early access (e.g. for preparation of Practitioner's Forum APAC).

This PR is meant to provide a place to review the notebook in isolation.

@pedrorrivero pedrorrivero added PL-2 Priority level 2/5 → Medium-high notebook Notebook improvements or additions labels Feb 28, 2024
@pedrorrivero pedrorrivero self-assigned this Feb 28, 2024
@coveralls
Copy link

coveralls commented Feb 28, 2024

Pull Request Test Coverage Report for Build 8489985288

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 8489909505: 0.0%
Covered Lines: 290
Relevant Lines: 290

💛 - Coveralls

@pedrorrivero
Copy link
Member Author

Tests seem to fail due to the name of the file holding the cached results being invalid for Windows:

> Run actions/checkout@v3
Syncing repository: IBM-Quantum-Technical-Enablement/quantum-enablement
> Getting Git version info
Temporarily overriding HOME='D:\a\_temp\e528dd69-442a-4685-be32-65faa8c21fe5' before making global git config changes
Adding repository directory to the temporary git global config as a safe directory
"C:\Program Files\Git\bin\git.exe" config --global --add safe.directory D:\a\quantum-enablement\quantum-enablement
Deleting the contents of 'D:\a\quantum-enablement\quantum-enablement'
> Initializing the repository
> Disabling automatic garbage collection
> Setting up auth
> Fetching the repository
> Determining the checkout info
v Checking out the ref
  "C:\Program Files\Git\bin\git.exe" checkout --progress --force refs/remotes/pull/20/merge
  Error: error: invalid path 'docs/notebooks/scaling/12x12_2024-02-16T18:40:[14](https://github.com/IBM-Quantum-Technical-Enablement/quantum-enablement/actions/runs/8084536689/job/22090468670?pr=20#step:2:15).0352[19](https://github.com/IBM-Quantum-Technical-Enablement/quantum-enablement/actions/runs/8084536689/job/22090468670?pr=20#step:2:21)+00:00.json'
  Error: The process 'C:\Program Files\Git\bin\git.exe' failed with exit code 128

@itoko
Copy link

itoko commented Mar 6, 2024

I've just found average_distributions function should handle the edge case where the count of all-zero state is 0. Current notebook sometimes fails with ValueError when plotting the "Readout probabilities at different noise levels" figure. An example of half-baked figure looks like below (xval label 1024 suggests all-zero state was not observed within the shots xval label 1024 suggests all-zero state does not have the largest counts).

ValueError: The number of FixedLocator locations (3), usually from a call to set_ticks, does not match the number of labels (2).

image

@itoko
Copy link

itoko commented Mar 6, 2024

Another small comment is datetime.UTC seems not in Python 3.10. If we want to support 3.10 or earlier, we many need to use datetime.timezone.utc instead.

@pedrorrivero
Copy link
Member Author

pedrorrivero commented Mar 12, 2024

Thanks for the comments @itoko 🙇🏼‍♂️

Although we have chatted already I will include my responses here for transparency.

The ValueError that you report is merely for plotting, the rest of the notebook should run smoothly nonetheless. This code should be able to fix it thought:

from qiskit.visualization import plot_distribution
from copy import deepcopy
import matplotlib.pyplot as plt

plt.rcParams.update({"text.usetex": True, "font.family": "Helvetica"})
fig, ax = plt.subplots(dpi=200)

ACCURATE_READOUT = "0" * NUM_QUBITS
plots_dict = deepcopy(results_dict)
plots_dict = {
    nf: {"0": counts.pop(ACCURATE_READOUT), "1": sum(counts.values())}
    for nf, counts in plots_dict.items()
}

plot_distribution(
    [plots_dict.get(nf) for nf in NOISE_FACTORS], 
    legend=[f"Noise factor: {nf:.1f}" for nf in NOISE_FACTORS],
    color=['lightgray', 'gray', 'black'],
    title="Readout probabilities at different noise levels",
    ax=ax,
)
ax.set_xticklabels(['Accurate', 'Error'], rotation=0)
ax.legend(fontsize=11)

plt.show()

@itoko
Copy link

itoko commented Mar 14, 2024

We need to change the file name 12x12_2024-03-12T21:18:13.498254+00:00.json not to use ":" in it for Windows users. Otherwise, windows users fail to install quantum-enablement module, i.e. they are not able to do pip install quantum-enablement@git+https://github.com/IBM-Quantum-Technical-Enablement/quantum-enablement. I heard it today from a windows user.

@pedrorrivero pedrorrivero marked this pull request as ready for review March 27, 2024 20:03
Copy link
Contributor

@miamico miamico left a comment

Choose a reason for hiding this comment

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

I'm unable to comment this notebook line by line (source code is not viewable online), so I'll give my review in this comment:

  1. "To this end, we will begin studying conceptually different hardware-native quantum circuits, that will turn out equivalent in practice"
    There is a caveat here which explains why the different circuits which you consider all turn out to give similar circuit structure: i) MBL and TFIM dynamics are both Hamiltonian simulation tasks and QAOA again relies on time-evolution generated by the problem Hamiltonian so not that different from a Hamiltonian simulation task. ii) In all circuits you have assumed the same topology, Hamiltonian with nearest neighbor interaction for qubits on a line.
    For these reasons the circuits end up all looking similar to each other. So instead of claiming this is a generic structure for quantum circuits, you could say that Hamiltonian simulation task is widely used in quantum computing.

  2. "Then we will introduce a derivative form of the above circuits in order to address result validation: compute-uncompute."
    Let's not introduce new terminology (or reference it if use it elsewhere). Circuit constructed by appending $U^{\dag}$ to $U$ are commonly known as mirror circuits. Let's use this terminology which is already in use in the community.

  3. "Twirling or randomized compiling is a well known and widely used technique for converting arbitrary noise channels into Pauli channels (e.g. depolarizing noise)."
    This is incorrect. Twirling is a technique to taylor the noise. Depending on the gates used in the twirling bases, you may end up with Pauli noise (or not). See this reference for a comprehensive and straightforward introduction to twirling: https://glassnotes.github.io/OliviaDiMatteo-Unitary2Designs.pdf

  4. "Unfortunately, idle qubits decohere more easily than those on which operations are being applied. "
    This statement is also not generally correct. In fact, there is plenty of research showing that T2 is smaller for driven qubits than the one measured when they are idle. The actual problem is that the qubits in our device are always coupled to each other and the crosstalks effect induced by this coupling can induce coherent errors on the idling qubits when circuits with more than 2 qubits are considered.

  5. "single-qubit measurement obfuscation matrices"
    I never heard this term, shouldn't this be confusion matrices (for example https://mitiq.readthedocs.io/en/stable/guide/rem.html)

miamico
miamico previously approved these changes Mar 29, 2024
Copy link
Contributor

@miamico miamico left a comment

Choose a reason for hiding this comment

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

Awesome, looks great to me now! :D

@pedrorrivero pedrorrivero merged commit 5a029fb into main Mar 30, 2024
11 checks passed
@pedrorrivero pedrorrivero deleted the scaling-demo branch March 30, 2024 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
notebook Notebook improvements or additions PL-2 Priority level 2/5 → Medium-high
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants