Skip to main content

cubecl_runtime/config/
autotune.rs

1#[cfg(std_io)]
2use super::cache::CacheConfig;
3use super::logger::{LogLevel, LoggerConfig};
4
5/// Configuration for autotuning in `CubeCL`.
6#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
7pub struct AutotuneConfig {
8    /// Logger configuration for autotune logs, using autotune-specific log levels.
9    #[serde(default)]
10    pub logger: LoggerConfig<AutotuneLogLevel>,
11
12    /// Autotune level, controlling the intensity of autotuning.
13    #[serde(default)]
14    pub level: AutotuneLevel,
15
16    /// Cache location for storing autotune results.
17    #[serde(default)]
18    #[cfg(std_io)]
19    pub cache: CacheConfig,
20
21    /// Whether to disable the persistent cache of autotune results.
22    ///
23    /// The in-memory cache is unaffected: a key is still tuned only once per process.
24    #[serde(default)]
25    pub disable_cache: bool,
26}
27
28/// Log levels for autotune logging in `CubeCL`.
29#[derive(Default, Clone, Copy, Debug, serde::Serialize, serde::Deserialize)]
30pub enum AutotuneLogLevel {
31    /// Autotune logging is disabled.
32    #[serde(rename = "disabled")]
33    Disabled,
34
35    /// Minimal autotune information is logged such as the fastest kernel selected and a few
36    /// statistics (default).
37    #[default]
38    #[serde(rename = "minimal")]
39    Minimal,
40
41    /// Full autotune details are logged.
42    #[serde(rename = "full")]
43    Full,
44}
45
46impl LogLevel for AutotuneLogLevel {}
47
48/// Autotune levels controlling the intensity of autotuning.
49#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
50pub enum AutotuneLevel {
51    /// Minimal autotuning effort.
52    #[serde(rename = "minimal")]
53    Minimal,
54
55    /// Balanced autotuning effort (default).
56    #[default]
57    #[serde(rename = "balanced")]
58    Balanced,
59
60    /// Increased autotuning effort.
61    #[serde(rename = "extensive")]
62    Extensive,
63
64    /// Maximum autotuning effort.
65    #[serde(rename = "full")]
66    Full,
67}