tensorcircuit-nightly 1.3.0.dev20250728__tar.gz → 1.3.0.dev20250730__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.
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/CHANGELOG.md +14 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/PKG-INFO +2 -2
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/README.md +1 -1
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/README_cn.md +7 -3
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/docs/source/advance.rst +291 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/docs/source/modules.rst +1 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/__init__.py +2 -1
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/backends/abstract_backend.py +17 -2
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/backends/numpy_backend.py +1 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/backends/tensorflow_backend.py +12 -2
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/experimental.py +7 -152
- tensorcircuit_nightly-1.3.0.dev20250730/tensorcircuit/timeevol.py +594 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit_nightly.egg-info/PKG-INFO +2 -2
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit_nightly.egg-info/SOURCES.txt +2 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tests/test_miscs.py +0 -30
- tensorcircuit_nightly-1.3.0.dev20250730/tests/test_timeevol.py +454 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/HISTORY.md +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/LICENSE +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/MANIFEST.in +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/docs/source/cnconf.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/docs/source/conf.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/docs/source/contribution.rst +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/docs/source/faq.rst +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/docs/source/generate_rst.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/docs/source/index.rst +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/docs/source/infras.rst +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/docs/source/quickstart.rst +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/docs/source/sharpbits.rst +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/docs/source/textbooktoc.rst +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/docs/source/tutorial.rst +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/docs/source/tutorial_cn.rst +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/docs/source/whitepapertoc.rst +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/docs/source/whitepapertoc_cn.rst +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/setup.cfg +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/setup.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/about.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/abstractcircuit.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/applications/__init__.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/applications/ai/__init__.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/applications/ai/ensemble.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/applications/dqas.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/applications/finance/__init__.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/applications/finance/portfolio.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/applications/graphdata.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/applications/layers.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/applications/optimization.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/applications/physics/__init__.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/applications/physics/baseline.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/applications/physics/fss.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/applications/utils.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/applications/vags.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/applications/van.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/applications/vqes.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/asciiart.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/backends/__init__.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/backends/backend_factory.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/backends/cupy_backend.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/backends/jax_backend.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/backends/jax_ops.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/backends/pytorch_backend.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/backends/pytorch_ops.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/backends/tf_ops.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/basecircuit.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/channels.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/circuit.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/cloud/__init__.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/cloud/abstraction.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/cloud/apis.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/cloud/config.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/cloud/local.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/cloud/quafu_provider.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/cloud/tencent.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/cloud/utils.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/cloud/wrapper.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/compiler/__init__.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/compiler/composed_compiler.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/compiler/qiskit_compiler.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/compiler/simple_compiler.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/cons.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/densitymatrix.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/fgs.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/gates.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/interfaces/__init__.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/interfaces/jax.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/interfaces/numpy.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/interfaces/scipy.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/interfaces/tensorflow.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/interfaces/tensortrans.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/interfaces/torch.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/keras.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/mps_base.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/mpscircuit.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/noisemodel.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/quantum.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/results/__init__.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/results/counts.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/results/qem/__init__.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/results/qem/benchmark_circuits.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/results/qem/qem_methods.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/results/readout_mitigation.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/shadows.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/simplify.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/stabilizercircuit.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/templates/__init__.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/templates/ansatz.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/templates/blocks.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/templates/chems.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/templates/conversions.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/templates/dataset.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/templates/graphs.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/templates/hamiltonians.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/templates/lattice.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/templates/measurements.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/torchnn.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/translation.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/utils.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit/vis.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit_nightly.egg-info/dependency_links.txt +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit_nightly.egg-info/requires.txt +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tensorcircuit_nightly.egg-info/top_level.txt +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tests/__init__.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tests/conftest.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tests/test_backends.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tests/test_calibrating.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tests/test_channels.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tests/test_circuit.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tests/test_cloud.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tests/test_compiler.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tests/test_dmcircuit.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tests/test_ensemble.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tests/test_fgs.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tests/test_gates.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tests/test_hamiltonians.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tests/test_interfaces.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tests/test_keras.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tests/test_lattice.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tests/test_mpscircuit.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tests/test_noisemodel.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tests/test_qaoa.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tests/test_qem.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tests/test_quantum.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tests/test_quantum_attr.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tests/test_results.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tests/test_shadows.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tests/test_simplify.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tests/test_stabilizer.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tests/test_templates.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tests/test_torchnn.py +0 -0
- {tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/tests/test_van.py +0 -0
{tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/CHANGELOG.md
RENAMED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Add new module `tc.timeevol` for different types of time evolution solvers.
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- Fixed `one_hot` in numpy backend.
|
|
12
|
+
|
|
13
|
+
- Fixed `scan` in tensorflow backend and numpy backend.
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- The order of arguments of `tc.timeevol.ed_evol` are changed for consistent interface with other evolution methods.
|
|
18
|
+
|
|
5
19
|
## v1.3.0
|
|
6
20
|
|
|
7
21
|
### Added
|
{tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tensorcircuit-nightly
|
|
3
|
-
Version: 1.3.0.
|
|
3
|
+
Version: 1.3.0.dev20250730
|
|
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 tensorcircuit-ng [
|
|
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).
|
|
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
|
|
{tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/README.md
RENAMED
|
@@ -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 tensorcircuit-ng [
|
|
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).
|
|
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
|
|
{tensorcircuit_nightly-1.3.0.dev20250728 → tensorcircuit_nightly-1.3.0.dev20250730}/README_cn.md
RENAMED
|
@@ -21,11 +21,13 @@
|
|
|
21
21
|
|
|
22
22
|
<p align="center"> <a href="README.md">English</a> | 简体中文 </p>
|
|
23
23
|
|
|
24
|
-
TensorCircuit-NG
|
|
24
|
+
TensorCircuit-NG 是下一代量子软件框架,完美支持自动微分、即时编译、硬件加速、向量并行化和分布式训练。
|
|
25
25
|
|
|
26
|
-
TensorCircuit-NG 建立在现代机器学习框架 Jax, TensorFlow, PyTorch 之上,支持机器学习后端无关的统一界面。
|
|
26
|
+
TensorCircuit-NG 建立在现代机器学习框架 Jax, TensorFlow, PyTorch 之上,支持机器学习后端无关的统一界面。 其特别适用于理想情况、含噪声情况、稳定子情况、可控近似情况、连续动力学情况及费米子情况下,大规模量子经典混合范式和变分量子算法的高效模拟。其可以高效地编织和模拟量子线路、张量网络和神经网络组成的混合计算图。
|
|
27
27
|
|
|
28
|
-
TensorCircuit-NG 现在支持真实量子硬件连接和实验,并提供优雅的 CPU/GPU/QPU
|
|
28
|
+
TensorCircuit-NG 现在支持真实量子硬件连接和实验,并提供优雅的 CPU/GPU/QPU 硬件混合部署训练方案。
|
|
29
|
+
|
|
30
|
+
TensorCircuit-NG 是目前积极维护的唯一官方版本,是 TensorCircuit 的[完全兼容](https://github.com/orgs/tensorcircuit/discussions/19)的升级版本,它包含了更多新功能(例如稳定子线路、多卡分布式模拟等)和错误修复(例如支持最新的 numpy>2 和 qiskit>1)。
|
|
29
31
|
|
|
30
32
|
## 入门
|
|
31
33
|
|
|
@@ -33,6 +35,8 @@ TensorCircuit-NG 现在支持真实量子硬件连接和实验,并提供优雅
|
|
|
33
35
|
|
|
34
36
|
有关软件用法,算法实现和工程范式演示的更多信息和介绍,请参阅 80+ [示例脚本](/examples) 和 30+ [案例教程](https://tensorcircuit-ng.readthedocs.io/en/latest/#tutorials)。 [测试](/tests) 用例和 API docstring 也提供了丰富的使用信息。
|
|
35
37
|
|
|
38
|
+
TensorCircuit-NG 也支持 AI 原生编程资源:[Devin Deepwiki](https://deepwiki.com/tensorcircuit/tensorcircuit-ng) 和 [Context7 MCP](https://context7.com/tensorcircuit/tensorcircuit-ng).
|
|
39
|
+
|
|
36
40
|
初学者也可以参考[量子计算教程](https://github.com/sxzgroup/qc_lecture)学习量子计算基础和 TensorCircuit-NG 的典型用法.
|
|
37
41
|
|
|
38
42
|
以下是一些最简易的演示。
|
|
@@ -149,6 +149,297 @@ We support two modes of analog simulation, where :py:meth:`tensorcircuit.experim
|
|
|
149
149
|
v, gs = hybrid_evol(b)
|
|
150
150
|
|
|
151
151
|
|
|
152
|
+
Time Evolution
|
|
153
|
+
------------------
|
|
154
|
+
|
|
155
|
+
TensorCircuit-NG provides several methods for simulating quantum time evolution, including exact diagonalization, Krylov subspace methods, and ODE-based approaches.
|
|
156
|
+
These methods are essential for studying quantum dynamics, particularly in many-body systems, and all support automatic differentiation (AD) and JIT compilation for enhanced performance.
|
|
157
|
+
|
|
158
|
+
**Exact Diagonalization:**
|
|
159
|
+
|
|
160
|
+
For small systems where full diagonalization is feasible, the :py:meth:`tensorcircuit.timeevol.ed_evol` method provides exact time evolution by directly computing matrix exponentials
|
|
161
|
+
(alias :py:meth:`tensorcircuit.timeevol.hamiltonian_evol`):
|
|
162
|
+
|
|
163
|
+
.. code-block:: python
|
|
164
|
+
|
|
165
|
+
import tensorcircuit as tc
|
|
166
|
+
|
|
167
|
+
n = 4
|
|
168
|
+
g = tc.templates.graphs.Line1D(n, pbc=False)
|
|
169
|
+
h = tc.quantum.heisenberg_hamiltonian(g, hzz=1.0, hxx=1.0, hyy=1.0, sparse=False)
|
|
170
|
+
|
|
171
|
+
# Initial Neel state: |↑↓↑↓⟩
|
|
172
|
+
c = tc.Circuit(n)
|
|
173
|
+
c.x([1, 3]) # Apply X gates to qubits 1 and 3
|
|
174
|
+
psi0 = c.state()
|
|
175
|
+
|
|
176
|
+
# Imaginary time evolution times
|
|
177
|
+
times = tc.backend.convert_to_tensor([0.0, 0.5, 1.0, 2.0])
|
|
178
|
+
|
|
179
|
+
# Evolve and get states
|
|
180
|
+
states = tc.timeevol.ed_evol(h, psi0, times)
|
|
181
|
+
print(states)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def evolve_and_measure(params):
|
|
185
|
+
# Parametrized Hamiltonian
|
|
186
|
+
h_param = tc.quantum.heisenberg_hamiltonian(
|
|
187
|
+
g, hzz=params[0], hxx=params[1], hyy=params[2], sparse=False
|
|
188
|
+
)
|
|
189
|
+
states = tc.timeevol.ed_evol(h_param, psi0, times)
|
|
190
|
+
# Measure observable on final state
|
|
191
|
+
circuit = tc.Circuit(n, inputs=states[-1])
|
|
192
|
+
return tc.backend.real(circuit.expectation_ps(z=[0]))
|
|
193
|
+
|
|
194
|
+
evolve_and_measure(tc.backend.ones([3]))
|
|
195
|
+
|
|
196
|
+
This method is particularly efficient for time-independent Hamiltonians as it uses eigendecomposition to compute the evolution.
|
|
197
|
+
It provides exact results but is limited to small systems (typically <16 qubits) due to the exponential growth of the Hilbert space.
|
|
198
|
+
|
|
199
|
+
.. note::
|
|
200
|
+
|
|
201
|
+
For real time evolution, the time should be chosen as ``times = 1.j * tc.backend.convert_to_tensor([0.0, 0.5, 1.0, 2.0])``
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
**Krylov Subspace Methods:**
|
|
205
|
+
|
|
206
|
+
For larger systems where exact diagonalization becomes intractable, the Krylov subspace method provides an efficient approximation.
|
|
207
|
+
The :py:meth:`tensorcircuit.timeevol.krylov_evol` function implements this approach:
|
|
208
|
+
|
|
209
|
+
.. code-block:: python
|
|
210
|
+
|
|
211
|
+
import tensorcircuit as tc
|
|
212
|
+
|
|
213
|
+
# Create a Heisenberg Hamiltonian for a 1D chain
|
|
214
|
+
n = 10
|
|
215
|
+
g = tc.templates.graphs.Line1D(n, pbc=False)
|
|
216
|
+
h = tc.quantum.heisenberg_hamiltonian(g, hzz=1.0, hxx=1.0, hyy=1.0, sparse=True)
|
|
217
|
+
|
|
218
|
+
# Initial domain wall state: |↑↑↑↑↑↓↓↓↓↓⟩
|
|
219
|
+
c = tc.Circuit(n)
|
|
220
|
+
c.x(range(n//2, n))
|
|
221
|
+
psi0 = c.state()
|
|
222
|
+
|
|
223
|
+
# Real time evolution points
|
|
224
|
+
times = tc.backend.convert_to_tensor([0.0, 0.5, 1.0, 2.0])
|
|
225
|
+
|
|
226
|
+
# Perform Krylov evolution with a 30-dimensional subspace
|
|
227
|
+
states = tc.timeevol.krylov_evol(h, psi0, times, subspace_dimension=30)
|
|
228
|
+
|
|
229
|
+
# Krylov method also supports AD and JIT
|
|
230
|
+
|
|
231
|
+
def krylov_evolution(params):
|
|
232
|
+
# Parametrized initial state
|
|
233
|
+
c = tc.Circuit(n)
|
|
234
|
+
for i in range(n):
|
|
235
|
+
c.rx(i, theta=params[i])
|
|
236
|
+
psi0_param = c.state()
|
|
237
|
+
states = tc.timeevol.krylov_evol(h, psi0_param, [1.0], subspace_dimension=20)
|
|
238
|
+
# Measure total magnetization
|
|
239
|
+
circuit = tc.Circuit(n, inputs=states[0])
|
|
240
|
+
mz = sum(circuit.expectation_ps(z=[i]) for i in range(n))
|
|
241
|
+
return tc.backend.real(mz)
|
|
242
|
+
|
|
243
|
+
The Krylov method constructs a small subspace that captures the essential dynamics, making it possible to simulate larger systems efficiently.
|
|
244
|
+
It supports both standard and scan-based jit-friendly implementations:
|
|
245
|
+
|
|
246
|
+
.. code-block:: python
|
|
247
|
+
|
|
248
|
+
# Standard implementation (default)
|
|
249
|
+
states = tc.timeevol.krylov_evol(h, psi0, times, subspace_dimension=20, scan_impl=False)
|
|
250
|
+
|
|
251
|
+
# Scan-based implementation for better JIT performance
|
|
252
|
+
states = tc.timeevol.krylov_evol(h, psi0, times, subspace_dimension=20, scan_impl=True)
|
|
253
|
+
|
|
254
|
+
**ODE-Based Evolution:**
|
|
255
|
+
|
|
256
|
+
For time-dependent Hamiltonians or when fine control over the evolution process is needed, TensorCircuit provides ODE-based evolution methods.
|
|
257
|
+
These methods solve the time-dependent Schrödinger equation directly by integrating the equation :math:`i\frac{d}{dt}|\psi(t)\rangle = H(t)|\psi(t)\rangle`.
|
|
258
|
+
|
|
259
|
+
TensorCircuit provides two ODE-based evolution methods depending on whether the Hamiltonian acts on the entire system or just a local subsystem:
|
|
260
|
+
|
|
261
|
+
1. **Global Evolution** (:py:meth:`tensorcircuit.timeevol.ode_evol_global`): For time-dependent Hamiltonians acting on the entire system. The Hamiltonian should be provided in sparse matrix format for efficiency.
|
|
262
|
+
|
|
263
|
+
.. code-block:: python
|
|
264
|
+
|
|
265
|
+
import tensorcircuit as tc
|
|
266
|
+
from jax import jit, value_and_grad
|
|
267
|
+
|
|
268
|
+
# Set JAX backend for ODE support
|
|
269
|
+
K = tc.set_backend("jax")
|
|
270
|
+
|
|
271
|
+
# H(t) = -∑ᵢ Jᵢ(t) ZᵢZᵢ₊₁ - ∑ᵢ hᵢ(t) Xᵢ
|
|
272
|
+
|
|
273
|
+
# Time-dependent coefficients
|
|
274
|
+
def time_dep_J(t):
|
|
275
|
+
return 1.0 + 0.5 * tc.backend.sin(2.0 * t)
|
|
276
|
+
|
|
277
|
+
def time_dep_h(t):
|
|
278
|
+
return 0.5 * tc.backend.cos(1.5 * t)
|
|
279
|
+
|
|
280
|
+
zz_ham = tc.quantum.PauliStringSum2COO(
|
|
281
|
+
[[3, 3, 0, 0], [0, 3, 3, 0], [0, 0, 3, 3]], [1, 1, 1]
|
|
282
|
+
)
|
|
283
|
+
x_ham = tc.quantum.PauliStringSum2COO(
|
|
284
|
+
[[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]], [1, 1, 1, 1]
|
|
285
|
+
)
|
|
286
|
+
|
|
287
|
+
# Hamiltonian construction function
|
|
288
|
+
def hamiltonian_func(t):
|
|
289
|
+
# Create time-dependent ZZ terms
|
|
290
|
+
zz_coeff = time_dep_J(t)
|
|
291
|
+
|
|
292
|
+
# Create time-dependent X terms
|
|
293
|
+
x_coeff = time_dep_h(t)
|
|
294
|
+
|
|
295
|
+
return zz_coeff * zz_ham + x_coeff * x_ham
|
|
296
|
+
|
|
297
|
+
# Initial state: |↑↓↑↓⟩
|
|
298
|
+
c = tc.Circuit(4)
|
|
299
|
+
c.x([1, 3])
|
|
300
|
+
psi0 = c.state()
|
|
301
|
+
|
|
302
|
+
# Time points for evolution
|
|
303
|
+
times = tc.backend.arange(0, 5, 0.5)
|
|
304
|
+
|
|
305
|
+
# Perform global ODE evolution
|
|
306
|
+
states = tc.timeevol.ode_evol_global(hamiltonian_func, psi0, times)
|
|
307
|
+
assert tc.backend.shape_tuple(states) == (10, 16)
|
|
308
|
+
|
|
309
|
+
zz_ham = tc.quantum.PauliStringSum2COO([[3, 3, 0, 0], [0, 3, 3, 0]], [1, 1])
|
|
310
|
+
x_ham = tc.quantum.PauliStringSum2COO([[1, 0, 0, 0], [0, 1, 0, 0]], [1, 1])
|
|
311
|
+
|
|
312
|
+
# Example with parameterized Hamiltonian and optimization
|
|
313
|
+
def parametrized_hamiltonian(t, params):
|
|
314
|
+
# params = [J0, J1, h0, h1] - parameters to optimize
|
|
315
|
+
J_t = params[0] + params[1] * tc.backend.sin(2.0 * t)
|
|
316
|
+
h_t = params[2] + params[3] * tc.backend.cos(1.5 * t)
|
|
317
|
+
|
|
318
|
+
return J_t * zz_ham + h_t * x_ham
|
|
319
|
+
|
|
320
|
+
# Observable function: measure ZZ correlation
|
|
321
|
+
def zz_correlation(state):
|
|
322
|
+
n = int(np.log2(state.shape[0]))
|
|
323
|
+
circuit = tc.Circuit(n, inputs=state)
|
|
324
|
+
return circuit.expectation_ps(z=[0, 1])
|
|
325
|
+
|
|
326
|
+
@tc.backend.jit
|
|
327
|
+
@tc.backend.value_and_grad
|
|
328
|
+
def objective_function(params):
|
|
329
|
+
states = tc.timeevol.ode_evol_global(
|
|
330
|
+
parametrized_hamiltonian,
|
|
331
|
+
psi0,
|
|
332
|
+
tc.backend.convert_to_tensor([0, 1.0]),
|
|
333
|
+
None,
|
|
334
|
+
params,
|
|
335
|
+
)
|
|
336
|
+
# Measure ZZ correlation at final time
|
|
337
|
+
final_state = states[-1]
|
|
338
|
+
return tc.backend.real(zz_correlation(final_state))
|
|
339
|
+
|
|
340
|
+
print(objective_function(tc.backend.ones([4])))
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
2. **Local Evolution** (:py:meth:`tensorcircuit.timeevol.ode_evol_local`): For time-dependent Hamiltonians acting on a subsystem of qubits. The Hamiltonian should be provided in dense matrix format.
|
|
345
|
+
|
|
346
|
+
.. code-block:: python
|
|
347
|
+
|
|
348
|
+
import tensorcircuit as tc
|
|
349
|
+
import jax.numpy as jnp
|
|
350
|
+
from jax import jit
|
|
351
|
+
|
|
352
|
+
# Set JAX backend for ODE support
|
|
353
|
+
tc.set_backend("jax")
|
|
354
|
+
K = tc.backend
|
|
355
|
+
|
|
356
|
+
# Time-dependent local Hamiltonian on qubits 1 and 2
|
|
357
|
+
# H(t) = Ω(t) * (cos(φ(t)) * X + sin(φ(t)) * Y)
|
|
358
|
+
def local_hamiltonian(t, Omega, phi):
|
|
359
|
+
# Rabi oscillation Hamiltonian
|
|
360
|
+
angle = phi * t
|
|
361
|
+
coeff = Omega * jnp.cos(2.0 * t) # Amplitude modulation
|
|
362
|
+
|
|
363
|
+
# Single-qubit Rabi Hamiltonian (2x2 matrix)
|
|
364
|
+
hx = coeff * jnp.cos(angle) * tc.gates.x().tensor
|
|
365
|
+
hy = coeff * jnp.sin(angle) * tc.gates.y().tensor
|
|
366
|
+
return hx + hy
|
|
367
|
+
|
|
368
|
+
# Initial state: GHZ state |0000⟩ + |1111⟩
|
|
369
|
+
c = tc.Circuit(4)
|
|
370
|
+
c.h(0)
|
|
371
|
+
for i in range(3):
|
|
372
|
+
c.cnot(i, i+1)
|
|
373
|
+
psi0 = c.state()
|
|
374
|
+
|
|
375
|
+
times = tc.backend.arange(0.0, 3.0, 0.1)
|
|
376
|
+
|
|
377
|
+
# Evolve with local Hamiltonian acting on qubit 1
|
|
378
|
+
states = tc.timeevol.ode_evol_local(
|
|
379
|
+
local_hamiltonian,
|
|
380
|
+
psi0,
|
|
381
|
+
times,
|
|
382
|
+
[1], # Apply to qubit 1
|
|
383
|
+
None,
|
|
384
|
+
1.0,
|
|
385
|
+
2.0 # Omega=1.0, phi=2.0
|
|
386
|
+
)
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
Both ODE-based methods support automatic differentiation and JIT compilation when using the JAX backend, making them suitable for optimization tasks in quantum control and variational quantum algorithms.
|
|
390
|
+
The methods integrate the time-dependent Schrödinger equation using JAX's ODE solvers, providing flexible and efficient simulation of quantum dynamics with time-dependent Hamiltonians.
|
|
391
|
+
|
|
392
|
+
.. note::
|
|
393
|
+
|
|
394
|
+
1. ODE-based methods currently only support the JAX backend due to the dependency on JAX's ODE solvers.
|
|
395
|
+
2. Global evolution requires sparse Hamiltonian matrices for efficiency with large systems.
|
|
396
|
+
3. Local evolution requires dense Hamiltonian matrices and is suitable for subsystems with few qubits.
|
|
397
|
+
4. Both methods support callback functions to compute observables during evolution without storing all state vectors.
|
|
398
|
+
|
|
399
|
+
**Comparison of Time Evolution Methods:**
|
|
400
|
+
|
|
401
|
+
+--------------------------+----------------+------------------+------------------+------------------+
|
|
402
|
+
| Method | System Size | Accuracy | AD Support | JIT Support |
|
|
403
|
+
+==========================+================+==================+==================+==================+
|
|
404
|
+
| ED Evolution | < 16 qubits | Exact | ✅ | ✅ |
|
|
405
|
+
+--------------------------+----------------+------------------+------------------+------------------+
|
|
406
|
+
| Krylov Evolution | 16-30+ qubits | Approximate | ✅ | ✅ (JAX only) |
|
|
407
|
+
+--------------------------+----------------+------------------+------------------+------------------+
|
|
408
|
+
| ODE Local Evolution | Any size | Solver-dependent | ✅ (JAX only) | ✅ (JAX only) |
|
|
409
|
+
+--------------------------+----------------+------------------+------------------+------------------+
|
|
410
|
+
| ODE Global Evolution | ~ 20 qubits | Solver-dependent | ✅ (JAX only) | ✅ (JAX only) |
|
|
411
|
+
+--------------------------+----------------+------------------+------------------+------------------+
|
|
412
|
+
|
|
413
|
+
**Method Selection Guidelines:**
|
|
414
|
+
|
|
415
|
+
1. **Exact diagonalization Evolution**: Best for small systems where exact results are required. Most efficient for time-independent Hamiltonians. Support imaginary time evolution.
|
|
416
|
+
|
|
417
|
+
2. **Krylov Evolution**: Ideal for large systems with time-independent Hamiltonians. Provides a good balance between accuracy and computational efficiency. The subspace dimension controls the trade-off between accuracy and speed.
|
|
418
|
+
|
|
419
|
+
3. **ODE Local Evolution**: Suitable for time-dependent Hamiltonians acting on a few qubits. Most flexible for complex control protocols or digital-analog hybrid programs.
|
|
420
|
+
|
|
421
|
+
4. **ODE Global Evolution**: Best for time-dependent Hamiltonians acting on the entire system.
|
|
422
|
+
|
|
423
|
+
**Advanced Usage:**
|
|
424
|
+
|
|
425
|
+
Callback functions can be used to compute observables during evolution without storing all state vectors:
|
|
426
|
+
|
|
427
|
+
.. code-block:: python
|
|
428
|
+
|
|
429
|
+
def compute_total_magnetization(state):
|
|
430
|
+
# Compute total magnetization ⟨∑Zᵢ⟩
|
|
431
|
+
n = int(tc.backend.log2(tc.backend.shape_tuple(state)[0]))
|
|
432
|
+
circuit = tc.Circuit(n, inputs=state)
|
|
433
|
+
total_mz = sum(circuit.expectation_ps(z=[i]) for i in range(n))
|
|
434
|
+
return tc.backend.real(total_mz)
|
|
435
|
+
|
|
436
|
+
# Evolve with callback
|
|
437
|
+
magnetizations = tc.timeevol.krylov_evol(
|
|
438
|
+
h, psi0, times, subspace_dimension=20, callback=compute_total_magnetization
|
|
439
|
+
)
|
|
440
|
+
|
|
441
|
+
All time evolution methods in TensorCircuit support automatic differentiation and JIT compilation, making them suitable for variational optimization and other machine learning applications in quantum physics.
|
|
442
|
+
|
|
152
443
|
|
|
153
444
|
Jitted Function Save/Load
|
|
154
445
|
-----------------------------
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
__version__ = "1.3.0.
|
|
1
|
+
__version__ = "1.3.0.dev20250730"
|
|
2
2
|
__author__ = "TensorCircuit Authors"
|
|
3
3
|
__creator__ = "refraction-ray"
|
|
4
4
|
|
|
@@ -52,6 +52,7 @@ from . import compiler
|
|
|
52
52
|
from . import cloud
|
|
53
53
|
from . import fgs
|
|
54
54
|
from .fgs import FGSSimulator
|
|
55
|
+
from . import timeevol
|
|
55
56
|
|
|
56
57
|
FGSCircuit = FGSSimulator
|
|
57
58
|
|
|
@@ -700,6 +700,9 @@ class ExtendedBackend:
|
|
|
700
700
|
"Backend '{}' has not implemented `is_tensor`.".format(self.name)
|
|
701
701
|
)
|
|
702
702
|
|
|
703
|
+
def matvec(self: Any, A: Tensor, x: Tensor) -> Tensor:
|
|
704
|
+
return self.tensordot(A, x, axes=[[1], [0]])
|
|
705
|
+
|
|
703
706
|
def cast(self: Any, a: Tensor, dtype: str) -> Tensor:
|
|
704
707
|
"""
|
|
705
708
|
Cast the tensor dtype of a ``a``.
|
|
@@ -1386,9 +1389,21 @@ class ExtendedBackend:
|
|
|
1386
1389
|
:rtype: Tensor
|
|
1387
1390
|
"""
|
|
1388
1391
|
carry = init
|
|
1389
|
-
|
|
1390
|
-
|
|
1392
|
+
# Check if `xs` is a PyTree (tuple or list) of arrays.
|
|
1393
|
+
if isinstance(xs, (tuple, list)):
|
|
1394
|
+
for x_slice_tuple in zip(*xs):
|
|
1395
|
+
# x_slice_tuple will be (k_elems[i], j_elems[i]) at each step.
|
|
1396
|
+
carry = f(carry, x_slice_tuple)
|
|
1397
|
+
else:
|
|
1398
|
+
# If xs is a single array, iterate normally.
|
|
1399
|
+
for x in xs:
|
|
1400
|
+
carry = f(carry, x)
|
|
1401
|
+
|
|
1391
1402
|
return carry
|
|
1403
|
+
# carry = init
|
|
1404
|
+
# for x in xs:
|
|
1405
|
+
# carry = f(carry, x)
|
|
1406
|
+
# return carry
|
|
1392
1407
|
|
|
1393
1408
|
def stop_gradient(self: Any, a: Tensor) -> Tensor:
|
|
1394
1409
|
"""
|
|
@@ -200,6 +200,7 @@ class NumpyBackend(numpy_backend.NumPyBackend, ExtendedBackend): # type: ignore
|
|
|
200
200
|
return softmax(a, axis=axis)
|
|
201
201
|
|
|
202
202
|
def onehot(self, a: Tensor, num: int) -> Tensor:
|
|
203
|
+
a = np.asarray(a)
|
|
203
204
|
res = np.eye(num)[a.reshape([-1])]
|
|
204
205
|
return res.reshape(list(a.shape) + [num])
|
|
205
206
|
# https://stackoverflow.com/questions/38592324/one-hot-encoding-using-numpy
|
|
@@ -678,7 +678,14 @@ class TensorFlowBackend(tensorflow_backend.TensorFlowBackend, ExtendedBackend):
|
|
|
678
678
|
sp_a: Tensor,
|
|
679
679
|
b: Tensor,
|
|
680
680
|
) -> Tensor:
|
|
681
|
-
|
|
681
|
+
is_vec = False
|
|
682
|
+
if len(b.shape) == 1:
|
|
683
|
+
b = self.reshape(b, [-1, 1])
|
|
684
|
+
is_vec = True
|
|
685
|
+
r = tf.sparse.sparse_dense_matmul(sp_a, b)
|
|
686
|
+
if is_vec:
|
|
687
|
+
return self.reshape(r, [-1])
|
|
688
|
+
return r
|
|
682
689
|
|
|
683
690
|
def _densify(self) -> Tensor:
|
|
684
691
|
@partial(self.jit, jit_compile=True)
|
|
@@ -712,7 +719,10 @@ class TensorFlowBackend(tensorflow_backend.TensorFlowBackend, ExtendedBackend):
|
|
|
712
719
|
def scan(
|
|
713
720
|
self, f: Callable[[Tensor, Tensor], Tensor], xs: Tensor, init: Tensor
|
|
714
721
|
) -> Tensor:
|
|
715
|
-
|
|
722
|
+
stacked_results = tf.scan(f, xs, init)
|
|
723
|
+
final_state = tf.nest.map_structure(lambda x: x[-1], stacked_results)
|
|
724
|
+
return final_state
|
|
725
|
+
# return tf.scan(f, xs, init)[-1]
|
|
716
726
|
|
|
717
727
|
def device(self, a: Tensor) -> str:
|
|
718
728
|
dev = a.device
|
|
@@ -2,14 +2,20 @@
|
|
|
2
2
|
Experimental features
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
+
# pylint: disable=unused-import
|
|
6
|
+
|
|
5
7
|
from functools import partial
|
|
6
8
|
import logging
|
|
7
9
|
from typing import Any, Callable, Dict, Optional, Tuple, List, Sequence, Union
|
|
8
10
|
|
|
9
11
|
import numpy as np
|
|
10
12
|
|
|
11
|
-
from .cons import backend, dtypestr,
|
|
13
|
+
from .cons import backend, dtypestr, rdtypestr, get_tn_info
|
|
12
14
|
from .gates import Gate
|
|
15
|
+
from .timeevol import hamiltonian_evol, evol_global, evol_local
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# for backward compatibility
|
|
13
19
|
|
|
14
20
|
Tensor = Any
|
|
15
21
|
Circuit = Any
|
|
@@ -435,157 +441,6 @@ def finite_difference_differentiator(
|
|
|
435
441
|
return tf_function # type: ignore
|
|
436
442
|
|
|
437
443
|
|
|
438
|
-
def hamiltonian_evol(
|
|
439
|
-
tlist: Tensor,
|
|
440
|
-
h: Tensor,
|
|
441
|
-
psi0: Tensor,
|
|
442
|
-
callback: Optional[Callable[..., Any]] = None,
|
|
443
|
-
) -> Tensor:
|
|
444
|
-
"""
|
|
445
|
-
Fast implementation of time independent Hamiltonian evolution using eigendecomposition.
|
|
446
|
-
By default, performs imaginary time evolution.
|
|
447
|
-
|
|
448
|
-
:param tlist: Time points for evolution
|
|
449
|
-
:type tlist: Tensor
|
|
450
|
-
:param h: Time-independent Hamiltonian matrix
|
|
451
|
-
:type h: Tensor
|
|
452
|
-
:param psi0: Initial state vector
|
|
453
|
-
:type psi0: Tensor
|
|
454
|
-
:param callback: Optional function to process state at each time point
|
|
455
|
-
:type callback: Optional[Callable[..., Any]], optional
|
|
456
|
-
:return: Evolution results at each time point. If callback is None, returns state vectors;
|
|
457
|
-
otherwise returns callback results
|
|
458
|
-
:rtype: Tensor
|
|
459
|
-
|
|
460
|
-
:Example:
|
|
461
|
-
|
|
462
|
-
>>> import tensorcircuit as tc
|
|
463
|
-
>>> import numpy as np
|
|
464
|
-
>>> # Define a simple 2-qubit Hamiltonian
|
|
465
|
-
>>> h = tc.array_to_tensor([
|
|
466
|
-
... [1.0, 0.0, 0.0, 0.0],
|
|
467
|
-
... [0.0, -1.0, 2.0, 0.0],
|
|
468
|
-
... [0.0, 2.0, -1.0, 0.0],
|
|
469
|
-
... [0.0, 0.0, 0.0, 1.0]
|
|
470
|
-
... ])
|
|
471
|
-
>>> # Initial state |00⟩
|
|
472
|
-
>>> psi0 = tc.array_to_tensor([1.0, 0.0, 0.0, 0.0])
|
|
473
|
-
>>> # Evolution times
|
|
474
|
-
>>> times = tc.array_to_tensor([0.0, 0.5, 1.0])
|
|
475
|
-
>>> # Evolve and get states
|
|
476
|
-
>>> states = tc.experimental.hamiltonian_evol(times, h, psi0)
|
|
477
|
-
>>> print(states.shape) # (3, 4)
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
Note:
|
|
481
|
-
1. The Hamiltonian must be time-independent
|
|
482
|
-
2. For time-dependent Hamiltonians, use ``evol_local`` or ``evol_global`` instead
|
|
483
|
-
3. The evolution is performed in imaginary time by default (factor -t in exponential)
|
|
484
|
-
4. The state is automatically normalized at each time point
|
|
485
|
-
"""
|
|
486
|
-
es, u = backend.eigh(h)
|
|
487
|
-
utpsi0 = backend.reshape(
|
|
488
|
-
backend.transpose(u) @ backend.reshape(psi0, [-1, 1]), [-1]
|
|
489
|
-
)
|
|
490
|
-
|
|
491
|
-
@backend.jit
|
|
492
|
-
def _evol(t: Tensor) -> Tensor:
|
|
493
|
-
ebetah_utpsi0 = backend.exp(-t * es) * utpsi0
|
|
494
|
-
psi_exact = backend.conj(u) @ backend.reshape(ebetah_utpsi0, [-1, 1])
|
|
495
|
-
psi_exact = backend.reshape(psi_exact, [-1])
|
|
496
|
-
psi_exact = psi_exact / backend.norm(psi_exact)
|
|
497
|
-
if callback is None:
|
|
498
|
-
return psi_exact
|
|
499
|
-
return callback(psi_exact)
|
|
500
|
-
|
|
501
|
-
return backend.stack([_evol(t) for t in tlist])
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
def evol_local(
|
|
505
|
-
c: Circuit,
|
|
506
|
-
index: Sequence[int],
|
|
507
|
-
h_fun: Callable[..., Tensor],
|
|
508
|
-
t: float,
|
|
509
|
-
*args: Any,
|
|
510
|
-
**solver_kws: Any,
|
|
511
|
-
) -> Circuit:
|
|
512
|
-
"""
|
|
513
|
-
ode evolution of time dependent Hamiltonian on circuit of given indices
|
|
514
|
-
[only jax backend support for now]
|
|
515
|
-
|
|
516
|
-
:param c: _description_
|
|
517
|
-
:type c: Circuit
|
|
518
|
-
:param index: qubit sites to evolve
|
|
519
|
-
:type index: Sequence[int]
|
|
520
|
-
:param h_fun: h_fun should return a dense Hamiltonian matrix
|
|
521
|
-
with input arguments time and *args
|
|
522
|
-
:type h_fun: Callable[..., Tensor]
|
|
523
|
-
:param t: evolution time
|
|
524
|
-
:type t: float
|
|
525
|
-
:return: _description_
|
|
526
|
-
:rtype: Circuit
|
|
527
|
-
"""
|
|
528
|
-
from jax.experimental.ode import odeint
|
|
529
|
-
|
|
530
|
-
s = c.state()
|
|
531
|
-
n = c._nqubits
|
|
532
|
-
l = len(index)
|
|
533
|
-
|
|
534
|
-
def f(y: Tensor, t: Tensor, *args: Any) -> Tensor:
|
|
535
|
-
y = backend.reshape2(y)
|
|
536
|
-
y = Gate(y)
|
|
537
|
-
h = -1.0j * h_fun(t, *args)
|
|
538
|
-
h = backend.reshape2(h)
|
|
539
|
-
h = Gate(h)
|
|
540
|
-
edges = []
|
|
541
|
-
for i in range(n):
|
|
542
|
-
if i not in index:
|
|
543
|
-
edges.append(y[i])
|
|
544
|
-
else:
|
|
545
|
-
j = index.index(i)
|
|
546
|
-
edges.append(h[j])
|
|
547
|
-
h[j + l] ^ y[i]
|
|
548
|
-
y = contractor([y, h], output_edge_order=edges)
|
|
549
|
-
return backend.reshape(y.tensor, [-1])
|
|
550
|
-
|
|
551
|
-
ts = backend.stack([0.0, t])
|
|
552
|
-
ts = backend.cast(ts, dtype=rdtypestr)
|
|
553
|
-
s1 = odeint(f, s, ts, *args, **solver_kws)
|
|
554
|
-
return type(c)(n, inputs=s1[-1])
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
def evol_global(
|
|
558
|
-
c: Circuit, h_fun: Callable[..., Tensor], t: float, *args: Any, **solver_kws: Any
|
|
559
|
-
) -> Circuit:
|
|
560
|
-
"""
|
|
561
|
-
ode evolution of time dependent Hamiltonian on circuit of all qubits
|
|
562
|
-
[only jax backend support for now]
|
|
563
|
-
|
|
564
|
-
:param c: _description_
|
|
565
|
-
:type c: Circuit
|
|
566
|
-
:param h_fun: h_fun should return a **SPARSE** Hamiltonian matrix
|
|
567
|
-
with input arguments time and *args
|
|
568
|
-
:type h_fun: Callable[..., Tensor]
|
|
569
|
-
:param t: _description_
|
|
570
|
-
:type t: float
|
|
571
|
-
:return: _description_
|
|
572
|
-
:rtype: Circuit
|
|
573
|
-
"""
|
|
574
|
-
from jax.experimental.ode import odeint
|
|
575
|
-
|
|
576
|
-
s = c.state()
|
|
577
|
-
n = c._nqubits
|
|
578
|
-
|
|
579
|
-
def f(y: Tensor, t: Tensor, *args: Any) -> Tensor:
|
|
580
|
-
h = -1.0j * h_fun(t, *args)
|
|
581
|
-
return backend.sparse_dense_matmul(h, y)
|
|
582
|
-
|
|
583
|
-
ts = backend.stack([0.0, t])
|
|
584
|
-
ts = backend.cast(ts, dtype=rdtypestr)
|
|
585
|
-
s1 = odeint(f, s, ts, *args, **solver_kws)
|
|
586
|
-
return type(c)(n, inputs=s1[-1])
|
|
587
|
-
|
|
588
|
-
|
|
589
444
|
def jax_jitted_function_save(filename: str, f: Callable[..., Any], *args: Any) -> None:
|
|
590
445
|
"""
|
|
591
446
|
save a jitted jax function as a file
|