aitune.torch.tune_strategy.resolver
aitune.torch.tune_strategy.resolver
Create tune strategies whose backends are resolved for each module.
Module Contents
Classes
Functions
Data
API
Bases: BaseModel
Describe one requirement that a tuning candidate must satisfy.
Only ‘latency’ metric with ‘ms’ unit is supported for now.
Require latency to be no greater than milliseconds.
Bases: BaseModel
Describes rules that are used to select and configure an optimal tuning strategy for a given module at tune time.
This class holds no backend instances or backend-specific state. Instead, it contains a declarative description of the desired optimization objective (such as “throughput” or “latency”) and a set of constraints, all of which apply together.
In this framework:
- The objective defines what we try to maximize or minimize (e.g., maximize throughput).
- The constraint(s) express requirements that must be met by any configuration the strategy chooses (such as “latency at_most N ms”). For now, only a single latency constraint is supported (e.g., “latency at_most N ms”).
- Typically, this means we optimize for maximum throughput, but only among strategies/configurations that meet the given latency constraint.
This class is dynamic: it does not directly reference any backends.
When materialize() is called with a particular module, it creates a concrete TuneStrategy with appropriate backend objects
and automatically selects the right strategy class (e.g., LatencyBudgetStrategy for a throughput-optimization subject to a latency constraint).
The same DynamicTuneStrategy instance can be used for multiple modules, and a fresh concrete strategy is produced for each module.
Example:
Optimize for max throughput, but only if latency ≤ 40 ms for the current module
dts = DynamicTuneStrategy( objective=“throughput”, compilation=“any”, constraints=[Constraint.max_latency_ms(40)] ) strategy = dts.materialize(some_module)
Return an independent copy of this dynamic configuration.
Configure maximum-batch-size discovery on the resolved strategy.
Create a concrete strategy with fresh backends for module.
Return the unresolved configuration for reporting.
Create default candidates compatible with the module and requested compilation.
Resolve a dynamic strategy for module or preserve an explicit strategy.
Declare a strategy whose backends will be resolved for each tuned module.
Parameters:
Objective — Performance metric to optimize: throughput or latency.
Compilation — Allow ahead-of-time, just-in-time, or any supported backend build mode.
Sequence[ Constraint ] — Limits that candidates must satisfy while optimizing the objective.
Returns: DynamicTuneStrategy
A dynamic strategy configuration suitable for AOT and JIT tuning.