symtenet 0.1.0__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.
- symtenet-0.1.0/.github/dependabot.yml +14 -0
- symtenet-0.1.0/.github/workflows/ci.yml +80 -0
- symtenet-0.1.0/.github/workflows/docs.yml +55 -0
- symtenet-0.1.0/.github/workflows/release.yml +42 -0
- symtenet-0.1.0/.gitignore +11 -0
- symtenet-0.1.0/.python-version +1 -0
- symtenet-0.1.0/AGENTS.md +96 -0
- symtenet-0.1.0/CITATION.cff +15 -0
- symtenet-0.1.0/LICENSE +202 -0
- symtenet-0.1.0/PKG-INFO +142 -0
- symtenet-0.1.0/README.md +125 -0
- symtenet-0.1.0/REPOSITORY_RULES.md +84 -0
- symtenet-0.1.0/benchmarks/bench_compile.py +251 -0
- symtenet-0.1.0/benchmarks/bench_ctm_corner_signs.py +68 -0
- symtenet-0.1.0/benchmarks/bench_dmrg_compile.py +217 -0
- symtenet-0.1.0/benchmarks/bench_gpu.py +204 -0
- symtenet-0.1.0/benchmarks/bench_heff2_diagonal.py +225 -0
- symtenet-0.1.0/benchmarks/bench_map_diagonal.py +178 -0
- symtenet-0.1.0/benchmarks/bench_noise.py +166 -0
- symtenet-0.1.0/benchmarks/bench_pinned_mpo.py +441 -0
- symtenet-0.1.0/benchmarks/bench_preplace_mpo.py +716 -0
- symtenet-0.1.0/benchmarks/bench_qc_mpo.py +1036 -0
- symtenet-0.1.0/benchmarks/bench_su2_repartition.py +80 -0
- symtenet-0.1.0/benchmarks/bench_sweep_phases.py +252 -0
- symtenet-0.1.0/benchmarks/bench_sweep_transient.py +396 -0
- symtenet-0.1.0/benchmarks/bench_u1_tensordot.py +179 -0
- symtenet-0.1.0/benchmarks/bench_vs_yastn.py +444 -0
- symtenet-0.1.0/docs/api/ad.md +5 -0
- symtenet-0.1.0/docs/api/linalg.md +6 -0
- symtenet-0.1.0/docs/api/models.md +16 -0
- symtenet-0.1.0/docs/api/network.md +9 -0
- symtenet-0.1.0/docs/api/pytree.md +5 -0
- symtenet-0.1.0/docs/api/serialize.md +5 -0
- symtenet-0.1.0/docs/api/symmetry.md +11 -0
- symtenet-0.1.0/docs/api/tenet.md +5 -0
- symtenet-0.1.0/docs/design.md +7742 -0
- symtenet-0.1.0/docs/examples/heisenberg-walkthrough.md +40 -0
- symtenet-0.1.0/docs/examples/heisenberg.md +57 -0
- symtenet-0.1.0/docs/examples/index.md +41 -0
- symtenet-0.1.0/docs/examples/ising-thermo.md +146 -0
- symtenet-0.1.0/docs/examples/ising2d.md +65 -0
- symtenet-0.1.0/docs/examples/su2-heisenberg.md +53 -0
- symtenet-0.1.0/docs/examples/su3-heisenberg.md +36 -0
- symtenet-0.1.0/docs/examples/toy-ctmrg.md +83 -0
- symtenet-0.1.0/docs/examples/toy-dmrg.md +38 -0
- symtenet-0.1.0/docs/examples/toy-exact.md +35 -0
- symtenet-0.1.0/docs/examples/toy-ising.md +21 -0
- symtenet-0.1.0/docs/examples/toy-lanczos.md +21 -0
- symtenet-0.1.0/docs/examples/toy-model.md +27 -0
- symtenet-0.1.0/docs/examples/toy-mps.md +28 -0
- symtenet-0.1.0/docs/examples/toy-tebd.md +41 -0
- symtenet-0.1.0/docs/examples/toy-vmc-mps.md +53 -0
- symtenet-0.1.0/docs/getting-started.md +250 -0
- symtenet-0.1.0/docs/guide/api-map.md +211 -0
- symtenet-0.1.0/docs/guide/contraction.md +214 -0
- symtenet-0.1.0/docs/guide/dmrg.md +455 -0
- symtenet-0.1.0/docs/guide/hamiltonians.md +343 -0
- symtenet-0.1.0/docs/guide/jax-and-backends.md +156 -0
- symtenet-0.1.0/docs/guide/saving-and-loading.md +96 -0
- symtenet-0.1.0/docs/guide/symmetries-and-providers.md +208 -0
- symtenet-0.1.0/docs/guide/tensors-legs-spaces.md +257 -0
- symtenet-0.1.0/docs/guide/truncation.md +245 -0
- symtenet-0.1.0/docs/index.md +1 -0
- symtenet-0.1.0/docs/javascripts/mathjax.js +19 -0
- symtenet-0.1.0/docs/tutorials/ctmrg.md +373 -0
- symtenet-0.1.0/docs/tutorials/dmrg.md +228 -0
- symtenet-0.1.0/docs/tutorials/fermions.md +209 -0
- symtenet-0.1.0/docs/tutorials/quantum-chemistry.md +250 -0
- symtenet-0.1.0/docs/tutorials/su2.md +201 -0
- symtenet-0.1.0/docs/tutorials/symmetric-tensors.md +388 -0
- symtenet-0.1.0/docs/tutorials/vmc.md +132 -0
- symtenet-0.1.0/examples/bench_dmrg.py +195 -0
- symtenet-0.1.0/examples/heisenberg.py +71 -0
- symtenet-0.1.0/examples/heisenberg_walkthrough.py +367 -0
- symtenet-0.1.0/examples/ising2d.py +130 -0
- symtenet-0.1.0/examples/ising_thermo.py +198 -0
- symtenet-0.1.0/examples/su2_heisenberg.py +72 -0
- symtenet-0.1.0/examples/su3_heisenberg.py +122 -0
- symtenet-0.1.0/examples/toy_codes/README.md +36 -0
- symtenet-0.1.0/examples/toy_codes/ctmrg.py +746 -0
- symtenet-0.1.0/examples/toy_codes/dmrg.py +391 -0
- symtenet-0.1.0/examples/toy_codes/exact.py +87 -0
- symtenet-0.1.0/examples/toy_codes/ising.py +77 -0
- symtenet-0.1.0/examples/toy_codes/lanczos.py +82 -0
- symtenet-0.1.0/examples/toy_codes/model.py +214 -0
- symtenet-0.1.0/examples/toy_codes/mps.py +246 -0
- symtenet-0.1.0/examples/toy_codes/tebd.py +198 -0
- symtenet-0.1.0/examples/toy_codes/vmc_mps.py +242 -0
- symtenet-0.1.0/mkdocs.yml +129 -0
- symtenet-0.1.0/pyproject.toml +97 -0
- symtenet-0.1.0/src/tenet/__init__.py +241 -0
- symtenet-0.1.0/src/tenet/ad.py +252 -0
- symtenet-0.1.0/src/tenet/array/__init__.py +10 -0
- symtenet-0.1.0/src/tenet/array/dispatch.py +158 -0
- symtenet-0.1.0/src/tenet/backend.py +41 -0
- symtenet-0.1.0/src/tenet/cache.py +221 -0
- symtenet-0.1.0/src/tenet/fusion_tree.py +268 -0
- symtenet-0.1.0/src/tenet/leg.py +187 -0
- symtenet-0.1.0/src/tenet/map_view.py +1533 -0
- symtenet-0.1.0/src/tenet/models/__init__.py +82 -0
- symtenet-0.1.0/src/tenet/models/hamiltonians.py +387 -0
- symtenet-0.1.0/src/tenet/models/sites.py +430 -0
- symtenet-0.1.0/src/tenet/network/__init__.py +199 -0
- symtenet-0.1.0/src/tenet/network/common.py +478 -0
- symtenet-0.1.0/src/tenet/network/dmrg.py +842 -0
- symtenet-0.1.0/src/tenet/network/env.py +1131 -0
- symtenet-0.1.0/src/tenet/network/envctm.py +1229 -0
- symtenet-0.1.0/src/tenet/network/evolution.py +969 -0
- symtenet-0.1.0/src/tenet/network/lattice.py +541 -0
- symtenet-0.1.0/src/tenet/network/mps.py +3679 -0
- symtenet-0.1.0/src/tenet/network/peps.py +565 -0
- symtenet-0.1.0/src/tenet/ops/__init__.py +72 -0
- symtenet-0.1.0/src/tenet/ops/basic.py +423 -0
- symtenet-0.1.0/src/tenet/ops/batch.py +174 -0
- symtenet-0.1.0/src/tenet/ops/blocks.py +252 -0
- symtenet-0.1.0/src/tenet/ops/cast.py +156 -0
- symtenet-0.1.0/src/tenet/ops/contraction.py +1328 -0
- symtenet-0.1.0/src/tenet/ops/dense.py +447 -0
- symtenet-0.1.0/src/tenet/ops/embed.py +544 -0
- symtenet-0.1.0/src/tenet/ops/fusion.py +476 -0
- symtenet-0.1.0/src/tenet/ops/linalg.py +1790 -0
- symtenet-0.1.0/src/tenet/ops/map.py +708 -0
- symtenet-0.1.0/src/tenet/ops/permutation.py +579 -0
- symtenet-0.1.0/src/tenet/ops/repartition.py +850 -0
- symtenet-0.1.0/src/tenet/py.typed +0 -0
- symtenet-0.1.0/src/tenet/pytree.py +81 -0
- symtenet-0.1.0/src/tenet/serialize.py +358 -0
- symtenet-0.1.0/src/tenet/space.py +361 -0
- symtenet-0.1.0/src/tenet/structure.py +442 -0
- symtenet-0.1.0/src/tenet/symmetry/__init__.py +100 -0
- symtenet-0.1.0/src/tenet/symmetry/_su2_coeff.py +67 -0
- symtenet-0.1.0/src/tenet/symmetry/_sun_coeff.py +116 -0
- symtenet-0.1.0/src/tenet/symmetry/base.py +1273 -0
- symtenet-0.1.0/src/tenet/symmetry/coherence.py +574 -0
- symtenet-0.1.0/src/tenet/symmetry/fz2.py +252 -0
- symtenet-0.1.0/src/tenet/symmetry/product.py +510 -0
- symtenet-0.1.0/src/tenet/symmetry/su2.py +307 -0
- symtenet-0.1.0/src/tenet/symmetry/sun.py +277 -0
- symtenet-0.1.0/src/tenet/symmetry/u1.py +136 -0
- symtenet-0.1.0/src/tenet/symmetry/z2.py +181 -0
- symtenet-0.1.0/src/tenet/tensor.py +1274 -0
- symtenet-0.1.0/tests/COVERAGE.md +221 -0
- symtenet-0.1.0/tests/array/test_dispatch.py +280 -0
- symtenet-0.1.0/tests/backends/test_ad.py +1074 -0
- symtenet-0.1.0/tests/backends/test_pytree.py +439 -0
- symtenet-0.1.0/tests/backends/test_torch.py +991 -0
- symtenet-0.1.0/tests/conftest.py +14 -0
- symtenet-0.1.0/tests/fixtures/mpskit_heisenberg.json +1 -0
- symtenet-0.1.0/tests/fixtures/mpskit_hubbard.json +1 -0
- symtenet-0.1.0/tests/fixtures/su2_f.txt +109909 -0
- symtenet-0.1.0/tests/fixtures/su2_r.txt +625 -0
- symtenet-0.1.0/tests/fixtures/su3_cg.txt +22865 -0
- symtenet-0.1.0/tests/fixtures/su3_f.txt +24764 -0
- symtenet-0.1.0/tests/fixtures/su3_r.txt +346 -0
- symtenet-0.1.0/tests/helpers.py +360 -0
- symtenet-0.1.0/tests/integration/test_ctmrg.py +517 -0
- symtenet-0.1.0/tests/integration/test_ctmrg_ipeps.py +286 -0
- symtenet-0.1.0/tests/integration/test_dmrg.py +567 -0
- symtenet-0.1.0/tests/integration/test_dmrg_excited.py +202 -0
- symtenet-0.1.0/tests/integration/test_dmrg_noise.py +184 -0
- symtenet-0.1.0/tests/integration/test_dmrg_prepared.py +228 -0
- symtenet-0.1.0/tests/integration/test_quimb.py +367 -0
- symtenet-0.1.0/tests/integration/test_vmc.py +170 -0
- symtenet-0.1.0/tests/models/test_hamiltonians.py +217 -0
- symtenet-0.1.0/tests/models/test_sites.py +464 -0
- symtenet-0.1.0/tests/network/__init__.py +4 -0
- symtenet-0.1.0/tests/network/conftest.py +23 -0
- symtenet-0.1.0/tests/network/test_apply.py +214 -0
- symtenet-0.1.0/tests/network/test_chain_composition.py +121 -0
- symtenet-0.1.0/tests/network/test_deferred.py +408 -0
- symtenet-0.1.0/tests/network/test_density_matrix.py +219 -0
- symtenet-0.1.0/tests/network/test_dmrg.py +436 -0
- symtenet-0.1.0/tests/network/test_entanglement.py +215 -0
- symtenet-0.1.0/tests/network/test_env.py +121 -0
- symtenet-0.1.0/tests/network/test_envctm.py +569 -0
- symtenet-0.1.0/tests/network/test_envctmc4v.py +404 -0
- symtenet-0.1.0/tests/network/test_evolution.py +634 -0
- symtenet-0.1.0/tests/network/test_from_arrays.py +330 -0
- symtenet-0.1.0/tests/network/test_from_entries.py +323 -0
- symtenet-0.1.0/tests/network/test_heff2.py +317 -0
- symtenet-0.1.0/tests/network/test_hubbard.py +192 -0
- symtenet-0.1.0/tests/network/test_hygiene.py +350 -0
- symtenet-0.1.0/tests/network/test_materialize.py +149 -0
- symtenet-0.1.0/tests/network/test_measure.py +266 -0
- symtenet-0.1.0/tests/network/test_mpo.py +1086 -0
- symtenet-0.1.0/tests/network/test_mps.py +475 -0
- symtenet-0.1.0/tests/network/test_peps.py +479 -0
- symtenet-0.1.0/tests/network/test_pinned.py +212 -0
- symtenet-0.1.0/tests/network/test_two_state_env.py +178 -0
- symtenet-0.1.0/tests/ops/test_adjoint.py +236 -0
- symtenet-0.1.0/tests/ops/test_basic.py +368 -0
- symtenet-0.1.0/tests/ops/test_batch.py +414 -0
- symtenet-0.1.0/tests/ops/test_blocks.py +450 -0
- symtenet-0.1.0/tests/ops/test_braid.py +209 -0
- symtenet-0.1.0/tests/ops/test_contraction.py +629 -0
- symtenet-0.1.0/tests/ops/test_contraction_plan.py +414 -0
- symtenet-0.1.0/tests/ops/test_dense.py +621 -0
- symtenet-0.1.0/tests/ops/test_eigh_truncated.py +321 -0
- symtenet-0.1.0/tests/ops/test_einsum.py +416 -0
- symtenet-0.1.0/tests/ops/test_einsum_chain.py +282 -0
- symtenet-0.1.0/tests/ops/test_einsum_multi.py +776 -0
- symtenet-0.1.0/tests/ops/test_embed.py +1325 -0
- symtenet-0.1.0/tests/ops/test_empty_operands.py +212 -0
- symtenet-0.1.0/tests/ops/test_flip_dual.py +389 -0
- symtenet-0.1.0/tests/ops/test_full_trace.py +224 -0
- symtenet-0.1.0/tests/ops/test_fusion.py +507 -0
- symtenet-0.1.0/tests/ops/test_isometry.py +473 -0
- symtenet-0.1.0/tests/ops/test_linalg.py +626 -0
- symtenet-0.1.0/tests/ops/test_linalg_expm_eig.py +633 -0
- symtenet-0.1.0/tests/ops/test_linalg_more.py +623 -0
- symtenet-0.1.0/tests/ops/test_linalg_null.py +477 -0
- symtenet-0.1.0/tests/ops/test_map.py +402 -0
- symtenet-0.1.0/tests/ops/test_map_diagonal.py +310 -0
- symtenet-0.1.0/tests/ops/test_permutation.py +345 -0
- symtenet-0.1.0/tests/ops/test_repartition.py +564 -0
- symtenet-0.1.0/tests/ops/test_repartition_plan.py +231 -0
- symtenet-0.1.0/tests/ops/test_select_bond.py +289 -0
- symtenet-0.1.0/tests/ops/test_source_dedup.py +101 -0
- symtenet-0.1.0/tests/ops/test_svd_truncated.py +614 -0
- symtenet-0.1.0/tests/ops/test_to_symmetry.py +496 -0
- symtenet-0.1.0/tests/ops/test_twist.py +150 -0
- symtenet-0.1.0/tests/symmetry/_fibonacci_fixture.py +141 -0
- symtenet-0.1.0/tests/symmetry/_su3_fixture.py +242 -0
- symtenet-0.1.0/tests/symmetry/test_base.py +163 -0
- symtenet-0.1.0/tests/symmetry/test_capabilities.py +117 -0
- symtenet-0.1.0/tests/symmetry/test_fibonacci.py +118 -0
- symtenet-0.1.0/tests/symmetry/test_flip_scalar.py +83 -0
- symtenet-0.1.0/tests/symmetry/test_fz2.py +533 -0
- symtenet-0.1.0/tests/symmetry/test_product.py +1139 -0
- symtenet-0.1.0/tests/symmetry/test_su2.py +211 -0
- symtenet-0.1.0/tests/symmetry/test_su2_bend.py +627 -0
- symtenet-0.1.0/tests/symmetry/test_su2_braid.py +289 -0
- symtenet-0.1.0/tests/symmetry/test_su2_dual.py +291 -0
- symtenet-0.1.0/tests/symmetry/test_su2_recoupling.py +357 -0
- symtenet-0.1.0/tests/symmetry/test_su3_multiplicity.py +267 -0
- symtenet-0.1.0/tests/symmetry/test_sun.py +437 -0
- symtenet-0.1.0/tests/symmetry/test_u1.py +132 -0
- symtenet-0.1.0/tests/symmetry/test_z2.py +458 -0
- symtenet-0.1.0/tests/test_api_map.py +67 -0
- symtenet-0.1.0/tests/test_cache.py +246 -0
- symtenet-0.1.0/tests/test_coverage.py +237 -0
- symtenet-0.1.0/tests/test_docs.py +67 -0
- symtenet-0.1.0/tests/test_enable_jax.py +149 -0
- symtenet-0.1.0/tests/test_examples.py +451 -0
- symtenet-0.1.0/tests/test_fusion_tree.py +258 -0
- symtenet-0.1.0/tests/test_import.py +60 -0
- symtenet-0.1.0/tests/test_leg.py +81 -0
- symtenet-0.1.0/tests/test_lowering_fusion.py +310 -0
- symtenet-0.1.0/tests/test_map_view.py +606 -0
- symtenet-0.1.0/tests/test_map_view_assembly.py +316 -0
- symtenet-0.1.0/tests/test_readme.py +27 -0
- symtenet-0.1.0/tests/test_serialize.py +396 -0
- symtenet-0.1.0/tests/test_space.py +173 -0
- symtenet-0.1.0/tests/test_structure.py +375 -0
- symtenet-0.1.0/tests/test_tensor.py +300 -0
- symtenet-0.1.0/tests/test_tensor_keyed.py +222 -0
- symtenet-0.1.0/tests/test_tensor_properties.py +291 -0
- symtenet-0.1.0/tools/Manifest.toml +393 -0
- symtenet-0.1.0/tools/Project.toml +6 -0
- symtenet-0.1.0/tools/gen_fr_fixtures.jl +83 -0
- symtenet-0.1.0/tools/oracles/Manifest.toml +601 -0
- symtenet-0.1.0/tools/oracles/Project.toml +6 -0
- symtenet-0.1.0/tools/oracles/heisenberg_mpskit.jl +54 -0
- symtenet-0.1.0/tools/oracles/hubbard_mpskit.jl +53 -0
- symtenet-0.1.0/uv.lock +1502 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Keep the GitHub Actions pins fresh: one grouped PR per month, after a 7-day
|
|
2
|
+
# cooldown on each release. Python deps are deliberately absent -- uv resolves
|
|
3
|
+
# fresh on every CI run, so a dependency bump PR would duplicate that signal.
|
|
4
|
+
version: 2
|
|
5
|
+
updates:
|
|
6
|
+
- package-ecosystem: github-actions
|
|
7
|
+
directory: /
|
|
8
|
+
schedule:
|
|
9
|
+
interval: monthly
|
|
10
|
+
cooldown:
|
|
11
|
+
default-days: 7
|
|
12
|
+
groups:
|
|
13
|
+
actions:
|
|
14
|
+
patterns: ["*"]
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
# A superseded push to the same PR cancels the run it replaced; pushes to main
|
|
9
|
+
# always run to completion so every merge commit keeps its own green check.
|
|
10
|
+
concurrency:
|
|
11
|
+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
|
12
|
+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
test:
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
# `uv run pytest` is the whole job: everything else -- both syncs, the doctests,
|
|
18
|
+
# the torch subset and the docs build -- totals 45 s measured. The suite runs on
|
|
19
|
+
# xdist workers (see `addopts`), which measured 517 s -> 139 s locally; the
|
|
20
|
+
# runner is ~2x slower still, so warm runs land well inside 10 min; 30 is the cap
|
|
21
|
+
# a cold cache and a slow runner still have to fit in.
|
|
22
|
+
timeout-minutes: 30
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@v7
|
|
25
|
+
- uses: astral-sh/setup-uv@v7
|
|
26
|
+
with:
|
|
27
|
+
enable-cache: true
|
|
28
|
+
- run: uv sync
|
|
29
|
+
- run: uv run ruff check .
|
|
30
|
+
- run: uv run ruff format --check .
|
|
31
|
+
# Before pytest so a type error fails in seconds, not minutes. Measured
|
|
32
|
+
# 0.2 s locally on the warm uvx cache (#166); ty is a single static binary
|
|
33
|
+
# resolved by uvx, so no new dependency group. Unpinned deliberately: ty is
|
|
34
|
+
# alpha and its fixes land fast; if an upgrade ever breaks the gate, pin
|
|
35
|
+
# with `uvx ty@<version> check`.
|
|
36
|
+
- run: uvx ty check src/tenet
|
|
37
|
+
- run: uv run pytest
|
|
38
|
+
# The docstring examples plus the Getting started / guide pages and the
|
|
39
|
+
# tutorials whose problems run in seconds (#167). A separate step, not part of
|
|
40
|
+
# the suite: testpaths stays ["tests"]. The md paths are explicit — the remaining tutorial and example
|
|
41
|
+
# pages carry code blocks that are not doctests, so the glob reaches only the
|
|
42
|
+
# ones named here.
|
|
43
|
+
- run: uv run pytest --doctest-modules src/tenet --doctest-glob='*.md' docs/getting-started.md docs/guide docs/tutorials/symmetric-tensors.md docs/tutorials/dmrg.md docs/tutorials/fermions.md docs/tutorials/su2.md
|
|
44
|
+
# Appended to the same job, not a matrix axis: the torch-relevant subset is a
|
|
45
|
+
# few dozen tests and the suite is minutes, so running everything twice
|
|
46
|
+
# buys nothing. The step above is unchanged, so a torch failure can never
|
|
47
|
+
# redden the primary suite. CPU wheels; see [tool.uv.sources] (#95).
|
|
48
|
+
- run: uv sync --extra torch
|
|
49
|
+
- run: uv run pytest tests/backends/test_torch.py
|
|
50
|
+
# Same reasoning: one appended step, not a job. --strict turns every unresolved
|
|
51
|
+
# nav entry and internal link into a failure, which is the whole check (#118).
|
|
52
|
+
# A broken docs build reddens CI; the deploy lives in docs.yml and cannot.
|
|
53
|
+
- run: uv run --group docs mkdocs build --strict
|
|
54
|
+
|
|
55
|
+
# A separate job, not a step in `test` (#145): coverage instrumentation measured
|
|
56
|
+
# +63% on the suite locally, which the primary job should not pay.
|
|
57
|
+
# Non-blocking: a hiccup here never reddens the primary suite, and there is no
|
|
58
|
+
# --cov-fail-under gate — the percentage is published (badge via docs.yml), not
|
|
59
|
+
# enforced.
|
|
60
|
+
coverage:
|
|
61
|
+
runs-on: ubuntu-latest
|
|
62
|
+
continue-on-error: true
|
|
63
|
+
steps:
|
|
64
|
+
- uses: actions/checkout@v7
|
|
65
|
+
- uses: astral-sh/setup-uv@v7
|
|
66
|
+
with:
|
|
67
|
+
enable-cache: true
|
|
68
|
+
- run: uv run pytest -q --cov=src/tenet --cov-report=xml
|
|
69
|
+
# docs.yml downloads this to render the README's coverage badge on Pages.
|
|
70
|
+
- uses: actions/upload-artifact@v7
|
|
71
|
+
with:
|
|
72
|
+
name: coverage-xml
|
|
73
|
+
path: coverage.xml
|
|
74
|
+
# Codecov beside the self-hosted badge: the Pages badge is the
|
|
75
|
+
# dependency-free number; codecov adds per-PR coverage diffs and history.
|
|
76
|
+
# Tokenless upload (public repo); non-fatal like the rest of this job.
|
|
77
|
+
- uses: codecov/codecov-action@v5
|
|
78
|
+
with:
|
|
79
|
+
files: coverage.xml
|
|
80
|
+
fail_ci_if_error: false
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
name: Docs
|
|
2
|
+
|
|
3
|
+
# Deploy only. The build *check* is a step in ci.yml's test job, so a broken docs
|
|
4
|
+
# build reddens a PR; this workflow only ever runs after main already moved (#118).
|
|
5
|
+
on:
|
|
6
|
+
push:
|
|
7
|
+
branches: [main]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
actions: read # download ci.yml's coverage artifact for the badge (#145)
|
|
13
|
+
pages: write
|
|
14
|
+
id-token: write
|
|
15
|
+
|
|
16
|
+
# One live site: let a running deploy finish rather than cancelling it mid-publish.
|
|
17
|
+
concurrency:
|
|
18
|
+
group: pages
|
|
19
|
+
cancel-in-progress: false
|
|
20
|
+
|
|
21
|
+
jobs:
|
|
22
|
+
deploy:
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
environment:
|
|
25
|
+
name: github-pages
|
|
26
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/checkout@v7
|
|
29
|
+
- uses: astral-sh/setup-uv@v7
|
|
30
|
+
with:
|
|
31
|
+
enable-cache: true
|
|
32
|
+
- run: uv run --group docs mkdocs build --strict
|
|
33
|
+
# The coverage badge (#145): rendered from the newest successful CI run on
|
|
34
|
+
# main rather than re-running the suite here — measuring belongs to ci.yml,
|
|
35
|
+
# publishing to Pages belongs here. On the very first deploy (or if CI for
|
|
36
|
+
# this push is still running) the newest artifact can lag one commit or be
|
|
37
|
+
# absent; a missing badge 404s in the README until the next deploy, which
|
|
38
|
+
# is why the step is non-fatal.
|
|
39
|
+
- name: Coverage badge
|
|
40
|
+
env:
|
|
41
|
+
GH_TOKEN: ${{ github.token }}
|
|
42
|
+
run: |
|
|
43
|
+
run_id=$(gh run list --workflow ci.yml --branch main --status success \
|
|
44
|
+
--limit 1 --json databaseId -q '.[0].databaseId')
|
|
45
|
+
if [ -n "$run_id" ] && gh run download "$run_id" -n coverage-xml -D cov; then
|
|
46
|
+
uvx --from 'genbadge[coverage]' genbadge coverage \
|
|
47
|
+
-i cov/coverage.xml -o site/coverage-badge.svg
|
|
48
|
+
else
|
|
49
|
+
echo "no coverage artifact yet; badge deferred to the next deploy"
|
|
50
|
+
fi
|
|
51
|
+
- uses: actions/upload-pages-artifact@v5
|
|
52
|
+
with:
|
|
53
|
+
path: site
|
|
54
|
+
- uses: actions/deploy-pages@v5
|
|
55
|
+
id: deployment
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Trusted publishing (OIDC, no tokens): a v* tag dry-runs the artifact through
|
|
2
|
+
# TestPyPI; publishing a GitHub release ships the same artifact to PyPI. Pure
|
|
3
|
+
# Python, so `uv build` replaces the cibuildwheel matrix C-extension projects need.
|
|
4
|
+
name: Release
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
tags: ["v*"]
|
|
9
|
+
release:
|
|
10
|
+
types: [published]
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
timeout-minutes: 10
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v7
|
|
18
|
+
- uses: astral-sh/setup-uv@v7
|
|
19
|
+
- run: uv build
|
|
20
|
+
- run: uvx twine check --strict dist/*
|
|
21
|
+
- uses: actions/upload-artifact@v7
|
|
22
|
+
with:
|
|
23
|
+
name: dist
|
|
24
|
+
path: dist
|
|
25
|
+
publish:
|
|
26
|
+
needs: build
|
|
27
|
+
runs-on: ubuntu-latest
|
|
28
|
+
timeout-minutes: 10
|
|
29
|
+
environment: pypi
|
|
30
|
+
permissions:
|
|
31
|
+
id-token: write
|
|
32
|
+
steps:
|
|
33
|
+
- uses: actions/download-artifact@v8
|
|
34
|
+
with:
|
|
35
|
+
name: dist
|
|
36
|
+
path: dist
|
|
37
|
+
- if: github.event_name == 'push'
|
|
38
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
39
|
+
with:
|
|
40
|
+
repository-url: https://test.pypi.org/legacy/
|
|
41
|
+
- if: github.event_name == 'release'
|
|
42
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.12
|
symtenet-0.1.0/AGENTS.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
Guide for coding agents (and humans) working in this repository.
|
|
4
|
+
|
|
5
|
+
## What this project is
|
|
6
|
+
|
|
7
|
+
`symtenet`: non-Abelian symmetric tensors with ndarray-style Python APIs and
|
|
8
|
+
backend-native numerical execution. **`docs/design.md` is the design document.**
|
|
9
|
+
Read the relevant section of it before implementing anything; it defines the
|
|
10
|
+
architecture, milestones, and invariants. `REPOSITORY_RULES.md` defines
|
|
11
|
+
process rules.
|
|
12
|
+
|
|
13
|
+
Three-layer architecture (never blur these):
|
|
14
|
+
|
|
15
|
+
```text
|
|
16
|
+
mathematical model TensorMap semantics (Hom(D,C), duality, fusion, F/R)
|
|
17
|
+
programming model SymmetricTensor (ordered ndarray-like legs)
|
|
18
|
+
execution model backend-native reduced arrays (NumPy / JAX / PyTorch via autoray)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Commands
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
uv sync # install (creates .venv, includes dev deps)
|
|
25
|
+
uv run pytest # run tests
|
|
26
|
+
uv run ruff check . # lint
|
|
27
|
+
uv run ruff format . # format
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
CI runs exactly: `ruff check`, `ruff format --check`, `pytest`. All must pass.
|
|
31
|
+
|
|
32
|
+
## Layout
|
|
33
|
+
|
|
34
|
+
```text
|
|
35
|
+
src/tenet/ library code (src layout; see "Proposed package structure" in docs/design.md)
|
|
36
|
+
tests/ pytest tests, mirroring src/tenet/ structure
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Design invariants (condensed from docs/design.md — full list there is authoritative)
|
|
40
|
+
|
|
41
|
+
1. Every `SymmetricTensor` has exact TensorMap semantics: `domain`/`codomain`
|
|
42
|
+
derived from leg metadata.
|
|
43
|
+
2. `side` (IN/OUT) and `dual` are independent. Never identify input with dual.
|
|
44
|
+
3. Public axis order is independent of domain/codomain grouping.
|
|
45
|
+
4. Fusion trees / intermediate sectors / multiplicities are tensor-level
|
|
46
|
+
structure, never stored on individual `Leg`s.
|
|
47
|
+
5. Categorical operations are never *defined* by backend array operations;
|
|
48
|
+
backend ops only implement lowered plans.
|
|
49
|
+
6. Reduced blocks contain only degeneracy indices; sector labels are metadata.
|
|
50
|
+
7. Reduced block axis order follows public tensor axis order, not
|
|
51
|
+
codomain × domain.
|
|
52
|
+
8. Numerical leaves are backend-native arrays: the tensor holds
|
|
53
|
+
`data: tuple[Array, ...]`, one dense matrix per coupled sector, and
|
|
54
|
+
`blocks: tuple[Array, ...]` ordered by `structure.block_order` is the public
|
|
55
|
+
view of it. Every operation reads `data`; `blocks` is for interop and for
|
|
56
|
+
reading a tensor apart, and reading it cuts every block out of the matrices.
|
|
57
|
+
`TensorStructure` is immutable, hashable, and array-free — F/R and other coefficient arrays never go in
|
|
58
|
+
structural fields. Do not subclass `numpy.ndarray` / `jax.Array` /
|
|
59
|
+
`torch.Tensor`.
|
|
60
|
+
9. No implicit densification. Dense expansion only via explicit `to_dense()`.
|
|
61
|
+
10. Structural planning (categorical analysis) is separated from numerical
|
|
62
|
+
execution; plans are static and cacheable. Structural logic runs in
|
|
63
|
+
Python on static metadata (so JAX tracing / torch AD see only array
|
|
64
|
+
ops); structure-changing operations (truncation, sector selection) live
|
|
65
|
+
outside JIT/compile boundaries or use static shapes/masks.
|
|
66
|
+
11. Expose an ndarray-style operation only when its categorical meaning is
|
|
67
|
+
defined; unsupported operations fail loudly.
|
|
68
|
+
12. Never invent an implicit braid convention. If an expression does not
|
|
69
|
+
uniquely specify a braid, require explicit input.
|
|
70
|
+
|
|
71
|
+
## Coding rules
|
|
72
|
+
|
|
73
|
+
- Symmetry-specific math goes through capability protocols — `FusionRules` for
|
|
74
|
+
structure, the `*Data` protocols (`FMatrixData`, `BendingCoefficients`, ...)
|
|
75
|
+
for the coefficients a category is defined by, `*Provider` for a concrete
|
|
76
|
+
symmetry. No `if symmetry == "su2":` branching in core code.
|
|
77
|
+
- Test non-Abelian behavior with SU(2) from the start; Abelian-only tests can
|
|
78
|
+
hide wrong assumptions (external sectors ≠ complete fusion basis).
|
|
79
|
+
- Where feasible, validate numerical operations against explicit dense
|
|
80
|
+
expansion in tests.
|
|
81
|
+
- A PR that adds a symmetry provider or a public operation updates
|
|
82
|
+
`tests/COVERAGE.md` in the same diff: a provider names its column and the
|
|
83
|
+
cells it fills; an operation names its row and the providers and modes it
|
|
84
|
+
runs under. Any cell left empty carries one of the four classifications —
|
|
85
|
+
genuine gap (with a follow-up), structurally redundant (with the argument),
|
|
86
|
+
out of contract (with the refusal test), or blocked (with what blocks it) —
|
|
87
|
+
in one line.
|
|
88
|
+
- Structural/categorical types are immutable (frozen dataclasses or similar).
|
|
89
|
+
- Backend abstraction is `autoray` only; keep it thin, don't build a second
|
|
90
|
+
numerical framework. Framework-specific optimization (`jit`, `grad`,
|
|
91
|
+
`torch.compile`) is application-level (symmray/quimb model).
|
|
92
|
+
- Integration surface: `get_params`/`set_params` (quimb-compatible) is core;
|
|
93
|
+
JAX PyTree registration is opt-in via `tenet.pytree` (import-guarded, core
|
|
94
|
+
never imports jax/torch).
|
|
95
|
+
- Follow the milestone order in docs/design.md ("Initial implementation strategy")
|
|
96
|
+
unless told otherwise.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: "If you use symtenet in your research, please cite it as below."
|
|
3
|
+
title: "symtenet: a Python library for symmetric tensor networks — a NumPy-style API on the surface, category theory under the hood"
|
|
4
|
+
type: software
|
|
5
|
+
authors:
|
|
6
|
+
- family-names: "Watanabe"
|
|
7
|
+
given-names: "Ryo"
|
|
8
|
+
repository-code: "https://github.com/Ryo-wtnb11/symtenet"
|
|
9
|
+
url: "https://ryo-wtnb11.github.io/symtenet/"
|
|
10
|
+
license: Apache-2.0
|
|
11
|
+
abstract: >-
|
|
12
|
+
A symmetric tensor Python library for tensor networks with Abelian,
|
|
13
|
+
fermionic and non-Abelian symmetries: graded tensors over U(1), Z2,
|
|
14
|
+
fermionic Z2, SU(2) and SU(N), differentiable through JAX, with
|
|
15
|
+
automatic MPO construction, DMRG and CTMRG.
|
symtenet-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Ryo Watanabe
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
symtenet-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: symtenet
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Non-Abelian symmetric tensors with ndarray-style Python APIs and backend-native numerical execution
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Requires-Python: >=3.12
|
|
8
|
+
Requires-Dist: autoray>=0.10.1
|
|
9
|
+
Requires-Dist: numpy>=2.0
|
|
10
|
+
Requires-Dist: opt-einsum>=3.4.0
|
|
11
|
+
Requires-Dist: racah-py>=0.1.2
|
|
12
|
+
Provides-Extra: jax
|
|
13
|
+
Requires-Dist: jax>=0.10; extra == 'jax'
|
|
14
|
+
Provides-Extra: torch
|
|
15
|
+
Requires-Dist: torch>=2.0; extra == 'torch'
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
|
|
18
|
+
# symtenet
|
|
19
|
+
|
|
20
|
+
[](https://github.com/Ryo-wtnb11/symtenet/actions/workflows/ci.yml)
|
|
21
|
+
[](https://github.com/Ryo-wtnb11/symtenet/actions/workflows/ci.yml)
|
|
22
|
+
[](https://codecov.io/gh/Ryo-wtnb11/symtenet)
|
|
23
|
+
[](https://ryo-wtnb11.github.io/symtenet/)
|
|
24
|
+
[](https://github.com/Ryo-wtnb11/symtenet/blob/main/LICENSE)
|
|
25
|
+
[](https://github.com/Ryo-wtnb11/symtenet/blob/main/pyproject.toml)
|
|
26
|
+
|
|
27
|
+
**A Python library for symmetric tensor networks: NumPy-ish API on the surface, category theory under the hood.**
|
|
28
|
+
|
|
29
|
+
`tenet` gives you block-sparse tensors that carry a symmetry exactly — SU(N), SU(2),
|
|
30
|
+
U(1), Z2, fermion parity and their products — through exact recoupling coefficients.
|
|
31
|
+
A tensor carries legs, contracts with `tenet.einsum` and factorizes with `tenet.linalg`,
|
|
32
|
+
the way an ndarray does. Blocks live in NumPy, JAX or PyTorch arrays through
|
|
33
|
+
[`autoray`](https://github.com/jcmgray/autoray), so the same tensor runs under
|
|
34
|
+
`jax.jit` and `jax.grad` with its symmetry structure intact. On top of the tensor layer,
|
|
35
|
+
`tenet.network` ships finite DMRG and CTMRG.
|
|
36
|
+
|
|
37
|
+
## Install
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
uv add symtenet # or: pip install symtenet
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The core install pulls `numpy`, `autoray`, `opt-einsum` and `racah-py`, and every
|
|
44
|
+
symmetry works on it. Two optional extras:
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
uv add "symtenet[jax]" # jax>=0.10 — pytrees, jit, grad
|
|
48
|
+
uv add "symtenet[torch]" # torch>=2.0 — eager blocks
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Quickstart
|
|
52
|
+
|
|
53
|
+
A 20-site spin-1/2 Heisenberg chain, U(1)-graded by `2 S^z`, to its ground state:
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from tenet.models import spin_half
|
|
57
|
+
from tenet.network import MPO, MPS, dmrg_
|
|
58
|
+
from tenet.symmetry import U1Sector
|
|
59
|
+
|
|
60
|
+
site, n = spin_half(), 20
|
|
61
|
+
terms = []
|
|
62
|
+
for i in range(n - 1):
|
|
63
|
+
terms.append((1.0, [(site.ops["Sz"], i), (site.ops["Sz"], i + 1)]))
|
|
64
|
+
terms.append((0.5, [(site.ops["S+"], i), (site.ops["S-"], i + 1)]))
|
|
65
|
+
terms.append((0.5, [(site.ops["S-"], i), (site.ops["S+"], i + 1)]))
|
|
66
|
+
|
|
67
|
+
h = MPO.from_terms(n, terms)
|
|
68
|
+
psi = MPS.product(site.phys, [U1Sector(1 if i % 2 else -1) for i in range(n)])
|
|
69
|
+
out = dmrg_(psi, h, chi=64)
|
|
70
|
+
|
|
71
|
+
print(out.sweeps, out.energy) # 6 -8.682473334398...
|
|
72
|
+
print(out.psi.entanglement_entropy()) # {bond: S}, in nats
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The Néel product state's own charges put the run in the `S^z_tot = 0` sector, and the
|
|
76
|
+
site tensors' invariance keeps it there — no projector, no penalty term.
|
|
77
|
+
[Getting started](https://ryo-wtnb11.github.io/symtenet/getting-started/) reads this
|
|
78
|
+
example line by line.
|
|
79
|
+
|
|
80
|
+
With the `jax` extra, the same tensors are JAX pytrees: `jit`, `grad` and `vmap` reach
|
|
81
|
+
through to the blocks while the symmetry structure stays static.
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
import jax
|
|
85
|
+
import tenet
|
|
86
|
+
|
|
87
|
+
tenet.enable_jax()
|
|
88
|
+
|
|
89
|
+
t = out.psi[0].to_backend("jax")
|
|
90
|
+
g = jax.jit(jax.grad(lambda x: tenet.norm(x) ** 2))(t)
|
|
91
|
+
assert g.legs == t.legs
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## What it supports
|
|
95
|
+
|
|
96
|
+
- **Symmetries.** SU(N), SU(2), U(1), Z2, fermion parity (`fZ2`) and Deligne products
|
|
97
|
+
of any of them. Non-Abelian sectors are multiplets with exact Clebsch-Gordan,
|
|
98
|
+
F- and R-symbols; fermionic wires carry their Koszul signs.
|
|
99
|
+
- **Tensors.** `SymmetricTensor` over a flat tuple of `Leg`s, one reduced block per
|
|
100
|
+
allowed fusion channel. `einsum`, `tensordot`, `compose`, `transpose`, `fuse`,
|
|
101
|
+
`repartition`, `trace`, and `tenet.linalg`'s `svd`, `qr`, `lq`, `eigh`, `eig`,
|
|
102
|
+
`polar`, `expm`, `left_null`, plus the truncating `svd_truncated` / `eigh_truncated`.
|
|
103
|
+
- **Algorithms.** Finite two-site DMRG (`dmrg_`, schedules, noise, excited states) with
|
|
104
|
+
MPS/MPO containers, environment caches and measurement; CTMRG on the directional
|
|
105
|
+
`EnvCTM` and its C4v specialization `EnvCTMc4v`, with a differentiable fixed-bond move.
|
|
106
|
+
- **Backends.** NumPy, JAX and PyTorch blocks through `autoray`. `tenet.enable_jax()`
|
|
107
|
+
registers `SymmetricTensor` as a JAX pytree, so `jit`, `grad` and `vmap` reach the
|
|
108
|
+
blocks while the structure stays static metadata.
|
|
109
|
+
|
|
110
|
+
## Docs
|
|
111
|
+
|
|
112
|
+
- [Getting started](https://ryo-wtnb11.github.io/symtenet/getting-started/) — install and the first example.
|
|
113
|
+
- [User guide](https://ryo-wtnb11.github.io/symtenet/guide/tensors-legs-spaces/) — tensors, symmetries, contraction, Hamiltonians, DMRG, truncation, JAX, files.
|
|
114
|
+
- [Tutorials](https://ryo-wtnb11.github.io/symtenet/tutorials/dmrg/) — DMRG, fermions, SU(2), quantum chemistry, CTMRG, VMC.
|
|
115
|
+
- [Examples](https://ryo-wtnb11.github.io/symtenet/examples/) — runnable files with their committed output.
|
|
116
|
+
- [API reference](https://ryo-wtnb11.github.io/symtenet/api/tenet/) — every public name.
|
|
117
|
+
- [`docs/design.md`](https://ryo-wtnb11.github.io/symtenet/design/) — the categorical model underneath.
|
|
118
|
+
- [`REPOSITORY_RULES.md`](https://github.com/Ryo-wtnb11/symtenet/blob/main/REPOSITORY_RULES.md) — process rules for contributing.
|
|
119
|
+
|
|
120
|
+
## Citation
|
|
121
|
+
|
|
122
|
+
If you use symtenet in your research, please cite it:
|
|
123
|
+
|
|
124
|
+
```bibtex
|
|
125
|
+
@software{symtenet,
|
|
126
|
+
author = {Watanabe, Ryo},
|
|
127
|
+
title = {{symtenet}: a {Python} library for symmetric tensor networks
|
|
128
|
+
--- a {NumPy}-style {API} on the surface, category theory under
|
|
129
|
+
the hood},
|
|
130
|
+
url = {https://github.com/Ryo-wtnb11/symtenet},
|
|
131
|
+
license = {Apache-2.0},
|
|
132
|
+
year = {2026}
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
The same metadata lives in
|
|
137
|
+
[`CITATION.cff`](https://github.com/Ryo-wtnb11/symtenet/blob/main/CITATION.cff) —
|
|
138
|
+
GitHub's "Cite this repository" button renders it as BibTeX or APA.
|
|
139
|
+
|
|
140
|
+
## License
|
|
141
|
+
|
|
142
|
+
Apache License 2.0 — see [`LICENSE`](https://github.com/Ryo-wtnb11/symtenet/blob/main/LICENSE).
|