tensorcircuit-nightly 1.4.0.dev20250924__py3-none-any.whl → 1.4.0.dev20250925__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of tensorcircuit-nightly might be problematic. Click here for more details.

tensorcircuit/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
- __version__ = "1.4.0.dev20250924"
1
+ __version__ = "1.4.0.dev20250925"
2
2
  __author__ = "TensorCircuit Authors"
3
3
  __creator__ = "refraction-ray"
4
4
 
@@ -53,6 +53,7 @@ vgates = [
53
53
  "any",
54
54
  "exp",
55
55
  "exp1",
56
+ "su4",
56
57
  ]
57
58
  mpogates = ["multicontrol", "mpo"]
58
59
  gate_aliases = [
@@ -229,6 +229,9 @@ class PyTorchBackend(pytorch_backend.PyTorchBackend, ExtendedBackend): # type:
229
229
  r = torchlib.ones(shape)
230
230
  return self.cast(r, dtype)
231
231
 
232
+ def exp(self, tensor: Tensor) -> Tensor:
233
+ return torchlib.exp(tensor)
234
+
232
235
  def zeros(self, shape: Tuple[int, ...], dtype: Optional[str] = None) -> Tensor:
233
236
  if dtype is None:
234
237
  dtype = dtypestr
@@ -248,7 +251,8 @@ class PyTorchBackend(pytorch_backend.PyTorchBackend, ExtendedBackend): # type:
248
251
  return result
249
252
 
250
253
  def expm(self, a: Tensor) -> Tensor:
251
- raise NotImplementedError("pytorch backend doesn't support expm")
254
+ return torchlib.linalg.matrix_exp(a)
255
+ # raise NotImplementedError("pytorch backend doesn't support expm")
252
256
  # in 2020, torch has no expm, hmmm. but that's ok,
253
257
  # it doesn't support complex numbers which is more severe issue.
254
258
  # see https://github.com/pytorch/pytorch/issues/9983
@@ -408,6 +412,7 @@ class PyTorchBackend(pytorch_backend.PyTorchBackend, ExtendedBackend): # type:
408
412
  return torchlib.nn.Softmax(a, dim=axis)
409
413
 
410
414
  def onehot(self, a: Tensor, num: int) -> Tensor:
415
+ a = a.long()
411
416
  return torchlib.nn.functional.one_hot(a, num)
412
417
 
413
418
  def cumsum(self, a: Tensor, axis: Optional[int] = None) -> Tensor:
tensorcircuit/gates.py CHANGED
@@ -870,6 +870,43 @@ def exponential_gate_unity(
870
870
  return Gate(mat, name="exp1-" + name)
871
871
 
872
872
 
873
+ def su4_gate(theta: Tensor, name: str = "su(4)") -> Gate:
874
+ r"""
875
+ Two-qubit general SU(4) gate.
876
+
877
+ :param theta: the angle tensor (15 components) of the gate.
878
+ :type theta: Tensor
879
+ :param name: the name of the gate.
880
+ :type name: str
881
+ :return: a gate object.
882
+ :rtype: Gate
883
+ """
884
+ theta = num_to_tensor(theta)
885
+ pauli_ops = array_to_tensor(
886
+ _ix_matrix,
887
+ _iy_matrix,
888
+ _iz_matrix,
889
+ _xi_matrix,
890
+ _xx_matrix,
891
+ _xy_matrix,
892
+ _xz_matrix,
893
+ _yi_matrix,
894
+ _yx_matrix,
895
+ _yy_matrix,
896
+ _yz_matrix,
897
+ _zi_matrix,
898
+ _zx_matrix,
899
+ _zy_matrix,
900
+ _zz_matrix,
901
+ )
902
+ generator = backend.sum(
903
+ backend.stack([theta[i] * pauli_ops[i] for i in range(15)]), axis=0
904
+ )
905
+ mat = backend.expm(-1j * generator)
906
+ mat = backend.reshape2(mat)
907
+ return Gate(mat, name=name)
908
+
909
+
873
910
  exp1_gate = exponential_gate_unity
874
911
  # exp1 = exponential_gate_unity
875
912
  rzz_gate = partial(exp1_gate, unitary=_zz_matrix, half=True)
@@ -974,6 +1011,7 @@ def meta_vgate() -> None:
974
1011
  "rzz",
975
1012
  "rxx",
976
1013
  "ryy",
1014
+ "su4",
977
1015
  ]:
978
1016
  for funcname in [f, f + "gate"]:
979
1017
  setattr(thismodule, funcname, GateVF(getattr(thismodule, f + "_gate"), f))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tensorcircuit-nightly
3
- Version: 1.4.0.dev20250924
3
+ Version: 1.4.0.dev20250925
4
4
  Summary: High performance unified quantum computing framework for the NISQ era
5
5
  Author-email: TensorCircuit Authors <znfesnpbh@gmail.com>
6
6
  License-Expression: Apache-2.0
@@ -1,6 +1,6 @@
1
- tensorcircuit/__init__.py,sha256=5GzybF2iCmmcUawd_lJZ-Xa3ksVUnqRFWf8LYPL6jS4,2160
1
+ tensorcircuit/__init__.py,sha256=xXyhJsWW3Epe8EgyWs2EOSY1UwDtW4NSusyVXHpx-L0,2160
2
2
  tensorcircuit/about.py,sha256=DazTswU2nAwOmASTaDII3L04PVtaQ7oiWPty5YMI3Wk,5267
3
- tensorcircuit/abstractcircuit.py,sha256=DwBmXhejVEqyhwoDJn8nOswJQBmvDR28n276wlhesJY,44224
3
+ tensorcircuit/abstractcircuit.py,sha256=uDRgaDeH_Ym-6_ZEOZwvxHIDycVLHkGZv4zfaIgaEnc,44235
4
4
  tensorcircuit/analogcircuit.py,sha256=4BzIC631MZ2m05CXuk2T6HQ8RTmHBE6NszaOLuxmlEc,15639
5
5
  tensorcircuit/asciiart.py,sha256=neY1OWFwtoW5cHPNwkQHgRPktDniQvdlP9QKHkk52fM,8236
6
6
  tensorcircuit/basecircuit.py,sha256=9I0Es2P5VdGisx5_t0AKSYtgSb15RB6fXCZg4eEr5es,39138
@@ -10,7 +10,7 @@ tensorcircuit/cons.py,sha256=V0wjevtDkESCIWMJaysgPVorQlPAIT0vtRWvIZkEWcE,33065
10
10
  tensorcircuit/densitymatrix.py,sha256=C8Q2fHXZ78S9ZaPqCIKl6_v_sILqbBgqBOUYUQ1QmFI,15020
11
11
  tensorcircuit/experimental.py,sha256=TGK4FaS6TS_ZhtjcIZgYVuAkGdRW50LN0DdXp-h4bos,29906
12
12
  tensorcircuit/fgs.py,sha256=J1TjAiiqZk9KO1xYX_V0xsgKlYZaUQ7Enm4s5zkRM50,49514
13
- tensorcircuit/gates.py,sha256=KLAYZyX_MyvKw4s4HZ0trw_3q9VCTHh8nwn2_ZaIV2c,29598
13
+ tensorcircuit/gates.py,sha256=9x1VTEpZWz-FoWVM_YznoU1dbFzXnfXIEJQQVec-2Ko,30504
14
14
  tensorcircuit/keras.py,sha256=nMSuu9uZy7haWwuen1g_6GFVwYIirtX9IvejDyoH33M,10129
15
15
  tensorcircuit/mps_base.py,sha256=UZ-v8vsr_rAsKrfun8prVgbXJ-qsdqKy2DZIHpq3sxo,15400
16
16
  tensorcircuit/mpscircuit.py,sha256=CPWlsb-kybZE-lh4iUkVMDn45qhHtFHUnxATP6TsaVk,38802
@@ -49,7 +49,7 @@ tensorcircuit/backends/cupy_backend.py,sha256=KG5fqP29wnngkPsi-TnOk0pHsr9lyD7hx6
49
49
  tensorcircuit/backends/jax_backend.py,sha256=luLhZ7zyj8d6ARYxzGsvhxZnbownbqgeUMpUQw6F5Yw,29080
50
50
  tensorcircuit/backends/jax_ops.py,sha256=WyUGavch2R9uEFsI1Ap7eP1UcU4s2TItBgGsrVS3Hzs,9320
51
51
  tensorcircuit/backends/numpy_backend.py,sha256=0N7Z6slwDsAkWBislzsy0YhKTxa2Woq_xaCCX_SFuHI,15613
52
- tensorcircuit/backends/pytorch_backend.py,sha256=XUSPh_AMbB1BeX2h9HHpccNubrLg85ouotjoXDc7N7g,26996
52
+ tensorcircuit/backends/pytorch_backend.py,sha256=V4NW7RAwPgBlhMbenTJHFxSGDVdQsd5PwH8CRqcjEEc,27146
53
53
  tensorcircuit/backends/pytorch_ops.py,sha256=lLxpK6OqfpVwifyFlgsqhpnt-oIn4R5paPMVg51WaW0,3826
54
54
  tensorcircuit/backends/tensorflow_backend.py,sha256=9SAfcWEoKvyJG4sM0I89ozW16aa3VMxMfcOUeDljShE,39813
55
55
  tensorcircuit/backends/tf_ops.py,sha256=FJwDU7LhZrt0VUIx12DJU0gZnWhMv7B7r9sAKG710As,3378
@@ -89,8 +89,8 @@ tensorcircuit/templates/graphs.py,sha256=cPYrxjoem0xZ-Is9dZKAvEzWZL_FejfIRiCEOTA
89
89
  tensorcircuit/templates/hamiltonians.py,sha256=Guvqqi-V47w8xeZDmca4_mU4mW9V4c3AplsBOrRtxFo,6308
90
90
  tensorcircuit/templates/lattice.py,sha256=IvFyNgsFMfj82g-tpJraI3lMbI-EIZ0Cghq9v7tZ6Wg,72851
91
91
  tensorcircuit/templates/measurements.py,sha256=pzc5Aa9S416Ilg4aOY77Z6ZhUlYcXnAkQNQFTuHjFFs,10943
92
- tensorcircuit_nightly-1.4.0.dev20250924.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
93
- tensorcircuit_nightly-1.4.0.dev20250924.dist-info/METADATA,sha256=N1cYFaWqWV7Pbgv6GGrS0arQqK2gPTm8V0iYWrwBqXg,38283
94
- tensorcircuit_nightly-1.4.0.dev20250924.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
95
- tensorcircuit_nightly-1.4.0.dev20250924.dist-info/top_level.txt,sha256=9dcuK5488dWpVauYz8cdvx743z_La1h7zIQCsEEgu7o,14
96
- tensorcircuit_nightly-1.4.0.dev20250924.dist-info/RECORD,,
92
+ tensorcircuit_nightly-1.4.0.dev20250925.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
93
+ tensorcircuit_nightly-1.4.0.dev20250925.dist-info/METADATA,sha256=VW5RjBoS-Q3q5esxl_GO8ilCXuPG5eu8BS2_79PUBUI,38283
94
+ tensorcircuit_nightly-1.4.0.dev20250925.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
95
+ tensorcircuit_nightly-1.4.0.dev20250925.dist-info/top_level.txt,sha256=9dcuK5488dWpVauYz8cdvx743z_La1h7zIQCsEEgu7o,14
96
+ tensorcircuit_nightly-1.4.0.dev20250925.dist-info/RECORD,,