Package: test-JaqalPaq
JaqalPaqJaqalPaq is a python package used to parse, manipulate, emulate, and generate
quantum assembly code written inJaqal(Just another quantum assembly language).  JaqalPaq can be installed with
optional transpilers that convert code written in other quantum assembly
languages to a version of Jaqal whose native gates are relevant forQSCOUT(Quantum Scientific Computing Open User
Testbed).CodeJaqalPaq is available onGitLabunder
the Apache 2.0 License.InstallationTLDR: Inside a venv/conda env:pipinstallCythonnumpy
pipinstallipykernelJaqalPaq[pygsti-integration]QSCOUT-gatemodels
ipythonkernelinstall--user--name=jaqalStep 0: Prepare base dependenciesJaqalPaq requires Python 3.6 (or later), but Python 3.7 (or later) is
recommended.  To check your installed version, runpython3--versionWindows users are encouraged to install under WSL2.  You may also considerconda, which provides a platform-independent Python
installation.We also recommend having Python headers installed.  Check for headers by
runningpython3-config--includesOn apt-based systems, headers can be installed by running (as root)aptinstallpython3-devOn rpm-based ones,yuminstallpython3-develMac users may need to install XCode to ensure they have a functional C++
compiler.Conda users should have these header files installed automatically.Step 1: (recommended) Prepare a virtual environmentWARNING: JaqalPaq's dependencies may sometimes conflict with each other.
Upgrading may introduce incompatible versions, and for this reason we
STRONGLY recommend installing within some kind of virtual environment.To create a Python virtual environment, runpython3-mvenv/path/to/venvThe location of the venv is left to your discretion, but please be aware that
a full installation will be ~100s of megabytes.To create a conda virtual environment, runcondacreate--nameyour-preferred-namepython=3.9To enter the virtual environment, runsource/path/to/venv/bin/activateorcondaactivateyour-preferred-namerespectively.NOTE: All following steps should be performed inside the virtual
environment.  If you close your terminal, you will have to enter the virtual
environment again, using the appropriate command above.Jupyterusers can install a kernel to access this
virtual environment by runningpipinstallipykernel
ipythonkernelinstall--user--name=preferred-nameNOTE: Restart the Jupyter server.  A new kernel will be available.If you no longer want that kernel, you can remove it withjupyterkernelspecremovepip-jaqalNOTE: Unlike every other command, this must be performed from the
environment in which Jupyter is installed, and NOT the JaqalPaq environment.Step 2: (recommended) Emulator pre-dependenciesJaqalPaq includes an emulator that can provide measurement probabilities for
any native gate set.  This capability requirespyGSTi, which pre-depends on Cython and numpy:pipinstallCythonnumpyNOTE: pyGSTi will produce warnings if you do not have Python development
headers installed as recommended in Step 0.Step 3: Install JaqalPaqJaqalPaq packages are provided withpip.WARNING: Some dependencies may conflict with each other.  Be sure to
include all desired dependencies on this line.  It is safe to re-run the
whole command with a new desired feature set.pipinstallJaqalPaq'[pygsti-integration,notebooks]'QSCOUT-gatemodels\JaqalPaq-extras'[qiskit,pyquil,cirq,projectq,pytket,tutorial]'pygsti-integrationprovides the emulator.notebooksinstalls all dependencies for the chemistry example notebookQSCOUT-gatemodelsprovides the native gates of theQSCOUTproject , which are modeled as
pure-state  preparations, unitary transformations, and destructive
measurements. SeeQSCOUT-gatemodelsfor
details.The five transpiler targets for JaqalPaq-extras each install a compatible
version of the respective third-party package.tutorialinstalls an additional dependency required for the
JaqalPaq-extras tutorial notebook to run.NOTE: Thenotebooks,qiskit,pyquil,cirq,projectq,pytket,
andtutorialtargets will install a large number of third-party packages.
You should consider only installing the subset of these packages that you
plan on using.UsageThe following simple example is fromexamples/usage_example.pyimportjaqalpaqfromjaqalpaq.parserimportparse_jaqal_filefromjaqalpaq.emulatorimportrun_jaqal_circuitfromjaqalpaq.generatorimportgenerate_jaqal_programJaqalCircuitObject=parse_jaqal_file("jaqal/Sxx_circuit.jaqal")JaqalCircuitResults=run_jaqal_circuit(JaqalCircuitObject)print(f"Probabilities:{JaqalCircuitResults.subcircuits[0].probability_by_str}")JaqalProgram=generate_jaqal_program(JaqalCircuitObject)The Jaqal file processed by this example,examples/jaqal/Sxx_circuit.jaqal, isfromqscout.v1.stdusepulses*registerq[2]prepare_allSxxq[1]q[0]measure_allMore extensive examples, including detailed Jupyter notebooks implementing the
variational quantum eigensolver (VQE) quantum algorithm for some simple
molecules, can be found in theexamplesdirectory.For information on the JaqalPaq emulator's command-line interface, run the
following in your shell:jaqal-emulate--helpTesting and examplesUnderneath your environment prefix, navigate toshare/jaqalpaq.  Inside a
venv, runcd"$VIRTUAL_ENV/share/jaqalpaq"or, inside a conda environment,cd"$CONDA_PREFIX/share/jaqalpaq"Example Jaqal files, as well as tutorials and example quantum chemistry
calculations are in theexamples/directory.  To run the tests, first
install pytest,pipinstallpytestand then run it on thetests/directory:pytesttestsDocumentationOnline documentation is hosted onRead the Docs.LicenseApache 2.0Questions?For help and support, please contactqscout@sandia.gov.