Skip to content

Instantly share code, notes, and snippets.

@craiglpeters
Forked from crazy4pi314/README.md
Last active September 13, 2022 23:32
Show Gist options
  • Save craiglpeters/332560d203d64b0f249c509df52937b5 to your computer and use it in GitHub Desktop.
Save craiglpeters/332560d203d64b0f249c509df52937b5 to your computer and use it in GitHub Desktop.
qat tutorial/sample use in Codespaces

This is an annotated version of the original

Note: I removed the relative paths from the devcontainer on this branch https://github.com/craiglpeters/qat/tree/devcontainer-opt and now the postCreateCommand runs successfully on codespace startup

Note: I tested pre-builds... testing in progress

Note: Testing postStartCommand to adutomate the build of qat: "postStartCommand": "mkdir Debug ; cd Debug ; cmake .. ; make qat ; ./qir/qat/Apps/qat --apply --profile default -S ../qir/qir-tests/reduction_tests/inlining-input.ll"

  1. Open the qat codespace, and if it errors from being out of memory, locally clone and use remote dev containers to create docker

Note: I used an 8 core Codespace with no problems

  1. 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

Note: Try pre-builds to do this step ahead of time for users https://docs.github.com/en/codespaces/prebuilding-your-codespaces

  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

Note: the executable qat is lower case Note: the path is /workspaces/qat/qir...

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