Commit fa7f09e
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>1 parent b1ffff1 commit fa7f09e
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
622 | 622 | | |
623 | 623 | | |
624 | 624 | | |
625 | | - | |
| 625 | + | |
626 | 626 | | |
627 | 627 | | |
628 | 628 | | |
| |||
0 commit comments