> For the complete documentation index, see [llms.txt](https://docs.telys.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.telys.ai/tuning/apply-and-save.md).

# Apply & save

Applying a plan and persisting it are two steps. `col.apply_tuning(plan)` writes the plan's settings onto the **live** collection; `col.save()` makes them **durable** on disk. A plan is only a description — there is no `TuningPlan.save`.

## Before you start

* You have a `TuningPlan` from [running a pass](/tuning/running-a-pass.md) (`plan = col.tune(dry_run=True)`).
* The signed runtime is installed and verified.

## What each call does

| Call                     | Signature                    | Effect                                                                                                                                                                                               |
| ------------------------ | ---------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `col.apply_tuning(plan)` | `apply_tuning(plan) -> dict` | Sets `default_target_recall` and the exact-search crossover, builds or reuses the per-partition IVF, sets nprobe, and **returns the collection's `stats()`**.                                        |
| `col.save()`             | `save() -> str`              | Commits the collection to disk and returns its directory. Persists `default_target_recall` and `applied_tuner` (alongside name, dim, dtype, key name, filter columns, id map, and embedder profile). |

{% hint style="info" %}
`apply_tuning` changes the in-memory collection immediately, but nothing is durable until `save()` writes `collection.json`. Exit without saving and the applied tuning is lost.
{% endhint %}

## Apply, then save

{% stepper %}
{% step %}

#### Apply the plan

```python
from telys import Telys

db = Telys("$TELYS_HOME/store")
col = db.open_collection("notes")

plan = col.tune(dry_run=True)     # compute a plan, apply nothing yet
stats = col.apply_tuning(plan)    # now configure the live collection
```

{% endstep %}

{% step %}

#### Read the returned stats

`apply_tuning` returns the same dictionary as `col.stats()`, so you can confirm the new configuration.

```python
print(stats["name"])              # notes
print(stats["external_ids"])      # live id count
print(stats)                      # runtime stats reflecting the applied IVF / recall
```

{% endstep %}

{% step %}

#### Persist it

```python
path = col.save()                 # commit; returns the collection directory
print(path)                       # $TELYS_HOME/store/notes
```

{% endstep %}

{% step %}

#### Confirm it survived a reopen

```python
db2 = Telys("$TELYS_HOME/store")
reopened = db2.open_collection("notes")
print(reopened.stats())           # default_target_recall / applied_tuner are back
```

{% endstep %}
{% endstepper %}

## Expected result

After `apply_tuning`, the collection searches with the plan's recall target and IVF layout: large partitions use the approximate path, partitions below the crossover stay exact. After `save()`, reopening restores `default_target_recall` and `applied_tuner` from `collection.json` — no re-tuning needed.

```
notes
48213
$TELYS_HOME/store/notes
```

From now on, every `col.search(...)` that does not pass its own `target_recall=` aims for the applied `default_target_recall`. Override per query, for example `col.search(vector, target_recall=0.995)`.

{% hint style="warning" %}
On a large collection, `apply_tuning` builds per-partition IVF indexes and can take a moment. This happens once at apply time, not on every query.
{% endhint %}

## Next steps

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Interpret tuning results</strong></td><td>Read the plan's predictions and verify them.</td><td><a href="/pages/dVG4mjMMPwA41mVMfhqv">/pages/dVG4mjMMPwA41mVMfhqv</a></td></tr><tr><td><strong>Inspect collection stats</strong></td><td>Confirm the applied configuration.</td><td><a href="/pages/WGHEJNj5Rltcfakhls3R">/pages/WGHEJNj5Rltcfakhls3R</a></td></tr><tr><td><strong>Snapshots &#x26; persistence</strong></td><td>How <code>save()</code> commits to disk.</td><td><a href="/pages/3IabEB7rmGWO2uCD2t8X">/pages/3IabEB7rmGWO2uCD2t8X</a></td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.telys.ai/tuning/apply-and-save.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
