Skip to content

Commit

Permalink
Merge pull request #1037 from CQCL/release/1.20.1
Browse files Browse the repository at this point in the history
Release/1.20.1
  • Loading branch information
cqc-alec authored Sep 19, 2023
2 parents db3501f + 1f27d53 commit f92c514
Show file tree
Hide file tree
Showing 20 changed files with 200 additions and 30 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build-without-conan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ jobs:
- name: Install boost
run: |
cd ${TMP_DIR}
wget -O boost_1_82_0.tar.gz https://sourceforge.net/projects/boost/files/boost/1.82.0/boost_1_82_0.tar.gz/download
tar xzvf boost_1_82_0.tar.gz
cd boost_1_82_0/
wget -O boost_1_83_0.tar.gz https://sourceforge.net/projects/boost/files/boost/1.83.0/boost_1_83_0.tar.gz/download
tar xzvf boost_1_83_0.tar.gz
cd boost_1_83_0/
./bootstrap.sh --prefix=${INSTALL_DIR}
./b2
./b2 install
Expand Down
19 changes: 17 additions & 2 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ jobs:
run: |
conan profile detect
conan remote add tket-libs https://quantinuumsw.jfrog.io/artifactory/api/conan/tket1-libs --index 0
- name: Fix conan profile for clang toolchain
if: matrix.os == 'macos-12'
run: |
PROFILE_PATH=`conan profile path default`
sed -i -e 's/gnu98/gnu17/' ${PROFILE_PATH}
- name: Install runtime test requirements
if: matrix.os == 'ubuntu-22.04' && github.event_name == 'schedule'
run: |
Expand Down Expand Up @@ -147,8 +152,6 @@ jobs:
- uses: actions/checkout@v4
- name: Install conan
uses: turtlebrowser/[email protected]
with:
version: '2.0.9'
- name: Set up conan
id: conan-setup
run: |
Expand Down Expand Up @@ -221,6 +224,10 @@ jobs:
conan profile detect --force
conan remote add tket-libs https://quantinuumsw.jfrog.io/artifactory/api/conan/tket1-libs --force --index 0
conan cache clean
- name: Fix conan profile for clang toolchain
run: |
PROFILE_PATH=`conan profile path default`
sed -i -e 's/gnu98/gnu17/' ${PROFILE_PATH}
- name: ccache
uses: hendrikmuhs/[email protected]
with:
Expand Down Expand Up @@ -373,6 +380,10 @@ jobs:
run: |
conan profile detect
conan remote add tket-libs https://quantinuumsw.jfrog.io/artifactory/api/conan/tket1-libs --index 0
- name: Fix conan profile for clang toolchain
run: |
PROFILE_PATH=`conan profile path default`
sed -i -e 's/gnu98/gnu17/' ${PROFILE_PATH}
- name: ccache
uses: hendrikmuhs/[email protected]
with:
Expand Down Expand Up @@ -529,6 +540,10 @@ jobs:
run: |
conan profile detect --force
conan remote add tket-libs https://quantinuumsw.jfrog.io/artifactory/api/conan/tket1-libs --force --index 0
- name: Fix conan profile for clang toolchain
run: |
PROFILE_PATH=`conan profile path default`
sed -i -e 's/gnu98/gnu17/' ${PROFILE_PATH}
- name: Remove tket package from cache
run: conan remove -c 'tket/*'
- name: ccache
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/build_libs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ jobs:
uses: turtlebrowser/[email protected]
- name: create profile
run: conan profile detect
- name: Fix conan profile for clang toolchain
if: matrix.os == 'macos-12'
run: |
PROFILE_PATH=`conan profile path default`
sed -i -e 's/gnu98/gnu17/' ${PROFILE_PATH}
- name: add remote
run: conan remote add tket-libs https://quantinuumsw.jfrog.io/artifactory/api/conan/tket1-libs --index 0
- name: build ${{ matrix.lib }}
Expand Down Expand Up @@ -98,6 +103,10 @@ jobs:
uses: turtlebrowser/[email protected]
- name: create profile
run: conan profile detect --force
- name: Fix conan profile for clang toolchain
run: |
PROFILE_PATH=`conan profile path default`
sed -i -e 's/gnu98/gnu17/' ${PROFILE_PATH}
- name: set remotes
run: conan remote add --force tket-libs https://quantinuumsw.jfrog.io/artifactory/api/conan/tket1-libs --index 0
- name: build ${{ matrix.lib }}
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ jobs:
run: |
conan profile detect
conan remote add tket-libs https://quantinuumsw.jfrog.io/artifactory/api/conan/tket1-libs --index 0
- name: Fix conan profile for clang toolchain
if: matrix.os == 'macos-12'
run: |
PROFILE_PATH=`conan profile path default`
sed -i -e 's/gnu98/gnu17/' ${PROFILE_PATH}
- name: authenticate to repository
run: conan remote login -p ${{ secrets.JFROG_ARTIFACTORY_TOKEN_3 }} tket-libs ${{ secrets.JFROG_ARTIFACTORY_USER_3 }}
Expand All @@ -59,6 +64,11 @@ jobs:
conan profile detect --force
conan remote add tket-libs https://quantinuumsw.jfrog.io/artifactory/api/conan/tket1-libs --force --index 0
- name: Fix conan profile for clang toolchain
run: |
PROFILE_PATH=`conan profile path default`
sed -i -e 's/gnu98/gnu17/' ${PROFILE_PATH}
- name: authenticate to repository
run: conan remote login -p ${{ secrets.JFROG_ARTIFACTORY_TOKEN_3 }} tket-libs ${{ secrets.JFROG_ARTIFACTORY_USER_3 }}

Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ jobs:
run: |
conan profile detect
conan remote add tket-libs https://quantinuumsw.jfrog.io/artifactory/api/conan/tket1-libs --index 0
- name: Fix conan profile for clang toolchain
run: |
PROFILE_PATH=`conan profile path default`
sed -i -e 's/gnu98/gnu17/' ${PROFILE_PATH}
- name: Build tket C++
run: conan create tket --user tket --channel stable --build=missing -o boost/*:header_only=True -o tklog/*:shared=True -o tket/*:shared=True -tf ""
- name: Build wheel
Expand Down Expand Up @@ -128,6 +132,8 @@ jobs:
pyenv shell tket-${{ matrix.python-version }}
python -m pip install -U conan
conan profile detect --force
PROFILE_PATH=`conan profile path default`
sed -i -e 's/gnu98/gnu17/' ${PROFILE_PATH}
conan remote add tket-libs https://quantinuumsw.jfrog.io/artifactory/api/conan/tket1-libs --force --index 0
conan remove -c 'tket/*'
conan create tket --user tket --channel stable --build=missing -o boost/*:header_only=True -o tklog/*:shared=True -o tket/*:shared=True -tf ""
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/test_libs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ jobs:
uses: turtlebrowser/[email protected]
- name: create profile
run: conan profile detect
- name: Fix conan profile for clang toolchain
if: matrix.os == 'macos-12'
run: |
PROFILE_PATH=`conan profile path default`
sed -i -e 's/gnu98/gnu17/' ${PROFILE_PATH}
- name: add remote
run: conan remote add tket-libs https://quantinuumsw.jfrog.io/artifactory/api/conan/tket1-libs --index 0
- name: build ${{ matrix.lib }}
Expand Down Expand Up @@ -104,6 +109,10 @@ jobs:
- name: create profile
shell: bash
run: conan profile detect --force
- name: Fix conan profile for clang toolchain
run: |
PROFILE_PATH=`conan profile path default`
sed -i -e 's/gnu98/gnu17/' ${PROFILE_PATH}
- name: set remotes
run: conan remote add --force tket-libs https://quantinuumsw.jfrog.io/artifactory/api/conan/tket1-libs --index 0
- name: build ${{ matrix.lib }}
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/test_libs_all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ jobs:
uses: turtlebrowser/[email protected]
- name: create profile
run: conan profile detect
- name: Fix conan profile for clang toolchain
if: matrix.os == 'macos-12'
run: |
PROFILE_PATH=`conan profile path default`
sed -i -e 's/gnu98/gnu17/' ${PROFILE_PATH}
- name: add remote
run: conan remote add tket-libs https://quantinuumsw.jfrog.io/artifactory/api/conan/tket1-libs --index 0
- name: build ${{ matrix.lib }}
Expand All @@ -48,6 +53,10 @@ jobs:
- name: create profile
shell: bash
run: conan profile detect --force
- name: Fix conan profile for clang toolchain
run: |
PROFILE_PATH=`conan profile path default`
sed -i -e 's/gnu98/gnu17/' ${PROFILE_PATH}
- name: add remote
run: conan remote add tket-libs https://quantinuumsw.jfrog.io/artifactory/api/conan/tket1-libs --force --index 0
- name: build ${{ matrix.lib }}
Expand Down
6 changes: 3 additions & 3 deletions build-without-conan.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ The versions should match the current requirements as specified in the relevant

```
cd ${TMP_DIR}
wget -O boost_1_82_0.tar.gz https://sourceforge.net/projects/boost/files/boost/1.82.0/boost_1_82_0.tar.gz/download
tar xzvf boost_1_82_0.tar.gz
cd boost_1_82_0/
wget -O boost_1_83_0.tar.gz https://sourceforge.net/projects/boost/files/boost/1.83.0/boost_1_83_0.tar.gz/download
tar xzvf boost_1_83_0.tar.gz
cd boost_1_83_0/
./bootstrap.sh --prefix=${INSTALL_DIR}
./b2
./b2 install
Expand Down
7 changes: 1 addition & 6 deletions pytket/binders/circuit/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,12 +542,7 @@ PYBIND11_MODULE(circuit, m) {
.def("__hash__", &deletedHash<Op>, deletedHashDocstring)
.def("__repr__", [](const Op &op) { return op.get_name(); })
.def("free_symbols", [](const Op &op) { return op.free_symbols(); })
.def(
"get_unitary",
[](const Op *op) {
const auto &gate = dynamic_cast<const Gate &>(*op);
return gate.get_unitary();
})
.def("get_unitary", [](const Op *op) { return op->get_unitary(); })
.def(
"is_clifford_type",
[](const Op &op) { return op.get_desc().is_clifford_gate(); },
Expand Down
6 changes: 3 additions & 3 deletions pytket/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ def package(self):
cmake.install()

def requirements(self):
self.requires("tket/1.2.40@tket/stable")
self.requires("tket/1.2.43@tket/stable")
self.requires("tklog/0.3.3@tket/stable")
self.requires("tkrng/0.3.3@tket/stable")
self.requires("tkassert/0.3.3@tket/stable")
self.requires("tkwsm/0.3.4@tket/stable")
self.requires("tktokenswap/0.3.4@tket/stable")
self.requires("tkwsm/0.3.5@tket/stable")
self.requires("tktokenswap/0.3.5@tket/stable")
self.requires("symengine/0.10.1")
self.requires("gmp/6.2.1")
self.requires("pybind11/2.11.1")
Expand Down
12 changes: 12 additions & 0 deletions pytket/docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
Changelog
=========

1.20.1 (September 2023)
-----------------------

Fixes:

* Fix ``Op.get_unitary()`` runtime error for non gate ``Op``s.
* Fix ``CliffordSimp`` slow runtime issue.
* Correct implementation of ``free_symbols()`` and ``symbol_substitution()`` for
``ConjugationBox``.
* Fix pytket-to-QASM conversion when individual bits of registers used in
range predicates are later set.

1.20.0 (September 2023)
-----------------------

Expand Down
2 changes: 1 addition & 1 deletion pytket/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
# The short X.Y version
version = "1.20"
# The full version, including alpha/beta/rc tags
release = "1.20.0"
release = "1.20.1"


# -- General configuration ---------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions pytket/pytket/qasm/qasm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1261,6 +1261,7 @@ def mark_as_written(self, written_variable: str) -> None:
(variable, comparator, value, dest_bit, label)
for (variable, comparator, value, dest_bit, label) in self.range_preds
if variable == written_variable
or written_variable.startswith(variable + "[")
]
for hit in hits:
self.range_preds.remove(hit)
Expand Down
4 changes: 4 additions & 0 deletions pytket/tests/circuit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,10 @@ def test_boxes() -> None:
d.add_conjugation_box(conj_box2, [Qubit(0), Qubit(1), Qubit(2)])
assert d.n_gates == 25
assert json_validate(d)
# test op.get_unitary doesn't throw
for command in d.get_commands():
if len(command.op.free_symbols()) == 0:
command.op.get_unitary()


def test_tofollibox_strats() -> None:
Expand Down
32 changes: 32 additions & 0 deletions pytket/tests/qasm_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,38 @@ def test_classical_assignment_order() -> None:
assert posns[i] < posns[i + 1]


def test_classical_assignment_order_1() -> None:
circ = Circuit(1)
reg_meas = circ.add_c_register("c0", 1)
reg_cond = circ.add_c_register("c1", 1)
reg_aux = circ.add_c_register("c2", 1)
circ.add_c_setreg(0, reg_cond)
circ.add_c_setreg(1, reg_aux)
circ.add_c_xor(reg_cond[0], reg_aux[0], reg_cond[0])
circ.X(0, condition=reg_eq(reg_cond, 1))
circ.add_c_xor(reg_cond[0], reg_aux[0], reg_cond[0])
circ.Measure(Qubit(0), reg_meas[0])
qasm = circuit_to_qasm_str(circ, header="hqslib1")
correct_qasm = """OPENQASM 2.0;
include "hqslib1.inc";
qreg q[1];
creg c0[1];
creg c1[1];
creg c2[1];
creg tk_SCRATCH_BIT[1];
c1 = 0;
c2 = 1;
c1[0] = c2[0] ^ c1[0];
if(c1==1) tk_SCRATCH_BIT[0] = 1;
if(c1!=1) tk_SCRATCH_BIT[0] = 0;
c1[0] = c2[0] ^ c1[0];
if(tk_SCRATCH_BIT[0]==1) x q[0];
measure q[0] -> c0[0];
"""
assert qasm == correct_qasm


if __name__ == "__main__":
test_qasm_correct()
test_qasm_qubit()
Expand Down
8 changes: 4 additions & 4 deletions tket/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

class TketConan(ConanFile):
name = "tket"
version = "1.2.40"
version = "1.2.43"
package_type = "library"
license = "Apache 2"
homepage = "https://github.com/CQCL/tket"
Expand Down Expand Up @@ -111,15 +111,15 @@ def package_info(self):
def requirements(self):
# libraries installed from remote:
# https://quantinuumsw.jfrog.io/artifactory/api/conan/tket1-libs
self.requires("boost/1.82.0", transitive_headers=True)
self.requires("boost/1.83.0", transitive_headers=True)
self.requires("symengine/0.10.1", transitive_headers=True)
self.requires("eigen/3.4.0", transitive_headers=True)
self.requires("nlohmann_json/3.11.2", transitive_headers=True)
self.requires("tklog/0.3.3@tket/stable")
self.requires("tkassert/0.3.3@tket/stable", transitive_headers=True)
self.requires("tkrng/0.3.3@tket/stable")
self.requires("tktokenswap/0.3.4@tket/stable")
self.requires("tkwsm/0.3.4@tket/stable")
self.requires("tktokenswap/0.3.5@tket/stable")
self.requires("tkwsm/0.3.5@tket/stable")
if self.build_test():
self.test_requires("catch2/3.3.2")
if self.build_proptest():
Expand Down
8 changes: 2 additions & 6 deletions tket/include/tket/Circuit/ConjugationBox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,9 @@ class ConjugationBox : public Box {
ConjugationBox(const ConjugationBox &other);
~ConjugationBox() override {}

Op_ptr symbol_substitution(
const SymEngine::map_basic_basic &) const override {
// FIXME https://github.com/CQCL/tket/issues/1007
return std::make_shared<ConjugationBox>(*this);
}
Op_ptr symbol_substitution(const SymEngine::map_basic_basic &) const override;

SymSet free_symbols() const override { return {}; }
SymSet free_symbols() const override;

/**
* Equality check between two ConjugationBox instances
Expand Down
33 changes: 33 additions & 0 deletions tket/src/Circuit/ConjugationBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

#include "tket/Circuit/ConjugationBox.hpp"

#include <memory>
#include <optional>

#include "Utils/Expression.hpp"
#include "tket/Circuit/Circuit.hpp"
#include "tket/Ops/OpJsonFactory.hpp"
#include "tket/Utils/HelperFunctions.hpp"
Expand Down Expand Up @@ -89,6 +93,35 @@ void ConjugationBox::generate_circuit() const {
circ_ = std::make_shared<Circuit>(circ);
}

Op_ptr ConjugationBox::symbol_substitution(
const SymEngine::map_basic_basic &sub_map) const {
if (uncompute_.has_value()) {
return std::make_shared<ConjugationBox>(
compute_->symbol_substitution(sub_map),
action_->symbol_substitution(sub_map),
uncompute_.value()->symbol_substitution(sub_map));
} else {
return std::make_shared<ConjugationBox>(
compute_->symbol_substitution(sub_map),
action_->symbol_substitution(sub_map));
}
}

SymSet ConjugationBox::free_symbols() const {
SymSet compute_syms = compute_->free_symbols();
SymSet action_syms = action_->free_symbols();
SymSet uncompute_syms;
if (uncompute_.has_value()) {
SymSet s = uncompute_.value()->free_symbols();
uncompute_syms.insert(s.begin(), s.end());
}
SymSet sym_set;
sym_set.insert(compute_syms.begin(), compute_syms.end());
sym_set.insert(action_syms.begin(), action_syms.end());
sym_set.insert(uncompute_syms.begin(), uncompute_syms.end());
return sym_set;
}

bool ConjugationBox::is_equal(const Op &op_other) const {
const ConjugationBox &other = dynamic_cast<const ConjugationBox &>(op_other);
if (id_ == other.get_id()) return true;
Expand Down
Loading

0 comments on commit f92c514

Please sign in to comment.