changed 2 years ago
Published Linked with GitHub

Assignment 1

Paper

Term

  1. constant propagation
  2. value range propagation
  3. dead code elimination
  4. strength reduction
  5. register allocation

Main

A MLIR Dialect for Quantum Assembly Languages
Extend MLIR with a new quantum dialect that enables the expression and compilation of common quantum assembly languages.

Intro

The utility of this dialect -> ability to be lowered to the LLVM intermediate representation in a manner that is adherent to the QIR specification.

Provide a unified representation that quantum languages and compilers can map to in an effort to promote resurability of common quantum compilation tools, strategies, and backend runtime implementations.

Background

We put forward an extension to the MLIR infrastructure specifically for quantum computing, with the intention that any and all quantum languages are able to be parsed and mapped to an instance of this representation.

A Quantum MLIR Dialect

assembly -> Quantum co-processors by MLIR compiler framework
MLIR provides a mechanism for mapping IR down to assembly and object code via LLVM IR.

LLVM

source 1

https://llvm.org/
The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
Despite its name, LLVM has little to do with traditional virtual machines.
The name "LLVM" itself is not an acronym ; it is the full name of the project.

The goal of providing a modern, SSA-based compilation strategy capable of supporting both static and dynamic compilation of arbitrary programming languages.

SSA

wiki
SSA is a property of an intermediate representation (IR) that requires each variable to be assigned exactly once and defined before it is used. Existing variables in the original IR are split into versions, new variables typically indicated by the original name with a subscript in textbooks, so that every definition gets its own version. In SSA form, use-def chains are explicit and each contains a single element.

Install qcor and test with case

installation

Can not be install on Ubuntu 22.04.
either use script provided by Github:qcor or build everythings from source

Ubuntu 20.04 can just run the script and the installation will be complete.

/bin/bash -c "$(curl -fsSL https://aide-qc.github.io/deploy/install.sh)"

Test

1

The sample code provided by the main paper can be compiled but can't run on linux.

Illegal instruction (core dumped)

The code from QASMBench cannot be compiled.

[qcor-mlir] Reported Error: see current operation: %21 = "quantum.value_inst"(%10, %19, %c0_i64_12, %20) {name = "u3", operand_segment_sizes = dense<[1, 3]> : vector<2xi32>} : (!quantum.Qubit, f64, i64, f64) -> !quantum.Qubit
loc("bell_n4":14:0): error: 'quantum.value_inst' op operand #2 must be 64-bit float, but got 'i64'
[qcor-mlir-tool] MLIR-to-LLVM_MLIR lowering failed.
[qcor-exec] fatal error.

2

When trying to linked to qcor c++ code, it seems the include_qcor_qasm(bell) needed to be provided.

Code

pip install qiskit -U
pip install qiskit-ibm-runtime -U

from qiskit_ibm_runtime import QiskitRuntimeService

# Save an IBM Quantum account.
QiskitRuntimeService.save_account(channel="ibm_quantum", token="ca7828fbe535ecc506f6446d52647464a1dd43036ee95d49c62f25bdaec42bbbe4281fd84cd3b9e4e58b2430c7012269fe056cd567fb5006ff83a6c42b50bae0")

from qiskit import *
from qiskit_ibm_runtime import QiskitRuntimeService

service = QiskitRuntimeService()
backend = service.get_backend("ibmq_qasm_simulator")

qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0,1)
qc.measure_all()

sampler = Sampler(session=backend)
job = sampler.run(circuits)
print(f"job id: {job.job_id()}")
result = job.result()
print(f" > Quasi probability distribution: {result.quasi_dists[0]}")
Select a repo