Tuner & plans
Reference for Tuner, TuningPlan, and the runtime-only HeuristicTuner — the objects that produce, describe, and apply a collection's index tuning.
Tuning turns a workload into a TuningPlan — a recall target, an exact-crossover threshold, and IVF parameters — that the collection applies and persists. Tuner and TuningPlan are top-level; HeuristicTuner comes from the signed runtime.
from telys import Tuner, TuningPlanTuner (base)
The base class defines the tuning interface; its name is "base". tune_collection is abstract — subclasses (such as the runtime's HeuristicTuner) implement the policy.
tune_collection(collection, workload=None, objectives=None)
TuningPlan
Build a plan for the collection. Raises NotImplementedError on the base class.
choose_plan(stats, query)
plan
Select a plan given current stats and a query.
explain()
—
Human-readable description of the tuner's policy.
Don't call a tuner directly. Attach one at creation, then call Collection.tune():
from telys import Telys
ame = Telys("./memory")
col = ame.create_collection("notes", dim=384, partition_by="scope", tuner=my_tuner)
plan = col.tune(workload=my_workload) # delegates to the tunerTuningPlan
A dataclass describing a tuning decision. It is the return value of Collection.tune() and the argument to Collection.apply_tuning().
collection
(required)
Name of the target collection.
tuner
(required)
Name of the tuner that produced the plan.
target_recall
(required)
Desired recall for approximate search.
exact_crossover_rows
(required)
Row count below which exact search is used.
ivf
(required)
IVF parameters as a dict (e.g. lists/nprobe).
expected
(required)
Expected outcomes (latency/recall estimates) as a dict.
constraints
(required)
Constraints considered, as a dict.
decision_trace
(required)
list of the decisions taken.
workload_hash
""
Hash of the workload the plan was built for.
engine
"telys"
Engine that produced the plan.
plan_id
""
Auto-assigned tune_<hash> when empty.
Methods:
as_dict()
dict
Serializable form of the plan.
to_json(**kw)
str
JSON string (**kw forwarded to json.dumps).
Applying a plan
Collection.tune() optionally applies as it goes; Collection.apply_tuning() applies an existing plan.
Collection.tune(workload=None, objectives=None, dry_run=None)
TuningPlan
dry_run=True never applies; False always applies; None applies only when tuner.mode == "suggest_then_apply".
Collection.apply_tuning(plan)
stats
Sets default_target_recall and exact-crossover, builds/uses per-partition IVF, and sets nprobe.
HeuristicTuner (runtime-only)
HeuristicTuner is listed in telys.__all__ but is not implemented in the thin SDK. It resolves lazily from the signed runtime and raises ImportError when the runtime is not installed.
See also
Last updated
Was this helpful?