tensorcircuit-nightly 1.3.0.dev20250730__tar.gz → 1.3.0.dev20250801__tar.gz

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.

Files changed (149) hide show
  1. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/CHANGELOG.md +14 -0
  2. {tensorcircuit_nightly-1.3.0.dev20250730/tensorcircuit_nightly.egg-info → tensorcircuit_nightly-1.3.0.dev20250801}/PKG-INFO +2 -2
  3. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/README.md +1 -1
  4. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/README_cn.md +1 -1
  5. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/__init__.py +1 -1
  6. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/backends/abstract_backend.py +66 -4
  7. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/backends/jax_backend.py +20 -1
  8. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/backends/jax_ops.py +108 -0
  9. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/backends/numpy_backend.py +7 -1
  10. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/backends/tensorflow_backend.py +34 -0
  11. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/fgs.py +5 -6
  12. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/quantum.py +1 -1
  13. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/stabilizercircuit.py +4 -2
  14. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/templates/lattice.py +52 -0
  15. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/timeevol.py +217 -0
  16. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801/tensorcircuit_nightly.egg-info}/PKG-INFO +2 -2
  17. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tests/test_backends.py +121 -0
  18. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tests/test_lattice.py +84 -0
  19. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tests/test_timeevol.py +188 -1
  20. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/HISTORY.md +0 -0
  21. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/LICENSE +0 -0
  22. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/MANIFEST.in +0 -0
  23. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/docs/source/advance.rst +0 -0
  24. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/docs/source/cnconf.py +0 -0
  25. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/docs/source/conf.py +0 -0
  26. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/docs/source/contribution.rst +0 -0
  27. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/docs/source/faq.rst +0 -0
  28. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/docs/source/generate_rst.py +0 -0
  29. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/docs/source/index.rst +0 -0
  30. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/docs/source/infras.rst +0 -0
  31. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/docs/source/modules.rst +0 -0
  32. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/docs/source/quickstart.rst +0 -0
  33. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/docs/source/sharpbits.rst +0 -0
  34. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/docs/source/textbooktoc.rst +0 -0
  35. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/docs/source/tutorial.rst +0 -0
  36. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/docs/source/tutorial_cn.rst +0 -0
  37. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/docs/source/whitepapertoc.rst +0 -0
  38. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/docs/source/whitepapertoc_cn.rst +0 -0
  39. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/setup.cfg +0 -0
  40. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/setup.py +0 -0
  41. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/about.py +0 -0
  42. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/abstractcircuit.py +0 -0
  43. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/applications/__init__.py +0 -0
  44. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/applications/ai/__init__.py +0 -0
  45. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/applications/ai/ensemble.py +0 -0
  46. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/applications/dqas.py +0 -0
  47. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/applications/finance/__init__.py +0 -0
  48. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/applications/finance/portfolio.py +0 -0
  49. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/applications/graphdata.py +0 -0
  50. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/applications/layers.py +0 -0
  51. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/applications/optimization.py +0 -0
  52. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/applications/physics/__init__.py +0 -0
  53. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/applications/physics/baseline.py +0 -0
  54. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/applications/physics/fss.py +0 -0
  55. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/applications/utils.py +0 -0
  56. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/applications/vags.py +0 -0
  57. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/applications/van.py +0 -0
  58. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/applications/vqes.py +0 -0
  59. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/asciiart.py +0 -0
  60. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/backends/__init__.py +0 -0
  61. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/backends/backend_factory.py +0 -0
  62. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/backends/cupy_backend.py +0 -0
  63. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/backends/pytorch_backend.py +0 -0
  64. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/backends/pytorch_ops.py +0 -0
  65. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/backends/tf_ops.py +0 -0
  66. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/basecircuit.py +0 -0
  67. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/channels.py +0 -0
  68. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/circuit.py +0 -0
  69. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/cloud/__init__.py +0 -0
  70. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/cloud/abstraction.py +0 -0
  71. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/cloud/apis.py +0 -0
  72. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/cloud/config.py +0 -0
  73. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/cloud/local.py +0 -0
  74. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/cloud/quafu_provider.py +0 -0
  75. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/cloud/tencent.py +0 -0
  76. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/cloud/utils.py +0 -0
  77. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/cloud/wrapper.py +0 -0
  78. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/compiler/__init__.py +0 -0
  79. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/compiler/composed_compiler.py +0 -0
  80. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/compiler/qiskit_compiler.py +0 -0
  81. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/compiler/simple_compiler.py +0 -0
  82. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/cons.py +0 -0
  83. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/densitymatrix.py +0 -0
  84. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/experimental.py +0 -0
  85. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/gates.py +0 -0
  86. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/interfaces/__init__.py +0 -0
  87. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/interfaces/jax.py +0 -0
  88. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/interfaces/numpy.py +0 -0
  89. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/interfaces/scipy.py +0 -0
  90. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/interfaces/tensorflow.py +0 -0
  91. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/interfaces/tensortrans.py +0 -0
  92. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/interfaces/torch.py +0 -0
  93. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/keras.py +0 -0
  94. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/mps_base.py +0 -0
  95. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/mpscircuit.py +0 -0
  96. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/noisemodel.py +0 -0
  97. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/results/__init__.py +0 -0
  98. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/results/counts.py +0 -0
  99. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/results/qem/__init__.py +0 -0
  100. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/results/qem/benchmark_circuits.py +0 -0
  101. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/results/qem/qem_methods.py +0 -0
  102. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/results/readout_mitigation.py +0 -0
  103. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/shadows.py +0 -0
  104. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/simplify.py +0 -0
  105. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/templates/__init__.py +0 -0
  106. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/templates/ansatz.py +0 -0
  107. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/templates/blocks.py +0 -0
  108. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/templates/chems.py +0 -0
  109. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/templates/conversions.py +0 -0
  110. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/templates/dataset.py +0 -0
  111. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/templates/graphs.py +0 -0
  112. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/templates/hamiltonians.py +0 -0
  113. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/templates/measurements.py +0 -0
  114. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/torchnn.py +0 -0
  115. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/translation.py +0 -0
  116. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/utils.py +0 -0
  117. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit/vis.py +0 -0
  118. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit_nightly.egg-info/SOURCES.txt +0 -0
  119. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit_nightly.egg-info/dependency_links.txt +0 -0
  120. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit_nightly.egg-info/requires.txt +0 -0
  121. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tensorcircuit_nightly.egg-info/top_level.txt +0 -0
  122. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tests/__init__.py +0 -0
  123. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tests/conftest.py +0 -0
  124. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tests/test_calibrating.py +0 -0
  125. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tests/test_channels.py +0 -0
  126. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tests/test_circuit.py +0 -0
  127. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tests/test_cloud.py +0 -0
  128. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tests/test_compiler.py +0 -0
  129. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tests/test_dmcircuit.py +0 -0
  130. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tests/test_ensemble.py +0 -0
  131. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tests/test_fgs.py +0 -0
  132. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tests/test_gates.py +0 -0
  133. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tests/test_hamiltonians.py +0 -0
  134. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tests/test_interfaces.py +0 -0
  135. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tests/test_keras.py +0 -0
  136. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tests/test_miscs.py +0 -0
  137. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tests/test_mpscircuit.py +0 -0
  138. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tests/test_noisemodel.py +0 -0
  139. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tests/test_qaoa.py +0 -0
  140. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tests/test_qem.py +0 -0
  141. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tests/test_quantum.py +0 -0
  142. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tests/test_quantum_attr.py +0 -0
  143. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tests/test_results.py +0 -0
  144. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tests/test_shadows.py +0 -0
  145. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tests/test_simplify.py +0 -0
  146. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tests/test_stabilizer.py +0 -0
  147. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tests/test_templates.py +0 -0
  148. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tests/test_torchnn.py +0 -0
  149. {tensorcircuit_nightly-1.3.0.dev20250730 → tensorcircuit_nightly-1.3.0.dev20250801}/tests/test_van.py +0 -0
@@ -6,12 +6,26 @@
6
6
 
7
7
  - Add new module `tc.timeevol` for different types of time evolution solvers.
8
8
 
9
+ - Add `special_jv` for numpy and jax backends.
10
+
11
+ - Add `jaxy_scan` for numpy and jax backends, contrasting to the tf style original backend scan method.
12
+
13
+ - Add `sparse_csr_from_coo` method for numpy and jax backends to convert COO format to CSR format, the latter is more efficient for `sparse_dense_matmul`.
14
+
15
+ - Add `krylov_evol` method for krylov evolution.
16
+
17
+ - Add `chebyshev_evol` method for chebyshev polynomial evolution.
18
+
19
+ - Add `ode_evol_local` and `ode_evol_global` methods for local and global ODE evolution.
20
+
9
21
  ### Fixed
10
22
 
11
23
  - Fixed `one_hot` in numpy backend.
12
24
 
13
25
  - Fixed `scan` in tensorflow backend and numpy backend.
14
26
 
27
+ - Fix potential np.matrix return from `PaulistringSum2Dense`.
28
+
15
29
  ### Changed
16
30
 
17
31
  - The order of arguments of `tc.timeevol.ed_evol` are changed for consistent interface with other evolution methods.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tensorcircuit-nightly
3
- Version: 1.3.0.dev20250730
3
+ Version: 1.3.0.dev20250801
4
4
  Summary: nightly release for tensorcircuit
5
5
  Home-page: https://github.com/refraction-ray/tensorcircuit-dev
6
6
  Author: TensorCircuit Authors
@@ -70,7 +70,7 @@ TensorCircuit-NG is the actively maintained official version and a [fully compat
70
70
 
71
71
  Please begin with [Quick Start](/docs/source/quickstart.rst) in the [full documentation](https://tensorcircuit-ng.readthedocs.io/).
72
72
 
73
- For more information on software usage, sota algorithm implementation and engineer paradigm demonstration, please refer to 80+ [example scripts](/examples) and 30+ [tutorial notebooks](https://tensorcircuit-ng.readthedocs.io/en/latest/#tutorials). API docstrings and test cases in [tests](/tests) are also informative. One can also refer to AI-native docs for tensorcircuit-ng: [Devin Deepwiki](https://deepwiki.com/tensorcircuit/tensorcircuit-ng) and [Context7 MCP](https://context7.com/tensorcircuit/tensorcircuit-ng).
73
+ For more information on software usage, sota algorithm implementation and engineer paradigm demonstration, please refer to 90+ [example scripts](/examples) and 30+ [tutorial notebooks](https://tensorcircuit-ng.readthedocs.io/en/latest/#tutorials). API docstrings and test cases in [tests](/tests) are also informative. One can also refer to AI-native docs for tensorcircuit-ng: [Devin Deepwiki](https://deepwiki.com/tensorcircuit/tensorcircuit-ng) and [Context7 MCP](https://context7.com/tensorcircuit/tensorcircuit-ng).
74
74
 
75
75
  For beginners, please refer to [quantum computing lectures with TC-NG](https://github.com/sxzgroup/qc_lecture) to learn both quantum computing basics and representative usage of TensorCircuit-NG.
76
76
 
@@ -35,7 +35,7 @@ TensorCircuit-NG is the actively maintained official version and a [fully compat
35
35
 
36
36
  Please begin with [Quick Start](/docs/source/quickstart.rst) in the [full documentation](https://tensorcircuit-ng.readthedocs.io/).
37
37
 
38
- For more information on software usage, sota algorithm implementation and engineer paradigm demonstration, please refer to 80+ [example scripts](/examples) and 30+ [tutorial notebooks](https://tensorcircuit-ng.readthedocs.io/en/latest/#tutorials). API docstrings and test cases in [tests](/tests) are also informative. One can also refer to AI-native docs for tensorcircuit-ng: [Devin Deepwiki](https://deepwiki.com/tensorcircuit/tensorcircuit-ng) and [Context7 MCP](https://context7.com/tensorcircuit/tensorcircuit-ng).
38
+ For more information on software usage, sota algorithm implementation and engineer paradigm demonstration, please refer to 90+ [example scripts](/examples) and 30+ [tutorial notebooks](https://tensorcircuit-ng.readthedocs.io/en/latest/#tutorials). API docstrings and test cases in [tests](/tests) are also informative. One can also refer to AI-native docs for tensorcircuit-ng: [Devin Deepwiki](https://deepwiki.com/tensorcircuit/tensorcircuit-ng) and [Context7 MCP](https://context7.com/tensorcircuit/tensorcircuit-ng).
39
39
 
40
40
  For beginners, please refer to [quantum computing lectures with TC-NG](https://github.com/sxzgroup/qc_lecture) to learn both quantum computing basics and representative usage of TensorCircuit-NG.
41
41
 
@@ -33,7 +33,7 @@ TensorCircuit-NG 是目前积极维护的唯一官方版本,是 TensorCircuit
33
33
 
34
34
  请从 [完整文档](https://tensorcircuit-ng.readthedocs.io/) 中的 [快速上手](/docs/source/quickstart.rst) 开始。
35
35
 
36
- 有关软件用法,算法实现和工程范式演示的更多信息和介绍,请参阅 80+ [示例脚本](/examples) 和 30+ [案例教程](https://tensorcircuit-ng.readthedocs.io/en/latest/#tutorials)。 [测试](/tests) 用例和 API docstring 也提供了丰富的使用信息。
36
+ 有关软件用法,算法实现和工程范式演示的更多信息和介绍,请参阅 90+ [示例脚本](/examples) 和 30+ [案例教程](https://tensorcircuit-ng.readthedocs.io/en/latest/#tutorials)。 [测试](/tests) 用例和 API docstring 也提供了丰富的使用信息。
37
37
 
38
38
  TensorCircuit-NG 也支持 AI 原生编程资源:[Devin Deepwiki](https://deepwiki.com/tensorcircuit/tensorcircuit-ng) 和 [Context7 MCP](https://context7.com/tensorcircuit/tensorcircuit-ng).
39
39
 
@@ -1,4 +1,4 @@
1
- __version__ = "1.3.0.dev20250730"
1
+ __version__ = "1.3.0.dev20250801"
2
2
  __author__ = "TensorCircuit Authors"
3
3
  __creator__ = "refraction-ray"
4
4
 
@@ -808,6 +808,21 @@ class ExtendedBackend:
808
808
  "Backend '{}' has not implemented `solve`.".format(self.name)
809
809
  )
810
810
 
811
+ def special_jv(self: Any, v: int, z: Tensor, M: int) -> Tensor:
812
+ """
813
+ Special function: Bessel function of the first kind.
814
+
815
+ :param v: The order of the Bessel function.
816
+ :type v: int
817
+ :param z: The argument of the Bessel function.
818
+ :type z: Tensor
819
+ :return: The value of the Bessel function [J_0, ...J_{v-1}(z)].
820
+ :rtype: Tensor
821
+ """
822
+ raise NotImplementedError(
823
+ "Backend '{}' has not implemented `special_jv`.".format(self.name)
824
+ )
825
+
811
826
  def searchsorted(self: Any, a: Tensor, v: Tensor, side: str = "left") -> Tensor:
812
827
  """
813
828
  Find indices where elements should be inserted to maintain order.
@@ -1251,6 +1266,26 @@ class ExtendedBackend:
1251
1266
  "Backend '{}' has not implemented `sparse_dense_matmul`.".format(self.name)
1252
1267
  )
1253
1268
 
1269
+ def sparse_csr_from_coo(self: Any, coo: Tensor, strict: bool = False) -> Tensor:
1270
+ """
1271
+ transform a coo matrix to a csr matrix
1272
+
1273
+ :param coo: a coo matrix
1274
+ :type coo: Tensor
1275
+ :param strict: whether to enforce the transform, defaults to False,
1276
+ corresponding to return the coo matrix if there is no implementation for specific backend.
1277
+ :type strict: bool, optional
1278
+ :return: a csr matrix
1279
+ :rtype: Tensor
1280
+ """
1281
+ if strict:
1282
+ raise NotImplementedError(
1283
+ "Backend '{}' has not implemented `sparse_csr_from_coo`.".format(
1284
+ self.name
1285
+ )
1286
+ )
1287
+ return coo
1288
+
1254
1289
  def to_dense(self: Any, sp_a: Tensor) -> Tensor:
1255
1290
  """
1256
1291
  Convert a sparse matrix to dense tensor.
@@ -1400,10 +1435,37 @@ class ExtendedBackend:
1400
1435
  carry = f(carry, x)
1401
1436
 
1402
1437
  return carry
1403
- # carry = init
1404
- # for x in xs:
1405
- # carry = f(carry, x)
1406
- # return carry
1438
+
1439
+ def jaxy_scan(
1440
+ self: Any, f: Callable[[Tensor, Tensor], Tensor], init: Tensor, xs: Tensor
1441
+ ) -> Tensor:
1442
+ """
1443
+ This API follows jax scan style. TF use plain for loop
1444
+
1445
+ :param f: _description_
1446
+ :type f: Callable[[Tensor, Tensor], Tensor]
1447
+ :param init: _description_
1448
+ :type init: Tensor
1449
+ :param xs: _description_
1450
+ :type xs: Tensor
1451
+ :raises ValueError: _description_
1452
+ :return: _description_
1453
+ :rtype: Tensor
1454
+ """
1455
+ if xs is None:
1456
+ raise ValueError("Either xs or length must be provided.")
1457
+ if xs is not None:
1458
+ length = len(xs)
1459
+ carry, outputs_to_stack = init, []
1460
+ for i in range(length):
1461
+ if isinstance(xs, (tuple, list)):
1462
+ x = [ele[i] for ele in xs]
1463
+ else:
1464
+ x = xs[i]
1465
+ new_carry, y = f(carry, x)
1466
+ carry = new_carry
1467
+ outputs_to_stack.append(y)
1468
+ return carry, self.stack(outputs_to_stack)
1407
1469
 
1408
1470
  def stop_gradient(self: Any, a: Tensor) -> Tensor:
1409
1471
  """
@@ -418,6 +418,11 @@ class JaxBackend(jax_backend.JaxBackend, ExtendedBackend): # type: ignore
418
418
  def solve(self, A: Tensor, b: Tensor, assume_a: str = "gen") -> Tensor: # type: ignore
419
419
  return jsp.linalg.solve(A, b, assume_a=assume_a)
420
420
 
421
+ def special_jv(self, v: int, z: Tensor, M: int) -> Tensor:
422
+ from .jax_ops import bessel_jv_jax_rescaled
423
+
424
+ return bessel_jv_jax_rescaled(v, z, M)
425
+
421
426
  def searchsorted(self, a: Tensor, v: Tensor, side: str = "left") -> Tensor:
422
427
  if not self.is_tensor(a):
423
428
  a = self.convert_to_tensor(a)
@@ -615,6 +620,11 @@ class JaxBackend(jax_backend.JaxBackend, ExtendedBackend): # type: ignore
615
620
  carry, _ = libjax.lax.scan(f_jax, init, xs)
616
621
  return carry
617
622
 
623
+ def jaxy_scan(
624
+ self, f: Callable[[Tensor, Tensor], Tensor], init: Tensor, xs: Tensor
625
+ ) -> Tensor:
626
+ return libjax.lax.scan(f, init, xs)
627
+
618
628
  def scatter(self, operand: Tensor, indices: Tensor, updates: Tensor) -> Tensor:
619
629
  # updates = jnp.reshape(updates, indices.shape)
620
630
  # return operand.at[indices].set(updates)
@@ -639,11 +649,20 @@ class JaxBackend(jax_backend.JaxBackend, ExtendedBackend): # type: ignore
639
649
  ) -> Tensor:
640
650
  return sp_a @ b
641
651
 
652
+ def sparse_csr_from_coo(self, coo: Tensor, strict: bool = False) -> Tensor:
653
+ try:
654
+ return sparse.BCSR.from_bcoo(coo) # type: ignore
655
+ except AttributeError as e:
656
+ if not strict:
657
+ return coo
658
+ else:
659
+ raise e
660
+
642
661
  def to_dense(self, sp_a: Tensor) -> Tensor:
643
662
  return sp_a.todense()
644
663
 
645
664
  def is_sparse(self, a: Tensor) -> bool:
646
- return isinstance(a, sparse.BCOO) # type: ignore
665
+ return isinstance(a, sparse.JAXSparse) # type: ignore
647
666
 
648
667
  def device(self, a: Tensor) -> str:
649
668
  (dev,) = a.devices()
@@ -3,8 +3,11 @@ Customized ops for ML framework
3
3
  """
4
4
 
5
5
  # pylint: disable=invalid-name
6
+ # pylint: disable=unused-variable
7
+
6
8
 
7
9
  from typing import Any, Tuple, Sequence
10
+ from functools import partial
8
11
 
9
12
  import jax
10
13
  import jax.numpy as jnp
@@ -174,3 +177,108 @@ def jaxeigh_bwd(r: Array, tangents: Array) -> Array:
174
177
 
175
178
  adaware_eigh.defvjp(jaxeigh_fwd, jaxeigh_bwd)
176
179
  adaware_eigh_jit = jax.jit(adaware_eigh)
180
+
181
+
182
+ @partial(jax.jit, static_argnums=[0, 2])
183
+ def bessel_jv_jax_rescaled(k: int, x: jnp.ndarray, M: int) -> jnp.ndarray:
184
+ """
185
+ Computes Bessel function Jv using Miller's algorithm with dynamic rescaling,
186
+ implemented in JAX.
187
+ """
188
+ if M <= k:
189
+ raise ValueError(
190
+ f"Recurrence length M ({M}) must be greater than the required order k ({k})."
191
+ )
192
+
193
+ # Use vmap to handle array inputs for x efficiently.
194
+ # We map _bessel_jv_scalar_rescaled over the last dimension of x.
195
+ return _bessel_jv_scalar_rescaled(k, M, x)
196
+
197
+
198
+ def _bessel_jv_scalar_rescaled(k: int, M: int, x_val: jnp.ndarray) -> jnp.ndarray:
199
+ """
200
+ JAX implementation for a scalar input x_val.
201
+ This function will be vmapped for array inputs.
202
+ """
203
+ rescale_threshold = 1e250
204
+
205
+ # Define the body of the recurrence loop
206
+ def recurrence_body(i, state): # type: ignore
207
+ # M - i is the current 'm' value in the original loop.
208
+ # Loop from M down to 1. jax.lax.fori_loop goes from lower to upper-1.
209
+ # So for m from M down to 1, we map i from 0 to M-1.
210
+ # Current m_val = M - i
211
+ # The loop range for m in numpy was `range(M, 0, -1)`, which means m goes from M, M-1, ..., 1.
212
+ # For lax.fori_loop (start, stop, body_fn, init_val), start is inclusive, stop is exclusive.
213
+ # So to iterate M times for m from M down to 1, we do i from 0 to M-1.
214
+ # m_val = M - i means that for i=0, m_val=M; for i=M-1, m_val=1.
215
+ m_val = M - i
216
+ f_m, f_m_p1, f_vals = state
217
+
218
+ # If x_val is near zero, this division could be an issue,
219
+ # but the outer lax.cond handles the x_val near zero case before this loop runs.
220
+ f_m_m1 = (2.0 * m_val / x_val) * f_m - f_m_p1
221
+
222
+ # --- Rescaling Step ---
223
+ # jax.lax.cond requires all branches to return the exact same type and shape.
224
+ def rescale_branch(vals): # type: ignore
225
+ f_m_val, f_m_p1_val, f_vals_arr = vals
226
+ scale_factor = f_m_m1
227
+ # Return new f_m, f_m_p1, updated f_vals_arr, and the new f_m_m1 value (which is 1.0)
228
+ return (
229
+ f_m_val / scale_factor,
230
+ f_m_p1_val / scale_factor,
231
+ f_vals_arr / scale_factor,
232
+ 1.0,
233
+ )
234
+
235
+ def no_rescale_branch(vals): # type: ignore
236
+ f_m_val, f_m_p1_val, f_vals_arr = (
237
+ vals # Unpack to keep signatures consistent
238
+ )
239
+ # Return original f_m, f_m_p1, original f_vals_arr, and the computed f_m_m1
240
+ return (f_m_val, f_m_p1_val, f_vals_arr, f_m_m1)
241
+
242
+ f_m_rescaled, f_m_p1_rescaled, f_vals_rescaled, f_m_m1_effective = jax.lax.cond(
243
+ jnp.abs(f_m_m1) > rescale_threshold,
244
+ rescale_branch,
245
+ no_rescale_branch,
246
+ (f_m, f_m_p1, f_vals), # Arguments passed to branches
247
+ )
248
+
249
+ # Update f_vals at index m_val - 1. JAX uses .at[idx].set(val) for non-in-place updates.
250
+ f_vals_updated = f_vals_rescaled.at[m_val - 1].set(f_m_m1_effective)
251
+
252
+ # Return new state for the next iteration: (new f_m, new f_m_p1, updated f_vals)
253
+ return (f_m_m1_effective, f_m_rescaled, f_vals_updated)
254
+
255
+ # Initial state for the recurrence loop
256
+ f_m_p1_init = 0.0
257
+ f_m_init = 1e-30 # Start with a very small number
258
+ f_vals_init = jnp.zeros(M + 1).at[M].set(f_m_init)
259
+
260
+ # Use jax.lax.fori_loop for the backward recurrence
261
+ # Loop from i = 0 to M-1 (total M iterations)
262
+ # The 'body' function gets current 'i' and 'state', returns 'new_state'.
263
+ # We don't need the final f_m_p1, only f_m and f_vals.
264
+ final_f_m, _, f_vals = jax.lax.fori_loop(
265
+ 0, M, recurrence_body, (f_m_init, f_m_p1_init, f_vals_init)
266
+ )
267
+
268
+ # Normalization using Neumann's sum rule
269
+ even_sum = jnp.sum(f_vals[2::2])
270
+ norm_const = f_vals[0] + 2.0 * even_sum
271
+
272
+ # Handle division by near-zero normalization constant
273
+ norm_const_safe = jnp.where(jnp.abs(norm_const) < 1e-12, 1e-12, norm_const)
274
+
275
+ # Conditional logic for x_val close to zero
276
+ def x_is_zero_case() -> jnp.ndarray:
277
+ # For x=0, J_0(0)=1, J_k(0)=0 for k>0
278
+ return jnp.zeros(k).at[0].set(1.0)
279
+
280
+ def x_is_not_zero_case() -> jnp.ndarray:
281
+ return f_vals[:k] / norm_const_safe # type: ignore
282
+
283
+ # Use lax.cond to select between the two cases based on x_val
284
+ return jax.lax.cond(jnp.abs(x_val) < 1e-12, x_is_zero_case, x_is_not_zero_case) # type: ignore
@@ -17,7 +17,7 @@ except ImportError: # np2.0 compatibility
17
17
 
18
18
  import tensornetwork
19
19
  from scipy.linalg import expm, solve, schur
20
- from scipy.special import softmax, expit
20
+ from scipy.special import softmax, expit, jv
21
21
  from scipy.sparse import coo_matrix, issparse
22
22
  from tensornetwork.backends.numpy import numpy_backend
23
23
  from .abstract_backend import ExtendedBackend
@@ -245,6 +245,9 @@ class NumpyBackend(numpy_backend.NumPyBackend, ExtendedBackend): # type: ignore
245
245
  # https://stackoverflow.com/questions/44672029/difference-between-numpy-linalg-solve-and-numpy-linalg-lu-solve/44710451
246
246
  return solve(A, b, assume_a=assume_a)
247
247
 
248
+ def special_jv(self, v: int, z: Tensor, M: int) -> Tensor:
249
+ return jv(np.arange(v), z)
250
+
248
251
  def searchsorted(self, a: Tensor, v: Tensor, side: str = "left") -> Tensor:
249
252
  return np.searchsorted(a, v, side=side) # type: ignore
250
253
 
@@ -330,6 +333,9 @@ class NumpyBackend(numpy_backend.NumPyBackend, ExtendedBackend): # type: ignore
330
333
  ) -> Tensor:
331
334
  return sp_a @ b
332
335
 
336
+ def sparse_csr_from_coo(self, coo: Tensor, strict: bool = False) -> Tensor:
337
+ return coo.tocsr()
338
+
333
339
  def to_dense(self, sp_a: Tensor) -> Tensor:
334
340
  return sp_a.todense()
335
341
 
@@ -360,6 +360,38 @@ tensornetwork.backends.tensorflow.tensorflow_backend.TensorFlowBackend.rq = _rq_
360
360
  tensornetwork.backends.tensorflow.tensorflow_backend.TensorFlowBackend.svd = _svd_tf
361
361
 
362
362
 
363
+ def sparse_tensor_matmul(self: Tensor, other: Tensor) -> Tensor:
364
+ """
365
+ An implementation of matrix multiplication (@) for tf.SparseTensor.
366
+
367
+ This function is designed to be monkey-patched onto the tf.SparseTensor class.
368
+ It handles multiplication with a dense vector (rank-1 Tensor) by temporarily
369
+ promoting it to a matrix (rank-2 Tensor) for the underlying TensorFlow call.
370
+ """
371
+ # Ensure the 'other' tensor is of a compatible dtype
372
+ if not other.dtype.is_compatible_with(self.dtype):
373
+ other = tf.cast(other, self.dtype)
374
+
375
+ # tf.sparse.sparse_dense_matmul requires the dense tensor to be a 2D matrix.
376
+ # If we get a 1D vector, we need to reshape it.
377
+ is_vector = len(other.shape) == 1
378
+
379
+ if is_vector:
380
+ # Promote the vector to a column matrix [N] -> [N, 1]
381
+ other_matrix = tf.expand_dims(other, axis=1)
382
+ else:
383
+ other_matrix = other
384
+
385
+ # Perform the actual multiplication
386
+ result_matrix = tf.sparse.sparse_dense_matmul(self, other_matrix)
387
+
388
+ if is_vector:
389
+ # Demote the result matrix back to a vector [M, 1] -> [M]
390
+ return tf.squeeze(result_matrix, axis=1)
391
+ else:
392
+ return result_matrix
393
+
394
+
363
395
  class TensorFlowBackend(tensorflow_backend.TensorFlowBackend, ExtendedBackend): # type: ignore
364
396
  """
365
397
  See the original backend API at `tensorflow backend
@@ -378,6 +410,8 @@ class TensorFlowBackend(tensorflow_backend.TensorFlowBackend, ExtendedBackend):
378
410
  )
379
411
  tf = tensorflow
380
412
  tf.sparse.SparseTensor.__add__ = tf.sparse.add
413
+ tf.SparseTensor.__matmul__ = sparse_tensor_matmul
414
+
381
415
  self.minor = int(tf.__version__.split(".")[1])
382
416
  self.name = "tensorflow"
383
417
  logger = tf.get_logger() # .setLevel('ERROR')
@@ -28,7 +28,6 @@ def onehot_matrix(i: int, j: int, N: int) -> Tensor:
28
28
 
29
29
  # TODO(@refraction-ray): efficiency benchmark with jit
30
30
  # TODO(@refraction-ray): FGS mixed state support?
31
- # TODO(@refraction-ray): overlap?
32
31
  # TODO(@refraction-ray): fermionic logarithmic negativity
33
32
 
34
33
 
@@ -227,7 +226,7 @@ class FGSSimulator:
227
226
  return self.alpha
228
227
 
229
228
  def get_cmatrix(self, now_i: bool = True, now_j: bool = True) -> Tensor:
230
- """
229
+ r"""
231
230
  Calculates the correlation matrix.
232
231
 
233
232
  The correlation matrix is defined as :math:`C_{ij} = \langle c_i^\dagger c_j \rangle`.
@@ -509,7 +508,7 @@ class FGSSimulator:
509
508
 
510
509
  @staticmethod
511
510
  def hopping(chi: Tensor, i: int, j: int, L: int) -> Tensor:
512
- """
511
+ r"""
513
512
  Constructs the hopping Hamiltonian between two sites.
514
513
 
515
514
  The hopping Hamiltonian is given by :math:`\chi c_i^\dagger c_j + h.c.`.
@@ -550,7 +549,7 @@ class FGSSimulator:
550
549
 
551
550
  @staticmethod
552
551
  def chemical_potential(chi: Tensor, i: int, L: int) -> Tensor:
553
- """
552
+ r"""
554
553
  Constructs the chemical potential Hamiltonian for a single site.
555
554
 
556
555
  The chemical potential Hamiltonian is given by :math:`\chi c_i^\dagger c_i`.
@@ -572,7 +571,7 @@ class FGSSimulator:
572
571
 
573
572
  @staticmethod
574
573
  def sc_pairing(chi: Tensor, i: int, j: int, L: int) -> Tensor:
575
- """
574
+ r"""
576
575
  Constructs the superconducting pairing Hamiltonian between two sites.
577
576
 
578
577
  The superconducting pairing Hamiltonian is given by :math:`\chi c_i^\dagger c_j^\dagger + h.c.`.
@@ -637,7 +636,7 @@ class FGSSimulator:
637
636
  self.evol_ihamiltonian(self.chemical_potential(chi, i, self.L))
638
637
 
639
638
  def get_bogoliubov_uv(self) -> Tuple[Tensor, Tensor]:
640
- """
639
+ r"""
641
640
  Returns the u and v matrices of the Bogoliubov transformation.
642
641
 
643
642
  The Bogoliubov transformation is defined as:
@@ -1433,7 +1433,7 @@ def PauliStringSum2Dense(
1433
1433
  return sparsem.todense()
1434
1434
  sparsem = backend.coo_sparse_matrix_from_numpy(sparsem)
1435
1435
  densem = backend.to_dense(sparsem)
1436
- return densem
1436
+ return backend.convert_to_tensor(densem)
1437
1437
 
1438
1438
 
1439
1439
  # already implemented as backend method
@@ -96,10 +96,12 @@ class StabilizerCircuit(AbstractCircuit):
96
96
 
97
97
  if name.lower() in self.gate_map:
98
98
  # self._stim_circuit.append(gate_map[name.lower()], list(index))
99
- instruction = f"{self.gate_map[name.lower()]} {' '.join(map(str, index))}"
99
+ gn = self.gate_map[name.lower()]
100
+ instruction = f"{gn} {' '.join(map(str, index))}"
100
101
  self._stim_circuit.append_from_stim_program_text(instruction)
101
102
  # append is much slower
102
- self.current_sim.do(stim.Circuit(instruction))
103
+ # self.current_sim.do(stim.Circuit(instruction))
104
+ getattr(self.current_sim, gn.lower())(*index)
103
105
  else:
104
106
  raise ValueError(f"Gate {name} is not supported in stabilizer simulation")
105
107
 
@@ -15,6 +15,7 @@ from typing import (
15
15
  Union,
16
16
  TYPE_CHECKING,
17
17
  cast,
18
+ Set,
18
19
  )
19
20
 
20
21
  logger = logging.getLogger(__name__)
@@ -1446,3 +1447,54 @@ class CustomizeLattice(AbstractLattice):
1446
1447
  logger.info(
1447
1448
  f"{len(ids_to_remove)} sites removed. Lattice now has {self.num_sites} sites."
1448
1449
  )
1450
+
1451
+
1452
+ def get_compatible_layers(bonds: List[Tuple[int, int]]) -> List[List[Tuple[int, int]]]:
1453
+ """
1454
+ Partitions a list of pairs (bonds) into compatible layers for parallel
1455
+ gate application using a greedy edge-coloring algorithm.
1456
+
1457
+ This function takes a list of pairs, representing connections like
1458
+ nearest-neighbor (NN) or next-nearest-neighbor (NNN) bonds, and
1459
+ partitions them into the minimum number of sets ("layers") where no two
1460
+ pairs in a set share an index. This is a general utility for scheduling
1461
+ non-overlapping operations.
1462
+
1463
+ :Example:
1464
+
1465
+ >>> from tensorcircuit.templates.lattice import SquareLattice
1466
+ >>> sq_lattice = SquareLattice(size=(2, 2), pbc=False)
1467
+ >>> nn_bonds = sq_lattice.get_neighbor_pairs(k=1, unique=True)
1468
+
1469
+ >>> gate_layers = get_compatible_layers(nn_bonds)
1470
+ >>> print(gate_layers)
1471
+ [[[0, 1], [2, 3]], [[0, 2], [1, 3]]]
1472
+
1473
+ :param bonds: A list of tuples, where each tuple represents a bond (i, j)
1474
+ of site indices to be scheduled.
1475
+ :type bonds: List[Tuple[int, int]]
1476
+ :return: A list of layers. Each layer is a list of tuples, where each
1477
+ tuple represents a bond. All bonds within a layer are non-overlapping.
1478
+ :rtype: List[List[Tuple[int, int]]]
1479
+ """
1480
+ uncolored_edges: Set[Tuple[int, int]] = {(min(bond), max(bond)) for bond in bonds}
1481
+
1482
+ layers: List[List[Tuple[int, int]]] = []
1483
+
1484
+ while uncolored_edges:
1485
+ current_layer: List[Tuple[int, int]] = []
1486
+ qubits_in_this_layer: Set[int] = set()
1487
+
1488
+ edges_to_process = sorted(list(uncolored_edges))
1489
+
1490
+ for edge in edges_to_process:
1491
+ i, j = edge
1492
+ if i not in qubits_in_this_layer and j not in qubits_in_this_layer:
1493
+ current_layer.append(edge)
1494
+ qubits_in_this_layer.add(i)
1495
+ qubits_in_this_layer.add(j)
1496
+
1497
+ uncolored_edges -= set(current_layer)
1498
+ layers.append(sorted(current_layer))
1499
+
1500
+ return layers