---
title: "Third-party integrations"
description: "Use the ArcTN Python interface to optimize contraction paths and pass paths or trees to existing tensor-network tools."
eyebrow: "API reference"
---

## Using an opt_einsum PathOptimizer {#optimizer}

Reuse the three arrays from the [quick start](/docs/quick-start#network). The expression `"ab,bc,cd->ad"` connects the three inputs by their indices and retains `a` and `d` in the result. Commas separate inputs, and the right-hand side of `->` specifies output axes:

```python
import opt_einsum as oe
from arctn import ArcTNOptimizer

equation = "ab,bc,cd->ad"
optimizer = ArcTNOptimizer(
    preset="heavy", seed=0, max_time=30,
    flops_weight=1, read_write_weight=64,
)
result = oe.contract(equation, *arrays, optimize=optimizer)
```

opt\_einsum calls `ArcTNOptimizer.__call__` directly. The `PathOptimizer` interface returns only a path, not slicing indices. A non-`None` `memory_limit`, or a `target_size` configured in `ArcTNOptimizer`, makes this call raise `NotImplementedError`. For slicing, use `ArcTNOptimizer.search()` through Cotengra/Quimb to obtain a tree, or call `arctn_tree` / `arctn_contract` directly.

## Returning a Cotengra ContractionTree {#tree}

Reuse `inputs`, `output`, `size_dict`, and `arrays` from the quick start. Generate a tree and execute it directly:

```python
from arctn import arctn_tree

tree, info = arctn_tree(
    inputs, output, size_dict,
    preset="heavy", seed=0,
    target_size=2**24, slicing_mode="fixed",
    return_info=True,
)
result = tree.contract(arrays)
```

With `return_info=True`, the result is `(tree, info)`, where `info` is a dictionary of path metrics and slicing information. If `arctn_plan` has already produced a `plan`, convert it directly instead of searching again with `arctn_tree`:

```python
tree = plan.to_tree()
result = tree.contract(arrays)
```

`ArcTNOptimizer.search()` and `arctn_tree()` run path optimization. `plan.to_tree()` reuses the existing path and slicing indices without searching again. All of these interfaces can produce a Cotengra `ContractionTree` representing the path and slicing information.

## Using Quimb {#quimb}

Quimb obtains a contraction tree through `ArcTNOptimizer.search()`. Pass the optimizer to `optimize` to use ArcTN for circuit tasks or tensor-network contractions.

- [Using ArcTN in Quimb](/docs/tutorial-quimb) — Compute amplitudes, set slicing limits, and construct tensor networks.

## Explicit array-backend selection {#backend}

With `arctn_contract`, choose `native` or an explicit array backend. When executing through Quimb or a Cotengra tree, use the execution interface of the corresponding library.

- [Execution backends](/docs/execution-backends) — Supported backends, array types, and timing.

## Related pages {#related}

- [Python API](/docs/python-api)
- [Saving paths and slicing information](/docs/execution-plan)
- [Execution backends](/docs/execution-backends)
- [Sliced execution and reduction](/docs/slicing-execution)
