diff --git a/WORKSPACE b/WORKSPACE index df09599de..92790b6fa 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -12,13 +12,14 @@ http_archive( http_archive( name = "org_tensorflow", - sha256 = "2023a377a16e5566b8981400af9e8c8e25d3367d82824ffec2b5b6b9c7dba55d", - strip_prefix = "tensorflow-2.5.1", + sha256 = "249b48ddee927801c7a4f8e5442cf1a3c860f6f46b85a2ff7a78b501507dd561", + strip_prefix = "tensorflow-2.7.0", urls = [ - "https://github.com/tensorflow/tensorflow/archive/refs/tags/v2.5.1.zip", + "https://github.com/tensorflow/tensorflow/archive/refs/tags/v2.7.0.zip", ], ) + load("@org_tensorflow//tensorflow:workspace3.bzl", "workspace") workspace() @@ -50,3 +51,4 @@ bind( name = "six", actual = "@six_archive//:six", ) + diff --git a/configure.sh b/configure.sh index 2af283951..6ba7a1bc4 100755 --- a/configure.sh +++ b/configure.sh @@ -105,6 +105,7 @@ write_to_bazelrc "build --strategy=Genrule=standalone" write_to_bazelrc "build --experimental_repo_remote_exec" write_to_bazelrc "build -c opt" write_to_bazelrc "build --cxxopt=\"-D_GLIBCXX_USE_CXX11_ABI=0\"" +write_to_bazelrc "build --cxxopt=\"-std=c++14\"" if is_windows; then diff --git a/docs/install.md b/docs/install.md index 36286873a..50084a23e 100644 --- a/docs/install.md +++ b/docs/install.md @@ -17,7 +17,7 @@ TensorFlow Quantum is supported on Python 3.6, 3.7, and 3.8 and depends directly ### Requirements * pip 19.0 or later (requires `manylinux2010` support) -* [TensorFlow == 2.5.1](https://www.tensorflow.org/install/pip) +* [TensorFlow == 2.4.1](https://www.tensorflow.org/install/pip) See the [TensorFlow install guide](https://www.tensorflow.org/install/pip) to set up your Python development environment and an (optional) virtual environment. @@ -27,7 +27,7 @@ Upgrade `pip` and install TensorFlow
   pip3 install --upgrade pip
-  pip3 install tensorflow==2.5.1
+  pip3 install tensorflow==2.4.1
 
@@ -43,7 +43,7 @@ Install the latest stable release of TensorFlow Quantum: Success: TensorFlow Quantum is now installed. -Install the latest nightly version of TensorFlow Quantum: +Nightly builds which might depend on newer version of TensorFlow can be installed with:
@@ -84,7 +84,7 @@ As noted in the TensorFlow
 guide, the Bazel
 build system will be required.
 
-Our latest source builds use TensorFlow 2.5.1. To ensure compatibility we use `bazel` version 3.7.2. To remove any existing version of Bazel:
+Our latest source builds use TensorFlow 2.7.0. To ensure compatibility we use `bazel` version 3.7.2. To remove any existing version of Bazel:
 
 
 
@@ -122,7 +122,7 @@ Finally, confirm installation of the correct `bazel` version:
 ### 4. Build TensorFlow from source
 
 Here we adapt instructions from the TensorFlow [build from source](https://www.tensorflow.org/install/source)
-guide, see the link for further details. TensorFlow Quantum is compatible with TensorFlow version 2.5.
+guide, see the link for further details. TensorFlow Quantum is compatible with TensorFlow version 2.7.0.
 
 Download the
 TensorFlow source code:
@@ -131,7 +131,7 @@ Download the
 
   git clone https://github.com/tensorflow/tensorflow.git
   cd tensorflow
-  git checkout v2.5.1
+  git checkout v2.7.0
 
Be sure the virtual environment you created in step 2 is activated. Then, install the TensorFlow dependencies: diff --git a/release/setup.py b/release/setup.py index 5d6a67b2a..5b6fbdb83 100644 --- a/release/setup.py +++ b/release/setup.py @@ -58,7 +58,7 @@ def finalize_options(self): # placed as extra to not have required overwrite existing nightly installs if # they exist. -EXTRA_PACKAGES = ['tensorflow == 2.5.1'] +EXTRA_PACKAGES = ['tensorflow == 2.7.0'] CUR_VERSION = '0.6.0' diff --git a/requirements.txt b/requirements.txt index 98b3997fe..fc1de029b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,7 @@ nbconvert==5.6.1 nbformat==4.4.0 pylint==2.4.4 yapf==0.28.0 -tensorflow==2.5.1 +tensorflow==2.7.0 # Needed for compatibility with cirq program protos. googleapis-common-protos==1.52.0 google-api-core==1.21.0 diff --git a/tensorflow_quantum/core/ops/BUILD b/tensorflow_quantum/core/ops/BUILD index 5438fddd1..8a534229b 100644 --- a/tensorflow_quantum/core/ops/BUILD +++ b/tensorflow_quantum/core/ops/BUILD @@ -69,7 +69,7 @@ cc_binary( ], "//conditions:default": [ "-pthread", - "-std=c++11", + "-std=c++14", "-D_GLIBCXX_USE_CXX11_ABI=0", ], }), @@ -132,7 +132,7 @@ cc_binary( ], "//conditions:default": [ "-pthread", - "-std=c++11", + "-std=c++14", "-D_GLIBCXX_USE_CXX11_ABI=0", ], }), @@ -190,7 +190,7 @@ cc_binary( ], "//conditions:default": [ "-pthread", - "-std=c++11", + "-std=c++14", "-D_GLIBCXX_USE_CXX11_ABI=0", ], }), @@ -256,7 +256,7 @@ cc_binary( ], "//conditions:default": [ "-pthread", - "-std=c++11", + "-std=c++14", "-D_GLIBCXX_USE_CXX11_ABI=0", ], }), @@ -284,6 +284,41 @@ cc_library( name = "parse_context", srcs = ["parse_context.cc"], hdrs = ["parse_context.h"], + copts = select({ + ":windows": [ + "/D__CLANG_SUPPORT_DYN_ANNOTATION__", + "/D_USE_MATH_DEFINES", + "/DEIGEN_MPL2_ONLY", + "/DEIGEN_MAX_ALIGN_BYTES=64", + "/DEIGEN_HAS_TYPE_TRAITS=0", + "/DTF_USE_SNAPPY", + "/showIncludes", + "/MD", + "/O2", + "/DNDEBUG", + "/w", + "-DWIN32_LEAN_AND_MEAN", + "-DNOGDI", + "/d2ReducedOptimizeHugeFunctions", + "/arch:AVX", + "/std:c++14", + "-DTENSORFLOW_MONOLITHIC_BUILD", + "/DPLATFORM_WINDOWS", + "/DEIGEN_HAS_C99_MATH", + "/DTENSORFLOW_USE_EIGEN_THREADPOOL", + "/DEIGEN_AVOID_STL_ARRAY", + "/Iexternal/gemmlowp", + "/wd4018", + "/wd4577", + "/DNOGDI", + "/UTF_COMPILE_LIBRARY", + ], + "//conditions:default": [ + "-pthread", + "-std=c++14", + "-D_GLIBCXX_USE_CXX11_ABI=0", + ], + }), deps = [ ":tfq_simulate_utils", "//tensorflow_quantum/core/proto:pauli_sum_cc_proto", @@ -333,7 +368,7 @@ cc_binary( ], "//conditions:default": [ "-pthread", - "-std=c++11", + "-std=c++14", "-D_GLIBCXX_USE_CXX11_ABI=0", ], }), @@ -364,6 +399,41 @@ cc_library( name = "tfq_simulate_utils", srcs = ["tfq_simulate_utils.cc"], hdrs = ["tfq_simulate_utils.h"], + copts = select({ + ":windows": [ + "/D__CLANG_SUPPORT_DYN_ANNOTATION__", + "/D_USE_MATH_DEFINES", + "/DEIGEN_MPL2_ONLY", + "/DEIGEN_MAX_ALIGN_BYTES=64", + "/DEIGEN_HAS_TYPE_TRAITS=0", + "/DTF_USE_SNAPPY", + "/showIncludes", + "/MD", + "/O2", + "/DNDEBUG", + "/w", + "-DWIN32_LEAN_AND_MEAN", + "-DNOGDI", + "/d2ReducedOptimizeHugeFunctions", + "/arch:AVX", + "/std:c++14", + "-DTENSORFLOW_MONOLITHIC_BUILD", + "/DPLATFORM_WINDOWS", + "/DEIGEN_HAS_C99_MATH", + "/DTENSORFLOW_USE_EIGEN_THREADPOOL", + "/DEIGEN_AVOID_STL_ARRAY", + "/Iexternal/gemmlowp", + "/wd4018", + "/wd4577", + "/DNOGDI", + "/UTF_COMPILE_LIBRARY", + ], + "//conditions:default": [ + "-pthread", + "-std=c++14", + "-D_GLIBCXX_USE_CXX11_ABI=0", + ], + }), deps = [ "@local_config_tf//:libtensorflow_framework", "@local_config_tf//:tf_header_lib", diff --git a/tensorflow_quantum/core/ops/batch_util_test.py b/tensorflow_quantum/core/ops/batch_util_test.py index 3352b5ba2..6b11becd7 100644 --- a/tensorflow_quantum/core/ops/batch_util_test.py +++ b/tensorflow_quantum/core/ops/batch_util_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Test parallel Cirq simulations.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + import numpy as np import tensorflow as tf from absl.testing import parameterized diff --git a/tensorflow_quantum/core/ops/circuit_execution_ops_test.py b/tensorflow_quantum/core/ops/circuit_execution_ops_test.py index 27b27398f..f94297cdc 100644 --- a/tensorflow_quantum/core/ops/circuit_execution_ops_test.py +++ b/tensorflow_quantum/core/ops/circuit_execution_ops_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Module to test consistency between Cirq and TFQ circuit execution ops.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + from unittest import mock import numpy as np import tensorflow as tf diff --git a/tensorflow_quantum/core/ops/cirq_ops_test.py b/tensorflow_quantum/core/ops/cirq_ops_test.py index b0e1b0017..ffbfab1de 100644 --- a/tensorflow_quantum/core/ops/cirq_ops_test.py +++ b/tensorflow_quantum/core/ops/cirq_ops_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Tests for the cirq simulation ops.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + from unittest import mock import numpy as np import tensorflow as tf diff --git a/tensorflow_quantum/core/ops/math_ops/BUILD b/tensorflow_quantum/core/ops/math_ops/BUILD index 51008b96e..6585ec5b8 100644 --- a/tensorflow_quantum/core/ops/math_ops/BUILD +++ b/tensorflow_quantum/core/ops/math_ops/BUILD @@ -49,7 +49,7 @@ cc_binary( ], "//conditions:default": [ "-pthread", - "-std=c++11", + "-std=c++14", "-D_GLIBCXX_USE_CXX11_ABI=0", ], }), diff --git a/tensorflow_quantum/core/ops/math_ops/fidelity_op_test.py b/tensorflow_quantum/core/ops/math_ops/fidelity_op_test.py index d35d1e1e0..1ab8031ea 100644 --- a/tensorflow_quantum/core/ops/math_ops/fidelity_op_test.py +++ b/tensorflow_quantum/core/ops/math_ops/fidelity_op_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Tests that specifically target tfq_inner_product.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + import copy import numpy as np from absl.testing import parameterized diff --git a/tensorflow_quantum/core/ops/math_ops/inner_product_grad_test.py b/tensorflow_quantum/core/ops/math_ops/inner_product_grad_test.py index e16ee0b8b..7fa74ee40 100644 --- a/tensorflow_quantum/core/ops/math_ops/inner_product_grad_test.py +++ b/tensorflow_quantum/core/ops/math_ops/inner_product_grad_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Tests that specifically target tfq_inner_product_grad.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + import copy import numpy as np from absl.testing import parameterized diff --git a/tensorflow_quantum/core/ops/math_ops/inner_product_op_test.py b/tensorflow_quantum/core/ops/math_ops/inner_product_op_test.py index 2d2a9db3f..ae83857b6 100644 --- a/tensorflow_quantum/core/ops/math_ops/inner_product_op_test.py +++ b/tensorflow_quantum/core/ops/math_ops/inner_product_op_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Tests that specifically target tfq_inner_product.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + import copy import numpy as np from absl.testing import parameterized diff --git a/tensorflow_quantum/core/ops/noise/BUILD b/tensorflow_quantum/core/ops/noise/BUILD index 073f4b6e4..a72665780 100644 --- a/tensorflow_quantum/core/ops/noise/BUILD +++ b/tensorflow_quantum/core/ops/noise/BUILD @@ -50,7 +50,7 @@ cc_binary( ], "//conditions:default": [ "-pthread", - "-std=c++11", + "-std=c++14", "-D_GLIBCXX_USE_CXX11_ABI=0", ], }), diff --git a/tensorflow_quantum/core/ops/noise/noisy_expectation_op_test.py b/tensorflow_quantum/core/ops/noise/noisy_expectation_op_test.py index 0196f504e..1e73500b8 100644 --- a/tensorflow_quantum/core/ops/noise/noisy_expectation_op_test.py +++ b/tensorflow_quantum/core/ops/noise/noisy_expectation_op_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Tests that specifically target noisy expectation calculation.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + import numpy as np from absl.testing import parameterized import tensorflow as tf diff --git a/tensorflow_quantum/core/ops/noise/noisy_sampled_expectation_op_test.py b/tensorflow_quantum/core/ops/noise/noisy_sampled_expectation_op_test.py index 98d25d554..35d1cc113 100644 --- a/tensorflow_quantum/core/ops/noise/noisy_sampled_expectation_op_test.py +++ b/tensorflow_quantum/core/ops/noise/noisy_sampled_expectation_op_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Tests that specifically target noisy expectation calculation.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + import numpy as np from absl.testing import parameterized import tensorflow as tf diff --git a/tensorflow_quantum/core/ops/noise/noisy_samples_op_test.py b/tensorflow_quantum/core/ops/noise/noisy_samples_op_test.py index af9fc8301..b952e8d40 100644 --- a/tensorflow_quantum/core/ops/noise/noisy_samples_op_test.py +++ b/tensorflow_quantum/core/ops/noise/noisy_samples_op_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Tests that specifically target noisy sampling.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + import numpy as np from scipy import stats from absl.testing import parameterized diff --git a/tensorflow_quantum/core/ops/tfq_adj_grad_op_test.py b/tensorflow_quantum/core/ops/tfq_adj_grad_op_test.py index 849a99d88..388bb163f 100644 --- a/tensorflow_quantum/core/ops/tfq_adj_grad_op_test.py +++ b/tensorflow_quantum/core/ops/tfq_adj_grad_op_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Tests that specifically target tfq_unitary_op.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + import numpy as np from absl.testing import parameterized import tensorflow as tf diff --git a/tensorflow_quantum/core/ops/tfq_ps_util_ops_test.py b/tensorflow_quantum/core/ops/tfq_ps_util_ops_test.py index bcca5000c..14bccd9bf 100644 --- a/tensorflow_quantum/core/ops/tfq_ps_util_ops_test.py +++ b/tensorflow_quantum/core/ops/tfq_ps_util_ops_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Test for ParameterShift specific C++ ops.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + import numpy as np import tensorflow as tf import sympy diff --git a/tensorflow_quantum/core/ops/tfq_simulate_ops_test.py b/tensorflow_quantum/core/ops/tfq_simulate_ops_test.py index bd7ed7550..4cdbe42e5 100644 --- a/tensorflow_quantum/core/ops/tfq_simulate_ops_test.py +++ b/tensorflow_quantum/core/ops/tfq_simulate_ops_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Tests that specifically target tfq_simulate_ops.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + import numpy as np from absl.testing import parameterized import tensorflow as tf diff --git a/tensorflow_quantum/core/ops/tfq_unitary_op_test.py b/tensorflow_quantum/core/ops/tfq_unitary_op_test.py index d7854a1f7..212094056 100644 --- a/tensorflow_quantum/core/ops/tfq_unitary_op_test.py +++ b/tensorflow_quantum/core/ops/tfq_unitary_op_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Tests that specifically target tfq_unitary_op.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + import numpy as np from absl.testing import parameterized import tensorflow as tf diff --git a/tensorflow_quantum/core/ops/tfq_utility_ops_test.py b/tensorflow_quantum/core/ops/tfq_utility_ops_test.py index 0ac4a3b12..8eab57ae7 100644 --- a/tensorflow_quantum/core/ops/tfq_utility_ops_test.py +++ b/tensorflow_quantum/core/ops/tfq_utility_ops_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Tests for tfq utility ops.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + import numpy as np import sympy import tensorflow as tf diff --git a/tensorflow_quantum/core/serialize/op_deserializer_test.py b/tensorflow_quantum/core/serialize/op_deserializer_test.py index c5e56fb3d..ce1748b65 100644 --- a/tensorflow_quantum/core/serialize/op_deserializer_test.py +++ b/tensorflow_quantum/core/serialize/op_deserializer_test.py @@ -12,6 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. """Test op deserialization correctness.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position from typing import List import tensorflow as tf diff --git a/tensorflow_quantum/core/serialize/op_serializer_test.py b/tensorflow_quantum/core/serialize/op_serializer_test.py index 2d63a7f45..7597d6a47 100644 --- a/tensorflow_quantum/core/serialize/op_serializer_test.py +++ b/tensorflow_quantum/core/serialize/op_serializer_test.py @@ -12,6 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. """Adaption of op_serializer_test.py from Cirq 0.9.0.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position from typing import List import numpy as np diff --git a/tensorflow_quantum/core/serialize/serializable_gate_set_test.py b/tensorflow_quantum/core/serialize/serializable_gate_set_test.py index c25bc324b..1e6fd9861 100644 --- a/tensorflow_quantum/core/serialize/serializable_gate_set_test.py +++ b/tensorflow_quantum/core/serialize/serializable_gate_set_test.py @@ -12,6 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. """Test serializable_gat_set.py functionality.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position import tensorflow as tf diff --git a/tensorflow_quantum/core/serialize/serializer_test.py b/tensorflow_quantum/core/serialize/serializer_test.py index dd138c16e..a43da0cf0 100644 --- a/tensorflow_quantum/core/serialize/serializer_test.py +++ b/tensorflow_quantum/core/serialize/serializer_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Module to test serialization core.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + import copy import numpy as np import sympy diff --git a/tensorflow_quantum/datasets/cluster_state_test.py b/tensorflow_quantum/datasets/cluster_state_test.py index 195081a35..49e75309d 100644 --- a/tensorflow_quantum/datasets/cluster_state_test.py +++ b/tensorflow_quantum/datasets/cluster_state_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Test the cluster state dataset.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + import tensorflow as tf import cirq diff --git a/tensorflow_quantum/datasets/spin_system_test.py b/tensorflow_quantum/datasets/spin_system_test.py index 36aa1f32f..dcd35d5c7 100644 --- a/tensorflow_quantum/datasets/spin_system_test.py +++ b/tensorflow_quantum/datasets/spin_system_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Test the spin system dataset""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + import tensorflow as tf import numpy as np import cirq diff --git a/tensorflow_quantum/python/differentiators/adjoint_test.py b/tensorflow_quantum/python/differentiators/adjoint_test.py index 85a79c2f7..ffbf9173e 100644 --- a/tensorflow_quantum/python/differentiators/adjoint_test.py +++ b/tensorflow_quantum/python/differentiators/adjoint_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Tests for the differentiator abstract class.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + import tensorflow as tf from tensorflow_quantum.python.differentiators import adjoint diff --git a/tensorflow_quantum/python/differentiators/differentiator_test.py b/tensorflow_quantum/python/differentiators/differentiator_test.py index 4ec3fd82d..6f21f2e18 100644 --- a/tensorflow_quantum/python/differentiators/differentiator_test.py +++ b/tensorflow_quantum/python/differentiators/differentiator_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Tests for the differentiator abstract class.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + import tensorflow as tf from tensorflow_quantum.python.differentiators import differentiator diff --git a/tensorflow_quantum/python/differentiators/gradient_test.py b/tensorflow_quantum/python/differentiators/gradient_test.py index a2f2e0a91..f666ad801 100644 --- a/tensorflow_quantum/python/differentiators/gradient_test.py +++ b/tensorflow_quantum/python/differentiators/gradient_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Testing for gradient calculation consistency in TFQ.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + import copy import numpy as np diff --git a/tensorflow_quantum/python/differentiators/linear_combination_test.py b/tensorflow_quantum/python/differentiators/linear_combination_test.py index 974bf845c..f46b086e4 100644 --- a/tensorflow_quantum/python/differentiators/linear_combination_test.py +++ b/tensorflow_quantum/python/differentiators/linear_combination_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Basic tests for the LinearCombinationDifferentiator""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + import numpy as np from absl.testing import parameterized import tensorflow as tf diff --git a/tensorflow_quantum/python/differentiators/parameter_shift_test.py b/tensorflow_quantum/python/differentiators/parameter_shift_test.py index 4b4ed1dca..5a0846f25 100644 --- a/tensorflow_quantum/python/differentiators/parameter_shift_test.py +++ b/tensorflow_quantum/python/differentiators/parameter_shift_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Basic tests for the ParameterShift differentiator""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + import numpy as np from absl.testing import parameterized import tensorflow as tf diff --git a/tensorflow_quantum/python/differentiators/parameter_shift_util_test.py b/tensorflow_quantum/python/differentiators/parameter_shift_util_test.py index 198974e79..8c1083a10 100644 --- a/tensorflow_quantum/python/differentiators/parameter_shift_util_test.py +++ b/tensorflow_quantum/python/differentiators/parameter_shift_util_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Basic tests for utility functions for ParameterShift""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + import numpy as np from absl.testing import parameterized import tensorflow as tf diff --git a/tensorflow_quantum/python/layers/circuit_construction/elementary_test.py b/tensorflow_quantum/python/layers/circuit_construction/elementary_test.py index aa05d3039..38577dbe9 100644 --- a/tensorflow_quantum/python/layers/circuit_construction/elementary_test.py +++ b/tensorflow_quantum/python/layers/circuit_construction/elementary_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Tests for the elementary layers.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + import tensorflow as tf import cirq import sympy diff --git a/tensorflow_quantum/python/layers/circuit_executors/expectation_test.py b/tensorflow_quantum/python/layers/circuit_executors/expectation_test.py index 08dff1eb2..e4489e763 100644 --- a/tensorflow_quantum/python/layers/circuit_executors/expectation_test.py +++ b/tensorflow_quantum/python/layers/circuit_executors/expectation_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Tests for tensorflow_quantum.layers.circuit_executors.expectation.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + import numpy as np from absl.testing import parameterized import sympy diff --git a/tensorflow_quantum/python/layers/circuit_executors/input_checks_test.py b/tensorflow_quantum/python/layers/circuit_executors/input_checks_test.py index fccdbb0f4..affbd55d7 100644 --- a/tensorflow_quantum/python/layers/circuit_executors/input_checks_test.py +++ b/tensorflow_quantum/python/layers/circuit_executors/input_checks_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Tests for tensorflow_quantum.layers.circuit_executors.input_checks.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + import numpy as np import sympy import tensorflow as tf diff --git a/tensorflow_quantum/python/layers/circuit_executors/sample_test.py b/tensorflow_quantum/python/layers/circuit_executors/sample_test.py index ebc293ef1..b83848132 100644 --- a/tensorflow_quantum/python/layers/circuit_executors/sample_test.py +++ b/tensorflow_quantum/python/layers/circuit_executors/sample_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Tests for the sample layer.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + import numpy as np from absl.testing import parameterized import sympy diff --git a/tensorflow_quantum/python/layers/circuit_executors/sampled_expectation_test.py b/tensorflow_quantum/python/layers/circuit_executors/sampled_expectation_test.py index c3c07c74c..2d165b13c 100644 --- a/tensorflow_quantum/python/layers/circuit_executors/sampled_expectation_test.py +++ b/tensorflow_quantum/python/layers/circuit_executors/sampled_expectation_test.py @@ -13,6 +13,12 @@ # limitations under the License. # ============================================================================== """Tests for tensorflow_quantum.layers.circuit_executors.sampled_expectation.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position import numpy as np from absl.testing import parameterized diff --git a/tensorflow_quantum/python/layers/circuit_executors/state_test.py b/tensorflow_quantum/python/layers/circuit_executors/state_test.py index 2442fa20f..8addb0d8f 100644 --- a/tensorflow_quantum/python/layers/circuit_executors/state_test.py +++ b/tensorflow_quantum/python/layers/circuit_executors/state_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Tests for tensorflow_quantum.layers.circuit_executors.state.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + import numpy as np from absl.testing import parameterized import sympy diff --git a/tensorflow_quantum/python/layers/circuit_executors/unitary_test.py b/tensorflow_quantum/python/layers/circuit_executors/unitary_test.py index e38408b81..7330c807f 100644 --- a/tensorflow_quantum/python/layers/circuit_executors/unitary_test.py +++ b/tensorflow_quantum/python/layers/circuit_executors/unitary_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Tests for tensorflow_quantum.layers.circuit_executors.unitary.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + import numpy as np from absl.testing import parameterized import sympy diff --git a/tensorflow_quantum/python/layers/high_level/controlled_pqc_test.py b/tensorflow_quantum/python/layers/high_level/controlled_pqc_test.py index c2e6e80ba..0d9e76e7e 100644 --- a/tensorflow_quantum/python/layers/high_level/controlled_pqc_test.py +++ b/tensorflow_quantum/python/layers/high_level/controlled_pqc_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Test module for tfq.python.layers.high_level.controlled_pqc layer.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + import numpy as np import tensorflow as tf from absl.testing import parameterized diff --git a/tensorflow_quantum/python/layers/high_level/noisy_controlled_pqc_test.py b/tensorflow_quantum/python/layers/high_level/noisy_controlled_pqc_test.py index 104d00f59..57ecf6cff 100644 --- a/tensorflow_quantum/python/layers/high_level/noisy_controlled_pqc_test.py +++ b/tensorflow_quantum/python/layers/high_level/noisy_controlled_pqc_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Test module for tfq.python.layers.high_level.controlled_pqc layer.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + import numpy as np import tensorflow as tf from absl.testing import parameterized diff --git a/tensorflow_quantum/python/layers/high_level/noisy_pqc_test.py b/tensorflow_quantum/python/layers/high_level/noisy_pqc_test.py index 42ad0ba9d..112838912 100644 --- a/tensorflow_quantum/python/layers/high_level/noisy_pqc_test.py +++ b/tensorflow_quantum/python/layers/high_level/noisy_pqc_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Test module for tfq.python.layers.high_level.noisy_pqc layer.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + import numpy as np import tensorflow as tf from absl.testing import parameterized diff --git a/tensorflow_quantum/python/layers/high_level/pqc_test.py b/tensorflow_quantum/python/layers/high_level/pqc_test.py index 6febeecaa..e6d831c66 100644 --- a/tensorflow_quantum/python/layers/high_level/pqc_test.py +++ b/tensorflow_quantum/python/layers/high_level/pqc_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Test module for tfq.python.layers.high_level.pqc layer.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + import numpy as np import tensorflow as tf from absl.testing import parameterized diff --git a/tensorflow_quantum/python/optimizers/rotosolve_minimizer_test.py b/tensorflow_quantum/python/optimizers/rotosolve_minimizer_test.py index 2631f9606..7ddc54e28 100755 --- a/tensorflow_quantum/python/optimizers/rotosolve_minimizer_test.py +++ b/tensorflow_quantum/python/optimizers/rotosolve_minimizer_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Test module for tfq.python.optimizers.rotosolve_minimizer optimizer.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + from operator import mul from functools import reduce import numpy as np diff --git a/tensorflow_quantum/python/quantum_context_test.py b/tensorflow_quantum/python/quantum_context_test.py index ac8055b33..5b219b1dc 100644 --- a/tensorflow_quantum/python/quantum_context_test.py +++ b/tensorflow_quantum/python/quantum_context_test.py @@ -13,6 +13,12 @@ # limitations under the License. # ============================================================================== """Tests for quantum_context functions.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position import multiprocessing import tensorflow as tf diff --git a/tensorflow_quantum/python/util_test.py b/tensorflow_quantum/python/util_test.py index f4cb3e085..3d4e2dd76 100644 --- a/tensorflow_quantum/python/util_test.py +++ b/tensorflow_quantum/python/util_test.py @@ -13,6 +13,13 @@ # limitations under the License. # ============================================================================== """Tests for TFQ utilities.""" +# Remove PYTHONPATH collisions for protobuf. +# pylint: disable=wrong-import-position +import sys +NEW_PATH = [x for x in sys.path if 'com_google_protobuf' not in x] +sys.path = NEW_PATH +# pylint: enable=wrong-import-position + import numpy as np import tensorflow as tf from absl.testing import parameterized