Cotengra

Latest version: v0.6.0

Safety actively analyzes 623075 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 3

0.6.0

**Bug fixes**

- all input node legs and pre-processing steps are now calculated lazily, allowing slicing of indices including those 'simplified' away 31.
- make [`tree.peak_size`](https://cotengra.readthedocs.io/en/latest/autoapi/cotengra/index.html#cotengra.ContractionTree.peak_size) more accurate, by taking max assuming left, right and parent present at the same time.

**Enhancements**

- add simulated annealing tree refinement (in [`path_simulated_annealing.py`](https://cotengra.readthedocs.io/en/latest/autoapi/cotengra/pathfinders/path_simulated_annealing/index.html)), based on "Multi-Tensor Contraction for XEB Verification of Quantum Circuits" by Gleb Kalachev, Pavel Panteleev, Man-Hong Yung (arXiv:2108.05665), and the "treesa" implementation in OMEinsumContractionOrders.jl by Jin-Guo Liu and Pan Zhang. This can be accessed most easily by supplying `opt = HyperOptimizer(simulated_annealing_opts={})`.
- add [`ContractionTree.plot_flat`](https://cotengra.readthedocs.io/en/latest/autoapi/cotengra/plot/index.html#cotengra.plot.plot_tree_flat): a new method for plotting the contraction tree as a flat diagram showing all indices on
every intermediate (without requiring any graph layouts), which is useful for visualizing and understanding small contractions.
![image](https://github.com/jcmgray/cotengra/assets/8982598/32e82937-ab4f-4e0e-91fd-93d389489e29)
- [`HyperGraph.plot`](https://cotengra.readthedocs.io/en/latest/autoapi/cotengra/plot/index.html#cotengra.plot.plot_hypergraph): support showing hyper outer indices, multi-edges, and automatic unique coloring of nodes and indices (to match `plot_flat`).
- add [`ContractionTree.plot_circuit](https://cotengra.readthedocs.io/en/latest/autoapi/cotengra/plot/index.html#cotengra.plot.plot_tree_circuit) for plotting the contraction tree as a circuit diagram, which is fast and useful for visualizing the traversal ordering for larger trees.
![image](https://github.com/jcmgray/cotengra/assets/8982598/300b56c0-9537-49fd-a15c-09611d9e78fa)
- add [`ContractionTree.restore_ind`](https://cotengra.readthedocs.io/en/latest/autoapi/cotengra/index.html#cotengra.ContractionTree.restore_ind) for 'unslicing' or 'unprojecting' previously removed indices.
- [`ContractionTree.from_path`](https://cotengra.readthedocs.io/en/latest/autoapi/cotengra/index.html#cotengra.ContractionTree.from_path): add option `complete` to automatically complete the tree given an incomplete path (usually disconnected subgraphs - 29).
- add [`ContractionTree.get_incomplete_nodes`](https://cotengra.readthedocs.io/en/latest/autoapi/cotengra/index.html#cotengra.ContractionTree.get_incomplete_nodes) for finding all uncontracted childless-parentless node groups.
- add [`ContractionTree.autocomplete`](https://cotengra.readthedocs.io/en/latest/autoapi/cotengra/index.html#cotengra.ContractionTree.autocomplete) for automatically completing a contraction tree, using above method.
- [`tree.plot_flat`](cotengra.plot.plot_tree_flat): show any preprocessing steps and optionally list sliced indices
- add [get_rng](cotengra.utils.get_rng) as a single entry point for getting or propagating a random number generator, to help determinism.
- set ``autojit="auto"`` for contractions, which by default turns on jit for `backend="jax"` only.
- add [`tree.describe`](https://cotengra.readthedocs.io/en/latest/autoapi/cotengra/index.html#cotengra.ContractionTree.describe) for a various levels of information about a tree, e.g. `tree.describe("full")` and `tree.describe("concise")`.
- add [ctg.GreedyOptimizer](https://cotengra.readthedocs.io/en/latest/autoapi/cotengra/pathfinders/path_basic/index.html#cotengra.pathfinders.path_basic.GreedyOptimizer) and [ctg.OptimalOptimizer](https://cotengra.readthedocs.io/en/latest/autoapi/cotengra/pathfinders/path_basic/index.html#cotengra.pathfinders.path_basic.OptimalOptimizer) to the top namespace.
- add [ContractionTree.benchmark](https://cotengra.readthedocs.io/en/latest/autoapi/cotengra/index.html#cotengra.ContractionTree.benchmark) for for automatically assessing hardware performance vs theoretical cost.
- contraction trees now have a `get_default_objective` method to return the objective function they were optimized with, for simpler further refinement or scoring, where it is now picked up automatically.
- change the default 'sub' optimizer on divisive partition building algorithms to be `'greedy'` rather than `'auto'`. This might make individual trials slightly worse but makes each cheaper, see discussion: 27.

**Full Changelog**: https://github.com/jcmgray/cotengra/compare/v0.5.6...v0.6.0

0.5.6

**Bug fixes**

- fix a very rare but very infuriating bug related somehow to [ReusableHyperOptimizer](https://cotengra.readthedocs.io/en/latest/autoapi/cotengra/index.html#cotengra.ReusableHyperOptimizer) not being thread-safe and returning the wrong tree, especially on github actions

**Full Changelog**: https://github.com/jcmgray/cotengra/compare/v0.5.5...v0.5.6

0.5.5

**Enhancements**

- [`HyperOptimizer`](https://cotengra.readthedocs.io/en/latest/autoapi/cotengra/hyperoptimizers/hyper/index.html#cotengra.hyperoptimizers.hyper.HyperOptimizer): by default simply warn if an individual trial fails, rather than raising an exception. This is to ensure rare failures do not spoil an entire optimization run. The behavior can be controlled with the `on_trial_error` argument.

**Bug fixes**

- fixed bug in greedy optimizer that produced negative scores and otherwise inaccurate scores.
- fixed bug for contraction with many inputs and also preprocessing steps

**Full Changelog**: https://github.com/jcmgray/cotengra/compare/v0.5.4...v0.5.5

0.5.4

**Bug fixes**
- the `auto` and `auto-hq` optimizers are now safe to run under multi-threading.

0.5.3

**Features**
- [``einsum``](cotengra.einsum), [`einsum_tree`](cotengra.einsum_tree) and [`einsum_expression`](cotengra.einsum_expression): add support for all numpy input formats, including interleaved indices and ellipses.

**Bug fixes**
- remove some hidden `opt_einsum` dependence (via a `PathOptimizer` method)

**Full Changelog**: https://github.com/jcmgray/cotengra/compare/v0.5.2...v0.5.3

0.5.2

- add [`array_contract_path`](https://cotengra.readthedocs.io/en/latest/autoapi/cotengra/index.html#cotengra.array_contract_path)
- support for checking size and flops of 'tree' of size 1.

**Full Changelog**: https://github.com/jcmgray/cotengra/compare/v0.5.1...v0.5.2

Page 1 of 3

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.