Loading docker/qsharp/Dockerfile 0 → 100644 +30 −0 Original line number Diff line number Diff line FROM mcr.microsoft.com/dotnet/core/sdk:3.1-focal # Mono is required to run pack.ps1, so we install it here. RUN apt-get -y update && \ apt-get -y install dirmngr gnupg apt-transport-https ca-certificates && \ apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF && \ sh -c 'echo "deb https://download.mono-project.com/repo/ubuntu stable-focal main" > /etc/apt/sources.list.d/mono-official-stable.list' && \ apt-get -y update && \ apt-get -y install mono-complete && \ apt-get clean && rm -rf /var/lib/apt/lists/ # We can now get Mono itself. RUN curl -o /usr/local/bin/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe && \ # Create as alias for nuget echo "alias nuget=\"mono /usr/local/bin/nuget.exe\"" >> /root/.bash_aliases # Install qsharp compiler from source RUN git clone https://github.com/microsoft/qsharp-compiler.git RUN cd qsharp-compiler && export SOURCE_DIR=${PWD} && cd src/QsCompiler/CommandLineTool && dotnet build && \ echo "export PATH=${PATH}:${SOURCE_DIR}/src/QsCompiler/CommandLineTool/bin/Debug/netcoreapp3.1/" >> /root/.bashrc && \ echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${SOURCE_DIR}/src/QsCompiler/QirGeneration/Llvm.Net/runtimes/linux-x64/native" >> /root/.bashrc && \ # Build QirGeneration extension cd ${SOURCE_DIR}/src/QsCompiler/QirGeneration && dotnet build && \ # Export the DLL location to an environment variable. echo "export QIR_GEN_DLL=${SOURCE_DIR}/src/QsCompiler/QirGeneration/bin/Debug/netstandard2.1/Microsoft.Quantum.QirGeneration.dll" >> /root/.bashrc RUN apt-get update && apt-get -y install cmake gcc g++ clang-format libcurl4-openssl-dev libunwind-dev libpython3-dev python3-pip libblas-dev liblapack-dev lsb-release && \ wget -qO- https://aide-qc.github.io/deploy/aide_qc/debian/PUBLIC-KEY.gpg | apt-key add - && \ wget -qO- "https://aide-qc.github.io/deploy/aide_qc/debian/$(lsb_release -cs)/aide-qc.list" | tee -a /etc/apt/sources.list.d/aide-qc.list && \ apt-get update && apt-get -y install aideqc-llvm && \ pip3 install cmake No newline at end of file examples/qsharp/FTQC/Bell/bell.qs +1 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ namespace QCOR // Using QCOR Intrinsic instruction set // see QirTarget.qs open QCOR.Intrinsic; @EntryPoint() operation TestBell(count : Int) : Int { // Simple bell test mutable numOnes = 0; Loading examples/qsharp/FTQC/Bell/bell_driver.cpp +8 −5 Original line number Diff line number Diff line Loading @@ -2,17 +2,20 @@ #include <vector> // Include the external QSharp function. qcor_include_qsharp(QCOR__TestBell__body, int64_t, int64_t) // With EntryPoint() annotation, there are 3 functions generated: // QCOR__TestBell__body(): raw Q# callable // QCOR__TestBell(): EntryPoint type (with result printing), no return // QCOR__TestBell__Interop(): InteropFriendly function (type casting to C-type function) qcor_include_qsharp(QCOR__TestBell, void, int64_t) // Compile with: // Include both the qsharp source and this driver file // in the command line. // $ qcor -qrt ftqc bell.qs bell_driver.cpp // -qs-build-exe to activate entry point generation. // $ qcor -qrt ftqc -qs-build-exe bell.qs bell_driver.cpp // Run with: // $ ./a.out int main() { auto oneCounts = QCOR__TestBell__body(1024); std::cout << "Result = " << oneCounts << "\n"; QCOR__TestBell(1024); return 0; } No newline at end of file examples/qsharp/FTQC/EntryPoint/qs_standalone.qs 0 → 100644 +33 −0 Original line number Diff line number Diff line namespace QCOR { // Using QCOR Intrinsic instruction set // see QirTarget.qs open QCOR.Intrinsic; @EntryPoint() operation ValidEntryPoint() : Unit { } @EntryPoint() operation TestBell(count : Int) : Unit { // Simple bell test mutable numOnes = 0; mutable agree = 0; use q = Qubit[2]; for test in 1..count { H(q[0]); CNOT(q[0],q[1]); let res0 = M(q[0]); let res1 = M(q[1]); if res0 == res0 { set agree += 1; } // Count the number of ones we saw: if res0 == One { set numOnes += 1; } Reset(q[0]); Reset(q[1]); } } } No newline at end of file examples/qsharp/NISQ/bell.qs 0 → 100644 +14 −0 Original line number Diff line number Diff line namespace QCOR { open QCOR.Intrinsic; operation Bell(qubits : Qubit[]) : Unit { H(qubits[0]); for index in 0 .. Length(qubits) - 2 { CNOT(qubits[index], qubits[index + 1]); } for qubit in qubits { let res = M(qubit); } } } No newline at end of file Loading
docker/qsharp/Dockerfile 0 → 100644 +30 −0 Original line number Diff line number Diff line FROM mcr.microsoft.com/dotnet/core/sdk:3.1-focal # Mono is required to run pack.ps1, so we install it here. RUN apt-get -y update && \ apt-get -y install dirmngr gnupg apt-transport-https ca-certificates && \ apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF && \ sh -c 'echo "deb https://download.mono-project.com/repo/ubuntu stable-focal main" > /etc/apt/sources.list.d/mono-official-stable.list' && \ apt-get -y update && \ apt-get -y install mono-complete && \ apt-get clean && rm -rf /var/lib/apt/lists/ # We can now get Mono itself. RUN curl -o /usr/local/bin/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe && \ # Create as alias for nuget echo "alias nuget=\"mono /usr/local/bin/nuget.exe\"" >> /root/.bash_aliases # Install qsharp compiler from source RUN git clone https://github.com/microsoft/qsharp-compiler.git RUN cd qsharp-compiler && export SOURCE_DIR=${PWD} && cd src/QsCompiler/CommandLineTool && dotnet build && \ echo "export PATH=${PATH}:${SOURCE_DIR}/src/QsCompiler/CommandLineTool/bin/Debug/netcoreapp3.1/" >> /root/.bashrc && \ echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${SOURCE_DIR}/src/QsCompiler/QirGeneration/Llvm.Net/runtimes/linux-x64/native" >> /root/.bashrc && \ # Build QirGeneration extension cd ${SOURCE_DIR}/src/QsCompiler/QirGeneration && dotnet build && \ # Export the DLL location to an environment variable. echo "export QIR_GEN_DLL=${SOURCE_DIR}/src/QsCompiler/QirGeneration/bin/Debug/netstandard2.1/Microsoft.Quantum.QirGeneration.dll" >> /root/.bashrc RUN apt-get update && apt-get -y install cmake gcc g++ clang-format libcurl4-openssl-dev libunwind-dev libpython3-dev python3-pip libblas-dev liblapack-dev lsb-release && \ wget -qO- https://aide-qc.github.io/deploy/aide_qc/debian/PUBLIC-KEY.gpg | apt-key add - && \ wget -qO- "https://aide-qc.github.io/deploy/aide_qc/debian/$(lsb_release -cs)/aide-qc.list" | tee -a /etc/apt/sources.list.d/aide-qc.list && \ apt-get update && apt-get -y install aideqc-llvm && \ pip3 install cmake No newline at end of file
examples/qsharp/FTQC/Bell/bell.qs +1 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ namespace QCOR // Using QCOR Intrinsic instruction set // see QirTarget.qs open QCOR.Intrinsic; @EntryPoint() operation TestBell(count : Int) : Int { // Simple bell test mutable numOnes = 0; Loading
examples/qsharp/FTQC/Bell/bell_driver.cpp +8 −5 Original line number Diff line number Diff line Loading @@ -2,17 +2,20 @@ #include <vector> // Include the external QSharp function. qcor_include_qsharp(QCOR__TestBell__body, int64_t, int64_t) // With EntryPoint() annotation, there are 3 functions generated: // QCOR__TestBell__body(): raw Q# callable // QCOR__TestBell(): EntryPoint type (with result printing), no return // QCOR__TestBell__Interop(): InteropFriendly function (type casting to C-type function) qcor_include_qsharp(QCOR__TestBell, void, int64_t) // Compile with: // Include both the qsharp source and this driver file // in the command line. // $ qcor -qrt ftqc bell.qs bell_driver.cpp // -qs-build-exe to activate entry point generation. // $ qcor -qrt ftqc -qs-build-exe bell.qs bell_driver.cpp // Run with: // $ ./a.out int main() { auto oneCounts = QCOR__TestBell__body(1024); std::cout << "Result = " << oneCounts << "\n"; QCOR__TestBell(1024); return 0; } No newline at end of file
examples/qsharp/FTQC/EntryPoint/qs_standalone.qs 0 → 100644 +33 −0 Original line number Diff line number Diff line namespace QCOR { // Using QCOR Intrinsic instruction set // see QirTarget.qs open QCOR.Intrinsic; @EntryPoint() operation ValidEntryPoint() : Unit { } @EntryPoint() operation TestBell(count : Int) : Unit { // Simple bell test mutable numOnes = 0; mutable agree = 0; use q = Qubit[2]; for test in 1..count { H(q[0]); CNOT(q[0],q[1]); let res0 = M(q[0]); let res1 = M(q[1]); if res0 == res0 { set agree += 1; } // Count the number of ones we saw: if res0 == One { set numOnes += 1; } Reset(q[0]); Reset(q[1]); } } } No newline at end of file
examples/qsharp/NISQ/bell.qs 0 → 100644 +14 −0 Original line number Diff line number Diff line namespace QCOR { open QCOR.Intrinsic; operation Bell(qubits : Qubit[]) : Unit { H(qubits[0]); for index in 0 .. Length(qubits) - 2 { CNOT(qubits[index], qubits[index + 1]); } for qubit in qubits { let res = M(qubit); } } } No newline at end of file