Skip to content

Commit

Permalink
Merge branch 'main' into multithread-gpo
Browse files Browse the repository at this point in the history
  • Loading branch information
sjdilkes committed Nov 12, 2024
2 parents 1132ef0 + 5055846 commit e51a3c3
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 19 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 @@ -40,9 +40,9 @@ jobs:
- name: Install symengine
run: |
cd ${TMP_DIR}
wget https://github.com/symengine/symengine/archive/refs/tags/v0.12.0.tar.gz
tar xzvf v0.12.0.tar.gz
cd symengine-0.12.0/
wget https://github.com/symengine/symengine/archive/refs/tags/v0.13.0.tar.gz
tar xzvf v0.13.0.tar.gz
cd symengine-0.13.0/
mkdir build
cd build
cmake -GNinja -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -DBUILD_TESTS=OFF -DBUILD_BENCHMARKS=OFF ..
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ jobs:
python -m pip install -U mypy pybind11-stubgen
cd pytket
./stub_generation/regenerate_stubs
git diff --quiet pytket/_tket && echo "Stubs are up-to-date" || exit 1 # fail if stubs change after regeneration
git diff pytket/_tket && echo "Stubs are up-to-date" || exit 1 # fail if stubs change after regeneration
python -m mypy --config-file=mypy.ini --no-incremental -p pytket -p tests
- name: Upload package
if: github.event_name == 'push' && needs.check_changes.outputs.tket_changed == 'true'
Expand Down
6 changes: 3 additions & 3 deletions build-without-conan.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ make install

```
cd ${TMP_DIR}
wget https://github.com/symengine/symengine/archive/refs/tags/v0.12.0.tar.gz
tar xzvf v0.12.0.tar.gz
cd symengine-0.12.0/
wget https://github.com/symengine/symengine/archive/refs/tags/v0.13.0.tar.gz
tar xzvf v0.13.0.tar.gz
cd symengine-0.13.0/
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -DBUILD_TESTS=OFF -DBUILD_BENCHMARKS=OFF ..
Expand Down
18 changes: 16 additions & 2 deletions pytket/binders/circuit/Circuit/add_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,11 @@ void init_circuit_add_op(py::class_<Circuit, std::shared_ptr<Circuit>> &c) {
[](Circuit *circ, const py::tket_custom::BitLogicExpression &exp,
const py::tket_custom::SequenceVec<Bit> &outputs,
const py::kwargs &kwargs) {
PyErr_WarnEx(
PyExc_DeprecationWarning,
"The add_classicalexpbox_bit method is deprecated. Please use "
"Circuit::add_clexpr() instead.",
1);
auto inputs = exp.attr("all_inputs")().cast<std::set<Bit>>();
py::tket_custom::SequenceVec<Bit> o_vec, io_vec;

Expand All @@ -439,7 +444,9 @@ void init_circuit_add_op(py::class_<Circuit, std::shared_ptr<Circuit>> &c) {
n_i, n_io, n_o, exp),
o_vec, kwargs);
},
"Append a :py:class:`ClassicalExpBox` over Bit to the circuit.\n\n"
"Append a :py:class:`ClassicalExpBox` over Bit to the circuit.\n"
"DEPRECATED: Please use :py:meth:`add_clexpr` instead. This method "
"will be removed after pytket 1.40.\n\n"
":param classicalexpbox: The box to append\n"
":param args: Indices of the qubits to append the box to"
"\n:return: the new :py:class:`Circuit`",
Expand All @@ -450,6 +457,11 @@ void init_circuit_add_op(py::class_<Circuit, std::shared_ptr<Circuit>> &c) {
const py::tket_custom::BitRegisterLogicExpression &exp,
const py::tket_custom::SequenceVec<Bit> &outputs,
const py::kwargs &kwargs) {
PyErr_WarnEx(
PyExc_DeprecationWarning,
"The add_classicalexpbox_register method is deprecated. Please "
"use Circuit::add_clexpr() instead.",
1);
auto inputs =
exp.attr("all_inputs")().cast<std::set<BitRegister>>();
std::set<Bit> all_bits;
Expand Down Expand Up @@ -481,7 +493,9 @@ void init_circuit_add_op(py::class_<Circuit, std::shared_ptr<Circuit>> &c) {
o_vec, kwargs);
},
"Append a :py:class:`ClassicalExpBox` over BitRegister to the "
"circuit.\n\n"
"circuit.\n"
"DEPRECATED: Please use :py:meth:`add_clexpr` instead. This method "
"will be removed after pytket 1.40.\n\n"
":param classicalexpbox: The box to append\n"
":param args: Indices of the qubits to append the box to"
"\n:return: the new :py:class:`Circuit`",
Expand Down
4 changes: 3 additions & 1 deletion pytket/binders/circuit/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,9 @@ PYBIND11_MODULE(circuit, m) {
"A classical operation applied to multiple bits simultaneously")
.value(
"ClassicalExpBox", OpType::ClassicalExpBox,
"A box for holding compound classical operations on Bits.")
"A box for holding compound classical operations on Bits.\n"
"DEPRECATED: Please use :py:class:`WiredClExpr` instead. This class "
"will be removed after pytket 1.40.")
.value(
"MultiplexorBox", OpType::MultiplexorBox,
"A multiplexor (i.e. uniformly controlled operations)")
Expand Down
4 changes: 2 additions & 2 deletions pytket/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ def requirements(self):
self.requires("nlohmann_json/3.11.3")
self.requires("pybind11/2.13.6")
self.requires("pybind11_json/0.2.14")
self.requires("symengine/0.12.0")
self.requires("symengine/0.13.0")
self.requires("tkassert/0.3.4@tket/stable")
self.requires("tket/1.3.45@tket/stable")
self.requires("tket/1.3.47@tket/stable")
self.requires("tklog/0.3.3@tket/stable")
self.requires("tkrng/0.3.3@tket/stable")
self.requires("tktokenswap/0.3.9@tket/stable")
Expand Down
5 changes: 5 additions & 0 deletions pytket/docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ Features:
and `flatten_registers`
* Add new pass `MultiThreadGreedyPauliSimp`.
* Implement `dagger()` and `transpose()` for `CustomGate`.
* Use `ClExprOp` by default when converting from QASM.

Deprecations:

* Deprecate `ClassicalExpBox` and related methods, in favour of `ClExprOp`.

Fixes:

Expand Down
3 changes: 3 additions & 0 deletions pytket/pytket/_tket/circuit.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1438,6 +1438,7 @@ class Circuit:
def add_classicalexpbox_bit(self, expression: pytket.circuit.logic_exp.BitLogicExp, target: typing.Sequence[pytket._tket.unit_id.Bit], **kwargs: Any) -> Circuit:
"""
Append a :py:class:`ClassicalExpBox` over Bit to the circuit.
DEPRECATED: Please use :py:meth:`add_clexpr` instead. This method will be removed after pytket 1.40.
:param classicalexpbox: The box to append
:param args: Indices of the qubits to append the box to
Expand All @@ -1446,6 +1447,7 @@ class Circuit:
def add_classicalexpbox_register(self, expression: pytket.circuit.logic_exp.RegLogicExp, target: typing.Sequence[pytket._tket.unit_id.Bit], **kwargs: Any) -> Circuit:
"""
Append a :py:class:`ClassicalExpBox` over BitRegister to the circuit.
DEPRECATED: Please use :py:meth:`add_clexpr` instead. This method will be removed after pytket 1.40.
:param classicalexpbox: The box to append
:param args: Indices of the qubits to append the box to
Expand Down Expand Up @@ -3619,6 +3621,7 @@ class OpType:
MultiBit : A classical operation applied to multiple bits simultaneously
ClassicalExpBox : A box for holding compound classical operations on Bits.
DEPRECATED: Please use :py:class:`WiredClExpr` instead. This class will be removed after pytket 1.40.
MultiplexorBox : A multiplexor (i.e. uniformly controlled operations)
Expand Down
10 changes: 5 additions & 5 deletions pytket/pytket/qasm/qasm.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def __init__(
self,
return_gate_dict: bool = False,
maxwidth: int = 32,
use_clexpr: bool = False,
use_clexpr: bool = True,
) -> None:
super().__init__()
self.q_registers: dict[str, int] = {}
Expand Down Expand Up @@ -978,7 +978,7 @@ def circuit_from_qasm(
input_file: Union[str, "os.PathLike[Any]"],
encoding: str = "utf-8",
maxwidth: int = 32,
use_clexpr: bool = False,
use_clexpr: bool = True,
) -> Circuit:
"""A method to generate a tket Circuit from a qasm file.
Expand All @@ -1000,7 +1000,7 @@ def circuit_from_qasm(


def circuit_from_qasm_str(
qasm_str: str, maxwidth: int = 32, use_clexpr: bool = False
qasm_str: str, maxwidth: int = 32, use_clexpr: bool = True
) -> Circuit:
"""A method to generate a tket Circuit from a qasm string.
Expand All @@ -1023,7 +1023,7 @@ def circuit_from_qasm_str(


def circuit_from_qasm_io(
stream_in: TextIO, maxwidth: int = 32, use_clexpr: bool = False
stream_in: TextIO, maxwidth: int = 32, use_clexpr: bool = True
) -> Circuit:
"""A method to generate a tket Circuit from a qasm text stream"""
return circuit_from_qasm_str(
Expand All @@ -1036,7 +1036,7 @@ def circuit_from_qasm_wasm(
wasm_file: Union[str, "os.PathLike[Any]"],
encoding: str = "utf-8",
maxwidth: int = 32,
use_clexpr: bool = False,
use_clexpr: bool = True,
) -> Circuit:
"""A method to generate a tket Circuit from a qasm string and external WASM module.
Expand Down
4 changes: 2 additions & 2 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.3.45"
version = "1.3.47"
package_type = "library"
license = "Apache 2"
homepage = "https://github.com/CQCL/tket"
Expand Down Expand Up @@ -114,7 +114,7 @@ def requirements(self):
self.requires("boost/1.86.0", transitive_headers=True)
self.requires("eigen/3.4.0", transitive_headers=True)
self.requires("nlohmann_json/3.11.3", transitive_headers=True)
self.requires("symengine/0.12.0", transitive_headers=True)
self.requires("symengine/0.13.0", transitive_headers=True)
self.requires("tkassert/0.3.4@tket/stable", transitive_headers=True)
self.requires("tklog/0.3.3@tket/stable")
self.requires("tkrng/0.3.3@tket/stable")
Expand Down

0 comments on commit e51a3c3

Please sign in to comment.