pyGSTi icon indicating copy to clipboard operation
pyGSTi copied to clipboard

Various QILGST bugfixes

Open sserita opened this issue 1 year ago • 18 comments

Describe the bug There are several bugs that have been discovered regarding QILGST in v0.9.11.2 during the addition of support for IBMQ experiments with midcircuit measurements. This is a thread to keep track of them all, as well as when/where they are fixed. The below list will be updated as individual bugs are added/resolved.

Critical issues (0.9.13)

  • [x] Parallelization of GST analysis for quantum instruments @sserita
  • [x] #460 @sserita
  • [ ] #459 @coreyostrove
  • [ ] #461 @pcwysoc
  • [ ] #465 @coreyostrove

Feature requests (0.9.14+)

  • [ ] #463 @sserita
  • [ ] #464 @coreyostrove
  • [ ] #462 @pcwysoc @kmrudin @coreyostrove

Resolved issues

  • [x] StandardGST fails to run for QILGST (fixed in #349)
  • [x] Dim mismatch in HTML reports for instrument ddist (fixed in #349)
  • [x] Cannot pickle thread locks in IBMQExperiment.write() (applies to both QI and no-QI experiments) (fixed in #359)
  • [x] Instruments are not JSON-able in IBMQExperiment.write() (fixed in #359)
  • [x] Deprecation of id instruction in IBMQ (fixed in #359)
  • [x] Better printing for outcome labels in reports
  • [x] Get HTML working with additional germs (see [MoreGermsHTML.zip] (https://github.com/pyGSTio/pyGSTi/files/12667373/MoreGermsHTML.zip)) (fixed in #359)
  • [x] Auto embedding for QIs (fixed in #359)

Environment (please complete the following information):

  • pyGSTi 0.9.11.2+ (feature-qiskit-mcm branch mostly)
  • python 3.10

Cannot pickle locks: pickle lock

QI not JSON-able (occurred when trying to write combined experiment): Screenshot 2023-09-25 at 10 19 32 AM

Deprecated id: deprecated id

Outcome labels in reports: outcome labels

HTML with additional germs: Screenshot 2023-09-19 at 6 06 01 PM

sserita avatar Sep 19 '23 23:09 sserita

I have one more bug report--would you prefer I send it over email, comment it here, or add it to the initial comment? Thanks for following up on this! I'll also endeavor to learn the GitHub process as I'm still rather new to it.

pcwysoc avatar Sep 19 '23 23:09 pcwysoc

Haha you beat me to it! Yes please go ahead and add it here. If you can edit the initial comment to make a new checkbox item that would be awesome. But you may not be able to, in which case you can just make a new comment and I will update the initial comment.

sserita avatar Sep 19 '23 23:09 sserita

Looks like you can edit that initial comment, so that's awesome. If you have a minimum working example and could upload it also, that would be super helpful.

sserita avatar Sep 19 '23 23:09 sserita

I'm trying to figure out where to upload that right now. Where did you put the Wildcard file?

pcwysoc avatar Sep 20 '23 00:09 pcwysoc

When you edit the comment, do you have a "Attach filed by dragging & dropping" down at the very bottom? I drag & dropped the file there, and then it should just give you some Markdown text with a caption in square braces and a link in parenthesis. Don't change the link, but you can change the caption in square braces and then copy/paste that whole text string wherever you want (i.e. next to the item in the list would be great).

sserita avatar Sep 20 '23 00:09 sserita

Just updated the main comment--ran into another issue when trying to write an IBMQ Experiment.

pcwysoc avatar Sep 25 '23 16:09 pcwysoc

Here's another aspect that I don't necessarily want to add to the main comment since it isn't a bug fix. Currently, quantum instruments don't have an equivalent to "EmbeddedOp" and 1Q quantum instruments cannot be automatically embedded into 2Q+ state space. This will be fairly critical to expanding QILGST support and the current work I'm doing. Here's the current error message: Screenshot 2023-09-25 at 2 43 07 PM

I'm willing to work on it on it but could use a walk through of the auto embedding code for operations as it can be a bit circular at times and I'm unsure of which aspects would be critical to replicate in the short term for quantum instruments.

pcwysoc avatar Sep 25 '23 20:09 pcwysoc

I think I have an (incomplete) version of auto embedding for QIs working!

pcwysoc avatar Sep 27 '23 00:09 pcwysoc

I have a patch on the html problem! The problem is on lines 1215 and 2443 of workspacetable.py and affects two tables: GateVsTargetTable and GateEigenvalueTable. I think both appear in the "Germs Detail" section of the report. The code was hardcoded for all germs in 'virtual_ops' that were not a single quantum instrument to be treated as gate germs. I added a line enforcing that those additional germs be fully composed of gates, which results in the mixed instrument gate germs being skipped. The html report now generates, but the germs detail section is somewhat incomplete. At this point, this is not a problem for the project. I'll push the fix shortly.

pcwysoc avatar Oct 11 '23 21:10 pcwysoc

Additional feature requests (not urgent and may require some thought):

  • [ ] Calculating instrument error metrics which are currently blank
  • [ ] Calculating germ details for instrument and instrument + gate germs
  • [ ] Quantifying "weakness" quantum instrument error and readout/assignment errors using Robin's framework

pcwysoc avatar Oct 12 '23 20:10 pcwysoc

I think I found the root bug for the non-JSONable instruments on IBMQExperiment.write(). The processor spec associated with the initial StandardGSTDesign includes the instrument in a non-JSONable form in 'nonstd_instruments.' This means that the ProtocolData can't be written:

Screenshot 2023-10-18 at 10 14 01 AM

Additionally, there seems to be a bug where standard gate unitaries are included in 'nonstd_gate_unitaries.' Is there a reason why this is done? I can pretty easily fix it. See this notebook for details of both of the above. nonstd_gates_and_instruments_bugs.ipynb.zip

Some of this seems to trace back to there being no concept of a standard instrument (as is the case for gates in internalgates.py) and my incomplete implementation of an embedded instrument (modelmembers/instruments/EmbeddedInst.py). I think the "'nonstd_instruments' ProtocolData" and the "standard gate unitaries reported as nonstandard gate unitaries" bugs come in with the definition of 'create_processor_spec' in ExplicitModel.py. I think something like 'extract_unitary' needs to be written for instruments and the processor spec needs to be defined so that the standard gate unitaries don't get listed as nonstandard gate unitaries.

I'm a bit stuck right now on the instrument problem, as the 'extract_unitary' function is a bit obtuse to me.

pcwysoc avatar Oct 18 '23 16:10 pcwysoc

More complete bug report for the above (gives a non-working example of the ProtocolData error message): nonstd_gates_and_instruments_bugs_new.ipynb.zip

pcwysoc avatar Oct 23 '23 16:10 pcwysoc

The thread.lock bug is now fixed in d5807e7. @pcwysoc we should merge this into your branch tomorrow.

sserita avatar Oct 28 '23 07:10 sserita

The pspec instrument JSON bug is now fixed in bf2a082.

sserita avatar Oct 28 '23 08:10 sserita

The feature-ibm-devices branch was merged into develop in #359, so all the items labeled as fixed should be live in develop.

sserita avatar Nov 17 '23 17:11 sserita

@sserita It looks like the pspec instrument bug never really died. I made a mistake while testing it and it appears there's some subtle differences in the pspec after loading from a directory that causes GST to run. Here's a notebook exhibiting the problem: IBMWritePspecBugAliveAgain.ipynb.zip

I'm planning to take a look, since it appears to be a simple problem. It is not blocking as I have work arounds for this issue.

pcwysoc avatar Nov 17 '23 17:11 pcwysoc

I just implemented some fixes (not yet committed) for text wrapping of the hover labels.

pcwysoc avatar Nov 22 '23 18:11 pcwysoc

@sserita Just rearranged and added the three issues we discussed.

pcwysoc avatar May 15 '24 16:05 pcwysoc