You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Support hyperedges in TensorCircuit using cotengra with optimized execution.
This change introduces compatibility for hyperedges (CopyNodes) when using the cotengra contractor.
It features a new execution engine that avoids instantiating dense CopyNode tensors, preventing OOM errors on large hyperedges.
Key changes:
- `tensorcircuit/cons.py`:
- Updated `_get_path_cache_friendly` to use UnionFind to group edges connected by CopyNodes.
- Implemented a new primitive-based execution path (`_base`) using `einsum` on bare tensors. This handles hyperedges (shared indices) naturally without materializing large CopyNodes.
- Preserved legacy contraction logic as a safe fallback when no hyperedges are present.
- Updated `set_contractor` to accept `use_primitives` for explicit control over the execution engine.
- Added `examples/hyperedge_demo.py` demonstrating the feature with a large-scale (20-leg) example.
- Added `tests/test_hyperedge.py` for verification using pytest fixtures.
Co-authored-by: refraction-ray <35157286+refraction-ray@users.noreply.github.com>
0 commit comments