burn_std/config/remote.rs
1use cubecl_common::config::logger::{LogLevel, LoggerConfig};
2
3/// Configuration for the remote backend.
4#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
5pub struct RemoteConfig {
6 /// Logger configuration for remote-backend logs (e.g. the bytes-saved metric of the
7 /// fusion / op-graph caching feature).
8 #[serde(default)]
9 pub logger: LoggerConfig<RemoteLogLevel>,
10
11 /// Flush the outgoing task buffer once this many tasks have accumulated.
12 ///
13 /// Wire-level batching only — every task keeps its own stream/request id, so the server sees
14 /// the same per-task semantics. Larger values batch more aggressively (fewer, bigger frames);
15 /// smaller values cut latency for chains of fire-and-forget submits.
16 #[serde(default = "default_flush_threshold")]
17 pub flush_threshold: usize,
18
19 /// Flush once this many bytes of buffered tensor data accumulate, independent of
20 /// [`flush_threshold`](Self::flush_threshold).
21 ///
22 /// Bounds how much tensor data sits unsent so large uploads go out promptly while small ops keep
23 /// batching. Larger batches fewer/bigger frames; smaller cuts latency for data-heavy streams.
24 #[serde(default = "default_flush_bytes_threshold")]
25 pub flush_bytes_threshold: usize,
26}
27
28impl Default for RemoteConfig {
29 fn default() -> Self {
30 Self {
31 logger: LoggerConfig::default(),
32 flush_threshold: default_flush_threshold(),
33 flush_bytes_threshold: default_flush_bytes_threshold(),
34 }
35 }
36}
37
38fn default_flush_threshold() -> usize {
39 4
40}
41
42fn default_flush_bytes_threshold() -> usize {
43 1024 * 1024
44}
45
46/// Log levels for remote-backend logging.
47#[derive(
48 Default,
49 Clone,
50 Copy,
51 Debug,
52 PartialEq,
53 Eq,
54 PartialOrd,
55 Ord,
56 serde::Serialize,
57 serde::Deserialize,
58)]
59pub enum RemoteLogLevel {
60 /// Remote logging is disabled.
61 #[default]
62 #[serde(rename = "disabled")]
63 Disabled,
64
65 /// Log periodic summaries — e.g. the cumulative network bytes saved by op-graph caching,
66 /// emitted once per additional mebibyte saved.
67 #[serde(rename = "basic")]
68 Basic,
69
70 /// Log every optimization registration and replay, with per-message sizes.
71 #[serde(rename = "full")]
72 Full,
73}
74
75impl LogLevel for RemoteLogLevel {}