---
title: "Keeping intermediates within target_size"
description: "Start from an unsliced path and use Fixed or Dynamic slicing to control intermediate tensor sizes."
eyebrow: "Tutorials"
---

First prepare the example network structure, dimensions, and numerical arrays from [Tensor-network input in Quick start](/docs/quick-start#network).

## Fixed-path slicing {#fixed}

Use your own `inputs`, `output`, and `size_dict`, or reuse the network in [Quick start](/docs/quick-start#network). For the summation principle, see [Slicing principles](/docs/slicing#exact-decomposition).

```python
from arctn import arctn_schedule

fixed_report = arctn_schedule(
    inputs, output, size_dict,
    preset="heavy", seed=0,
    target_size=4,
    slicing_mode="fixed",
    use_ssa=True,
)
print(fixed_report["sliced_legs"])
print(fixed_report["sliced_log2_max_size"])
```

For the quick-start network, `target_size=4` actually triggers slicing. `fixed` is the default mode. It first obtains an unsliced path with the selected Light or Heavy preset, then keeps that path fixed and chooses only the sliced indices.

## Alternating slicing and local path reconfiguration {#dynamic}

Run Dynamic on the same network and inspect both returned paths in SSA format:

```python
dynamic_report = arctn_schedule(
    inputs, output, size_dict,
    preset="heavy", seed=0,
    target_size=4,
    slicing_mode="dynamic",
    use_ssa=True,
)
print(dynamic_report["path"] == fixed_report["path"])
print(dynamic_report["sliced_legs"])
print(dynamic_report["sliced_log10_flops_total"])
```

Both `fixed` and `dynamic` first optimize an unsliced path with the selected Light or Heavy preset. `dynamic` permits limited local path changes after slicing. The Boolean above only indicates whether the two calls returned the same final path; it is not a record of changes inside one search. Compare slice count and total work as well as whether the path changed.

## Comparing slicing settings {#tradeoff}

| Change | Direct effect | Also check |
| --- | --- | --- |
| Lower target\_size | Requires per-slice results to satisfy a smaller element limit; the actual maximum may stay unchanged | Slice count and total FLOPs may increase |
| fixed → dynamic | Allows local path changes after slicing | Adds local adjustment work; the final path may or may not change |
| Execute more slices concurrently | May increase throughput | Concurrent slices increase memory usage |

`target_size` constrains only the element count of per-slice binary contraction results; for a single-tensor network, it checks the final output. It does not limit all unary-operation temporaries and is not a cap on total process memory, GPU memory, or temporary workspace.
