Skip to content

Instantly share code, notes, and snippets.

@crazy4pi314
Last active September 13, 2022 22:27
Show Gist options
  • Save crazy4pi314/46ad75428b55ffe4a7baedc2a7d2401f to your computer and use it in GitHub Desktop.
Save crazy4pi314/46ad75428b55ffe4a7baedc2a7d2401f to your computer and use it in GitHub Desktop.
qat tutorial/sample use in Codespaces
  1. Open the qat codespace, and if it errors from being out of memory, locally clone and use remote dev containers to create docker
  2. Build qat tool with instructions here: https://qir-alliance.github.io/qat/UserGuide/BuildingLibrary/#:~:text=Build%20instructions%20for%20users
mkdir Debug
cd Debug
cmake ..
make qat
  1. Try running the built executable with some test QIR in the test folders here: https://github.com/qir-alliance/qat/tree/main/qir/qir-tests If you specifically use the inlining input *.ll file and the following options for qat:
codespace ➜ /home/qat/Debug (main ✗) $ ./qir/qat/Apps/Qat --apply --profile default -S /home/qat/qir/qir-tests/reduction_tests/inlining-input.ll

Then you should get the following output:

; ModuleID = 'qat-link'
source_filename = "qat-link"

%Qubit = type opaque

define void @SimpleLoop__Main() #0 {
entry:
  call void @SimpleLoop__Main__body()
  ret void
}

define internal void @SimpleLoop__Main__body() #1 {
entry:
  call void @SimpleLoop__MiniCircuit__body(%Qubit* null, %Qubit* nonnull inttoptr (i64 1 to %Qubit*))
  call void @SimpleLoop__MiniCircuit__body(%Qubit* null, %Qubit* nonnull inttoptr (i64 1 to %Qubit*))
  ret void
}

define internal void @SimpleLoop__MiniCircuit__body(%Qubit* %q1, %Qubit* %q2) #2 {
entry:
  call void @Microsoft__Quantum__Intrinsic__H__body(%Qubit* %q1)
  call void @Microsoft__Quantum__Intrinsic__H__body(%Qubit* %q2)
  call void @Microsoft__Quantum__Intrinsic__CNOT__body(%Qubit* %q1, %Qubit* %q2)
  ret void
}

define internal void @Microsoft__Quantum__Intrinsic__H__body(%Qubit* %qubit) #2 {
entry:
  call void @__quantum__qis__h__body(%Qubit* %qubit)
  ret void
}

define internal void @Microsoft__Quantum__Intrinsic__CNOT__body(%Qubit* %control, %Qubit* %target) #2 {
entry:
  call void @__quantum__qis__cnot__body(%Qubit* %control, %Qubit* %target)
  ret void
}

declare void @__quantum__qis__cnot__body(%Qubit*, %Qubit*)

declare void @__quantum__qis__h__body(%Qubit*)

attributes #0 = { "EntryPoint" "maxQubitIndex"="0" "maxResultIndex"="0" "requiredQubits"="0" "requiredResults"="0" }
attributes #1 = { "maxQubitIndex"="1" "maxResultIndex"="0" "requiredQubits"="2" "requiredResults"="0" }
attributes #2 = { "maxQubitIndex"="0" "maxResultIndex"="0" "requiredQubits"="0" "requiredResults"="0" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment