tensorcircuit-nightly 1.2.1.dev20250724__py3-none-any.whl → 1.2.1.dev20250725__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.2.1.dev20250724"
1
+ __version__ = "1.2.1.dev20250725"
2
2
  __author__ = "TensorCircuit Authors"
3
3
  __creator__ = "refraction-ray"
4
4
 
@@ -13,8 +13,6 @@ logger = logging.getLogger(__name__)
13
13
 
14
14
  try:
15
15
  import qiskit.quantum_info as qi
16
- import symengine
17
- import sympy
18
16
  from qiskit import QuantumCircuit
19
17
  from qiskit.circuit import Parameter, ParameterExpression
20
18
  from qiskit.circuit.exceptions import CircuitError
@@ -28,6 +26,14 @@ except ImportError:
28
26
  CircuitInstruction = Any
29
27
  QuantumCircuit = Any
30
28
 
29
+ try:
30
+ import symengine
31
+ import sympy
32
+ except ImportError:
33
+ logger.info(
34
+ "Please first ``pip install -U sympy symengine`` to enable `qiskit2tc` in translation module"
35
+ )
36
+
31
37
  try:
32
38
  import cirq
33
39
  except ImportError:
@@ -325,7 +331,9 @@ def qir2qiskit(
325
331
  qiskit_circ.append(gate, index_reversed)
326
332
  elif gate_name == "multicontrol":
327
333
  unitary = backend.numpy(backend.convert_to_tensor(parameters["unitary"]))
334
+ k = int(np.log(unitary.shape[-1]) / np.log(2) + 1e-7)
328
335
  ctrl_str = "".join(map(str, parameters["ctrl"]))[::-1]
336
+ unitary = perm_matrix(k) @ unitary @ perm_matrix(k)
329
337
  gate = UnitaryGate(unitary, label=qis_name).control(
330
338
  len(ctrl_str), ctrl_state=ctrl_str
331
339
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tensorcircuit-nightly
3
- Version: 1.2.1.dev20250724
3
+ Version: 1.2.1.dev20250725
4
4
  Summary: nightly release for tensorcircuit
5
5
  Home-page: https://github.com/refraction-ray/tensorcircuit-dev
6
6
  Author: TensorCircuit Authors
@@ -1,4 +1,4 @@
1
- tensorcircuit/__init__.py,sha256=crGf_yKgxwxVS0dPKaNTaY7srmWi_K0oqt9Ixlj6CZ0,2032
1
+ tensorcircuit/__init__.py,sha256=LrE3yXQseP6sJKYFCHPc8bpfsRIymW3wYpd2oZK-wLI,2032
2
2
  tensorcircuit/about.py,sha256=DazTswU2nAwOmASTaDII3L04PVtaQ7oiWPty5YMI3Wk,5267
3
3
  tensorcircuit/abstractcircuit.py,sha256=0osacPqq7B1EJki-cI1aLYoVRmjFaG9q3XevWMs7SsA,44125
4
4
  tensorcircuit/asciiart.py,sha256=neY1OWFwtoW5cHPNwkQHgRPktDniQvdlP9QKHkk52fM,8236
@@ -19,7 +19,7 @@ tensorcircuit/shadows.py,sha256=6XmWNubbuaxFNvZVWu-RXd0lN9Jkk-xwong_K8o8_KE,1701
19
19
  tensorcircuit/simplify.py,sha256=O11G3UYiVAc30GOfwXXmhLXwGZrQ8OVwLTMQMZp_XBc,9414
20
20
  tensorcircuit/stabilizercircuit.py,sha256=4gDeTgko04j4dwt7NdJvl8NhqmB8JH75nZjdbLU3Aw0,15178
21
21
  tensorcircuit/torchnn.py,sha256=z_QpM0QC3mydGyWpyp877j-tSFCPyzynCwqrTWaw-IA,4637
22
- tensorcircuit/translation.py,sha256=D0-JzhN8IxBlPerwDN4ImGbS4VQg-nFxGry9BhEc4xk,28330
22
+ tensorcircuit/translation.py,sha256=VnU7DnYmbk1cWjqa7N68WNLNDn3DwENrMzmbG4_CQco,28611
23
23
  tensorcircuit/utils.py,sha256=CH9gTV4iKIikSS8KajIu3ttyC8i_1tBPf5PAYH1fgxs,7060
24
24
  tensorcircuit/vis.py,sha256=O4hm050KKfOAoVyHsjpMg6NBNVoWhLSlv-xsCx4opsU,12196
25
25
  tensorcircuit/applications/__init__.py,sha256=nAX-Am6JoL9k53iJ_CjZJ2NcjIpaz21H87nrW4Op03k,246
@@ -84,13 +84,13 @@ tensorcircuit/templates/dataset.py,sha256=ldPvCUlwjHU_S98E2ISQp34KqJzJPpPHmDIKJ4
84
84
  tensorcircuit/templates/graphs.py,sha256=cPYrxjoem0xZ-Is9dZKAvEzWZL_FejfIRiCEOTA4qd4,3935
85
85
  tensorcircuit/templates/lattice.py,sha256=F35ebANk0DSmSHLR0-Q_hUbcznyCmZjb4fKmvCMywmA,58575
86
86
  tensorcircuit/templates/measurements.py,sha256=pzc5Aa9S416Ilg4aOY77Z6ZhUlYcXnAkQNQFTuHjFFs,10943
87
- tensorcircuit_nightly-1.2.1.dev20250724.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
87
+ tensorcircuit_nightly-1.2.1.dev20250725.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
88
88
  tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
89
89
  tests/conftest.py,sha256=J9nHlLE3Zspz1rMyzadEuBWhaS5I4Q9sq0lnWybcdIA,1457
90
90
  tests/test_backends.py,sha256=rClxb2gyAoGeXd_ZYVSAJ0zEvJ7z_2btAeFM_Iy_wwY,33925
91
91
  tests/test_calibrating.py,sha256=D1Tlv8mucUhg3ULvB5QlYyaDfw7aEERwq69-aGSb1A4,3805
92
92
  tests/test_channels.py,sha256=BL4CirU8ku9-_NrI6PZAS5xZ0wrL1UEC1S3wPI9dYQM,12628
93
- tests/test_circuit.py,sha256=DkyNJmG4-r9WHEPtRyZ1XrLeECCnjPGiMMlf3Y6yzxg,51866
93
+ tests/test_circuit.py,sha256=Suc-nA7TBSJajYojzaBH33Xz_WdAeuk-_XJ5zTJHxOk,51886
94
94
  tests/test_cloud.py,sha256=241ng6LnG_o_2PKR-BuUFfmrj3V1aeFiI-_bcWuPFyo,5606
95
95
  tests/test_compiler.py,sha256=R1t0MDQR01uEbY2wxqzQEf-LkSehrfZWmLvPuguC2JI,3419
96
96
  tests/test_dmcircuit.py,sha256=Th5N6TCdGQ2MBWy8O3GNnMWshGui8XR_rUSeM2QlVcs,17232
@@ -114,7 +114,7 @@ tests/test_stabilizer.py,sha256=HdVRbEshg02CaNsqni_nRYY7KL5vhRBp9k1KGzOSE9I,5252
114
114
  tests/test_templates.py,sha256=Xm9otFFaaBWG9TZpgJ-nNh9MBfRipTzFWL8fBOnie2k,7192
115
115
  tests/test_torchnn.py,sha256=CHLTfWkF7Ses5_XnGFN_uv_JddfgenFEFzaDtSH8XYU,2848
116
116
  tests/test_van.py,sha256=kAWz860ivlb5zAJuYpzuBe27qccT-Yf0jatf5uXtTo4,3163
117
- tensorcircuit_nightly-1.2.1.dev20250724.dist-info/METADATA,sha256=zl0gksspBZ2l7gAYmvRyfOwclQEjtFkFy2k9cC46Fr8,34831
118
- tensorcircuit_nightly-1.2.1.dev20250724.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
119
- tensorcircuit_nightly-1.2.1.dev20250724.dist-info/top_level.txt,sha256=O_Iqeh2x02lasEYMI9iyPNNNtMzcpg5qvwMOkZQ7n4A,20
120
- tensorcircuit_nightly-1.2.1.dev20250724.dist-info/RECORD,,
117
+ tensorcircuit_nightly-1.2.1.dev20250725.dist-info/METADATA,sha256=46s8LvFtkm0NiHPNKCBB6-DJxH66JCO3mF2ztmLs-Ws,34831
118
+ tensorcircuit_nightly-1.2.1.dev20250725.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
119
+ tensorcircuit_nightly-1.2.1.dev20250725.dist-info/top_level.txt,sha256=O_Iqeh2x02lasEYMI9iyPNNNtMzcpg5qvwMOkZQ7n4A,20
120
+ tensorcircuit_nightly-1.2.1.dev20250725.dist-info/RECORD,,
tests/test_circuit.py CHANGED
@@ -1094,7 +1094,7 @@ def test_qiskit2tc():
1094
1094
  import qiskit.quantum_info as qi
1095
1095
  from qiskit import QuantumCircuit
1096
1096
  from qiskit.circuit.library import HamiltonianGate
1097
- from qiskit.circuit.library.standard_gates import MCXGate, SwapGate
1097
+ from qiskit.circuit.library.standard_gates import MCXGate, SwapGate, CXGate
1098
1098
 
1099
1099
  from tensorcircuit.translation import perm_matrix
1100
1100
  except ImportError:
@@ -1150,12 +1150,13 @@ def test_qiskit2tc():
1150
1150
  mcx_g = MCXGate(3, ctrl_state="010")
1151
1151
  qisc.append(mcx_g, [0, 1, 2, 3])
1152
1152
  qisc.ccx(0, 1, 2, ctrl_state="01")
1153
- CCCRX = SwapGate().control(2, ctrl_state="01")
1154
- qisc.append(CCCRX, [0, 1, 2, 3])
1153
+ CCswap = SwapGate().control(2, ctrl_state="01")
1154
+ qisc.append(CCswap, [0, 1, 2, 3])
1155
+ CCCX = CXGate().control(2, ctrl_state="01")
1156
+ qisc.append(CCCX, [1, 2, 3, 4])
1155
1157
 
1156
- c = tc.Circuit.from_qiskit(qisc, n, np.eye(2**n))
1157
- tc_unitary = c.wavefunction()
1158
- tc_unitary = np.reshape(tc_unitary, [2**n, 2**n])
1158
+ c = tc.Circuit.from_qiskit(qisc, n)
1159
+ tc_unitary = c.matrix()
1159
1160
  qis_unitary = qi.Operator(qisc)
1160
1161
  qis_unitary = np.reshape(qis_unitary, [2**n, 2**n])
1161
1162
  p_mat = perm_matrix(n)