microsoft / QuantumKatas

Tutorials and programming exercises for learning Q# and quantum computing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use DumpUnitary utility in UnitaryPatterns notebook

Manvi-Agrawal opened this issue · comments

I tried the following steps:

  1. Built the DumpUnitary project to produce a NuGet package.
  2. Copied the generated .nupkg file to the UnitaryPatterns kata.
  3. Set up NuGet.config file so that it allows the project to discover a NuGet package in the current folder in addition to the standard sources.
  4. Added the following cells in IQ# notebook
%package DumpUnitary::1.0.0
%workspace reload
open Quantum.DumpUnitary;
%simulate DumpUnitaryToFiles N=3 unitary=MainDiagonal

Getting the following error when running simulate

Received invalid parameters. Please fix and try again:
 unitary: Error converting value "MainDiagonal" to type 'Microsoft.Quantum.Simulation.Core.ICallable'. Path '', line 1, position 14.

I've never tried calling DumpUnitary from Q# notebooks (it's so old it predates the notebooks support for Q#!), but I think %simulate doesn't like taking a callable as a parameter. I'd suggest writing a wrapper operation without any parameters that would call DumpUnitary with the parameters you want, and %simulate that operation.

Thank you @tcNickolas for the help. Now, I am able to call it through UnitaryPattern notebook

Great!
Just to offer another option, you can use DumpOperation similarly to dump the raw matrix, without conversion to a pattern, if you need more information about the unitary.

Thank you @tcNickolas. Would be glad to try it out.