@@ -652,11 +652,25 @@ py_library(
652
652
],
653
653
)
654
654
655
+ py_library (
656
+ name = "tfq_simulate_ops_cuquantum_py" ,
657
+ srcs = ["tfq_simulate_ops_cuquantum.py" ],
658
+ data = [
659
+ ":_tfq_simulate_ops_cuquantum.so" ,
660
+ ],
661
+ srcs_version = "PY3" ,
662
+ deps = [
663
+ # tensorflow framework for wrappers
664
+ ":load_module" ,
665
+ ],
666
+ )
667
+
655
668
py_test (
656
- name = "tfq_simulate_ops_cuda_test " ,
657
- srcs = ["tfq_simulate_ops_cuda_test .py" ],
669
+ name = "tfq_simulate_ops_gpu_test " ,
670
+ srcs = ["tfq_simulate_ops_gpu_test .py" ],
658
671
deps = [
659
672
":tfq_simulate_ops_cuda_py" ,
673
+ ":tfq_simulate_ops_cuquantum_py" ,
660
674
":tfq_simulate_ops_py" ,
661
675
"//tensorflow_quantum/python:util" ,
662
676
],
@@ -726,13 +740,94 @@ cc_binary(
726
740
"//tensorflow_quantum/core/proto:program_cc_proto" ,
727
741
"//tensorflow_quantum/core/src:circuit_parser_qsim" ,
728
742
"//tensorflow_quantum/core/src:util_qsim" ,
743
+ "@eigen//:eigen3" ,
744
+ # "@local_cuda//:cuda_headers"
745
+ # tensorflow core framework
746
+ # tensorflow core lib
747
+ # tensorflow core protos
748
+ ] + if_cuda_is_configured ([
749
+ ":cuda" ,
750
+ "@local_config_cuda//cuda:cuda_headers" ,
729
751
"@qsim//lib:qsim_cuda_lib" ,
752
+ ]),
753
+ # alwayslink=1,
754
+ )
755
+
756
+ cc_binary (
757
+ name = "_tfq_simulate_ops_cuquantum.so" ,
758
+ srcs = [
759
+ "tfq_simulate_expectation_op_cuquantum.cu.cc" ,
760
+ ],
761
+ linkshared = 1 ,
762
+ features = select ({
763
+ ":windows" : ["windows_export_all_symbols" ],
764
+ "//conditions:default" : [],
765
+ }),
766
+ copts = select ({
767
+ ":windows" : [
768
+ "/D__CLANG_SUPPORT_DYN_ANNOTATION__" ,
769
+ "/D_USE_MATH_DEFINES" ,
770
+ "/DEIGEN_MPL2_ONLY" ,
771
+ "/DEIGEN_MAX_ALIGN_BYTES=64" ,
772
+ "/DEIGEN_HAS_TYPE_TRAITS=0" ,
773
+ "/DTF_USE_SNAPPY" ,
774
+ "/showIncludes" ,
775
+ "/MD" ,
776
+ "/O2" ,
777
+ "/DNDEBUG" ,
778
+ "/w" ,
779
+ "-DWIN32_LEAN_AND_MEAN" ,
780
+ "-DNOGDI" ,
781
+ "/d2ReducedOptimizeHugeFunctions" ,
782
+ "/arch:AVX" ,
783
+ "/std:c++17" ,
784
+ "-DTENSORFLOW_MONOLITHIC_BUILD" ,
785
+ "/DPLATFORM_WINDOWS" ,
786
+ "/DEIGEN_HAS_C99_MATH" ,
787
+ "/DTENSORFLOW_USE_EIGEN_THREADPOOL" ,
788
+ "/DEIGEN_AVOID_STL_ARRAY" ,
789
+ "/Iexternal/gemmlowp" ,
790
+ "/wd4018" ,
791
+ "/wd4577" ,
792
+ "/DNOGDI" ,
793
+ "/UTF_COMPILE_LIBRARY" ,
794
+ ],
795
+ "//conditions:default" : [
796
+ "-Iexternal/local_cuda/cuda/include" ,
797
+ # "--cuda-gpu-arch=sm_86",
798
+ # "-L/usr/local/cuda/lib64",
799
+ # "-lcudart_static",
800
+ # "-ldl",
801
+ # "-lrt",
802
+ "-pthread" ,
803
+ "-std=c++17" ,
804
+ "-D_GLIBCXX_USE_CXX11_ABI=1" ,
805
+ "-O3" ,
806
+ "-Iexternal/cuda_headers" ,
807
+ "-DNV_CUDNN_DISABLE_EXCEPTION" ,
808
+ # "-fpermissive",
809
+ ],
810
+ }) + if_cuda_is_configured (["-DTENSORFLOW_USE_NVCC=1" , "-DGOOGLE_CUDA=1" , "-x cuda" , "-nvcc_options=relaxed-constexpr" , "-nvcc_options=ftz=true" ]),
811
+ deps = [
812
+ # cirq cc proto
813
+ "//tensorflow_quantum/core/ops:parse_context" ,
814
+ "//tensorflow_quantum/core/ops:tfq_simulate_utils" ,
815
+ "//tensorflow_quantum/core/proto:pauli_sum_cc_proto" ,
816
+ "//tensorflow_quantum/core/proto:program_cc_proto" ,
817
+ "//tensorflow_quantum/core/src:circuit_parser_qsim" ,
818
+ "//tensorflow_quantum/core/src:util_qsim" ,
730
819
"@eigen//:eigen3" ,
731
820
# "@local_cuda//:cuda_headers"
732
821
# tensorflow core framework
733
822
# tensorflow core lib
734
823
# tensorflow core protos
735
- ] + if_cuda_is_configured ([":cuda" , "@local_config_cuda//cuda:cuda_headers" ]),
824
+ ] + if_cuda_is_configured ([
825
+ ":cuda" ,
826
+ "@cuquantum_libs//:custatevec" ,
827
+ "@cuquantum_libs//:custatevec_headers" ,
828
+ "@local_config_cuda//cuda:cuda_headers" ,
829
+ "@qsim//lib:qsim_cuquantum_lib" ,
830
+ ]),
736
831
# alwayslink=1,
737
832
)
738
833
0 commit comments