aitune.torch.tune_strategy.profiling_tune_strategy
aitune.torch.tune_strategy.profiling_tune_strategy
Shared base for profiling-based tune strategies.
A profiling strategy profiles a TorchEager baseline, then builds, validates, and
profiles every user-provided backend, selecting the one whose profiled metric is
best. Subclasses define the metric (throughput, latency, …) by setting a few
class attributes and implementing a small set of hooks; MaxThroughputStrategy,
MinLatencyStrategy, and LatencyBudgetStrategy are the concrete implementations.
Module Contents
Classes
API
Profiled metric and speedup result for a single backend.
Profiled backend result returned by profiling strategies.
Returns the scalar metric used to compare candidates.
Returns fields stored in strategy_results for this backend.
Bases: FindMaxBatchSizeMixin
Base class for strategies that select a backend by a profiled metric.
Subclasses set _title, _description, _metric_label (e.g. “throughput”),
_metric_unit (e.g. “samples/s”) and _value_fmt (a format spec such as “.2f”),
and implement :meth:_measure, :meth:_is_better, and :meth:_speedup.
TorchEager is profiled in _pre_tune as a baseline (not injected into the backends
list). When performance validation is enabled (default), the strategy falls back to
TorchEager when no user-provided backend beats it. When disabled, the best
user-provided backend wins regardless of speed, and the strategy raises if all user
backends fail.
Returns default backends.
Returns the parts of the description.
Formats a metric value with its unit, e.g. 12.34 samples/s.
Gets profiling configuration.
Returns True when result is better than other.
Emit an explicit message when the TorchEager baseline is the selected backend.
Profiles the backend and returns its result.
Emits a speedup line after tuning completes.
Calls super()._pre_tune() (finds max batch size) then profiles TorchEager as baseline.
Appends a BackendPerfResult for the given backend if a baseline is available.
Returns the winning candidate, falling back to the TorchEager baseline when appropriate.
Builds, validates, and profiles each backend; returns the best candidate.
Returns the speedup of result relative to baseline_result (>1 is faster).
Tunes given torch module with provided graph_spec and data.
Enables or disables baseline validation.
Returns config dict for the strategy.