Skip to main content

Configuration reference

Speedtronic configuration is implemented by mutable dataclasses in speedtronic.config. Each section validates selected invariants in __post_init__; the aggregate applies cross-section defaults.

Accepted forms​

from speedtronic import SpeedtronicConfig, load_config

config = SpeedtronicConfig.from_dict({...})
config = SpeedtronicConfig.from_yaml("run.yaml")
config = SpeedtronicConfig.load("run.json")
config = SpeedtronicConfig.load("name: demo\nmax_steps: 10")
config = load_config({"max_steps": 10})

load() heuristically distinguishes inline YAML/JSON from paths. Unknown root and nested mapping keys raise ConfigError.

Root sections​

run: {}
model: {}
data: {}
optimizer: {}
scheduler: {}
precision: {}
checkpoint: {}
logging: {}
distributed: {}
gradient_checkpointing: false
compile: false

RunConfig​

FieldTypeDefaultMeaning and validation
namestrspeedtronic-runDescriptive run name; not used as a filesystem path
seedint1234Seeds Python, NumPy when available, PyTorch CPU, and CUDA
devicestrautoRequested device; auto selects CUDA, MPS, then CPU
max_stepsint1000Positive absolute local optimizer-step target
output_dirstrrunsBase for relative checkpoint and distributed state paths
log_everyint | NonenullPositive; copied to logging cadence only when logging cadence remains 1

ModelConfig​

FieldTypeDefaultMeaning and validation
namestrreference_transformerRegistry key; membership is not checked during config parsing
vocab_sizeint512Positive vocabulary size
max_seq_lenint128Positive reference-model context limit; mapped to block_size
n_layerint4Positive layer count
n_headint8Positive query-head count
n_kv_headint | NonenullResolves to n_head; positive and divides n_head
d_modelint256Positive hidden width; divisible by n_head
d_ffint | NonenullResolves to 4 * d_model; positive
dropoutfloat0.0Must satisfy 0 <= dropout < 1
tie_weightsbooltrueReference-model embedding/output weight tying
rope_basefloat10000.0Rotary base; no positivity check in ModelConfig
gradient_checkpointingboolfalseSynchronized with root-level flag

These fields are reference-transformer-oriented even though the trainer itself is architecture-neutral.

DataConfig​

FieldTypeDefaultMeaning and validation
text_pathstr | nullnullUTF-8 text file; selected before serialized/synthetic data
datasetstr | nullnullSerialized dataset path in YAML; may hold a Dataset object programmatically
syntheticbooltrueEnables synthetic fallback
num_tokensint100000Positive; synthetic implementation uses it as sample count
vocab_sizeint | nullnullPositive if explicit; aggregate normally fills from model
block_sizeint | nullnullPositive after aggregate initialization; normally model context length
micro_batch_sizeint1Positive loader batch size
target_batch_sizeint1Positive, at least microbatch, and divisible by microbatch
num_workersint0Non-negative DataLoader worker count
prefetch_factorint | nullnullPositive if explicit; defaults to 2 when workers are enabled
pin_memorybool | nullnullExplicit override or runtime device-derived default
shuffleboolfalseApplied to map-style datasets; forced off for iterable datasets
drop_lastbooltrueDrop incomplete loader batches
seedint | nullnullAggregate fills from run.seed
max_stepsint | nullnullPositive; used as local target when run target is not explicitly overridden

Derived accumulation:

config.data.accumulation_steps
# target_batch_size // micro_batch_size
num_tokens naming

For synthetic data, num_tokens=256 creates 256 samples, each containing block_size input tokens and one next-token target. It is not a literal total-token budget.

OptimizerConfig​

FieldTypeDefaultMeaning and validation
namestradamwOnly adamw is supported
lrfloat0.0003Positive learning rate
betastuple[float, float](0.9, 0.95)Exactly two values in [0, 1)
epsfloat1e-8Positive Adam epsilon
weight_decayfloat0.1Non-negative
fusedbool | nullnullAuto-probe, force, or disable fused AdamW
grad_clipfloat | nullnullPositive global gradient-norm limit

Fused construction is best-effort. Failure falls back to regular AdamW.

SchedulerConfig​

FieldTypeDefaultMeaning and validation
namestrcosinecosine or constant
warmup_stepsint100Non-negative optimizer-step warmup
max_stepsint1000Positive schedule horizon
min_lr_ratiofloat0.1Cosine floor in [0, 1]; ignored by constant schedule

The warmup factor is (step + 1) / warmup_steps, floored at 1e-8. The cosine factor clamps progress to [0, 1].

Schedule target mismatch

SchedulerConfig rejects max_steps <= 0, making the aggregate branch that attempts to infer it from run.max_steps unreachable. If a Python config omits scheduler.max_steps, it remains 1000 even when run.max_steps is 10. The CLI --max-steps override updates both fields; direct Python overrides do not.

PrecisionConfig​

FieldTypeDefaultMeaning and validation
modestrautoauto, bf16, fp16, or fp32
dtypestr | nullnullbf16, fp16, or fp32; affects resolution only when mode is auto

A string section is accepted as shorthand:

precision: bf16

Conflicting values such as mode: fp32 and dtype: bf16 are accepted; the explicit mode wins and dtype is ignored.

CheckpointConfig​

FieldTypeDefaultMeaning and validation
enabledbooltrueEnable interval saves from the trainer
directorystrcheckpointsRelative paths are rooted under run.output_dir
every_stepsint500Positive global-step interval
keep_lastint | null3Positive retained count or null for unlimited
resumeboolfalseRequest local checkpoint loading during runtime construction

Saving happens only at exact interval boundaries. The trainer does not force a final checkpoint when the final step is off interval.

LoggingConfig​

FieldTypeDefaultMeaning and validation
levelstrINFOUppercased; unknown names map to INFO in the logger
filestr | nullnullOptional text output; relative to process working directory
every_stepsint1Positive cadence for train_step text, JSONL, and hook delivery
json_filestr | nullnullOptional JSONL output; relative to process working directory

There is no YAML hooks field. W&B, TensorBoard, and custom hooks require programmatic logger construction or mutation.

DistributedConfig​

FieldTypeDefaultMeaning and validation
enabledboolfalseConstruct DumbDiLoCoCoordinator
modestrdumb_dilocodumb_diloco or disabled single
rolestrsinglesingle, master, or worker
node_idstr | nullnullExplicit path-safe unique ID
collaboratorslist[str][]Master attempts to grant each user write
inner_stepsint500Positive local steps between uploads
poll_intervalfloat60.0Positive worker/master polling interval
outer_lrfloat0.7Positive Nesterov outer learning rate
outer_momentumfloat0.9Value in [0, 1)
repo_idstr | nullnullRequired for enabled distributed mode
tokenstr | nullnullOptional Hub token; prefer SDK environment authentication
cache_dirstr.speedtronic/hubHub cache, relative to process working directory
state_dirstr.speedtronic/dilocoRelative state root under run.output_dir, then /<node_id>
retry_initialfloat1.0Positive first retry delay
retry_maxfloat60.0At least retry_initial
retry_attemptsint6Positive total attempts per Hub operation
reset_inner_optimizerbooltrueClear optimizer state after successful upload/load callback

When enabled with role: single, the role becomes master because a repository is required. The code treats this as a master-by-default convenience.

Root booleans​

gradient_checkpointing: true
compile: true

compile also accepts:

compile:
enabled: true

Top-level values pass through bool(...); quoted strings such as "false" become truthy. YAML booleans should remain unquoted.

Aggregate normalization​

SpeedtronicConfig.__post_init__ performs:

  1. Positive run target check.
  2. Distributed role fallback.
  3. data.block_size = model.max_seq_len when null.
  4. data.vocab_size = model.vocab_size when null.
  5. data.seed = run.seed when null.
  6. logging.every_steps = run.log_every when the former remains 1.
  7. Scheduler fallback that is only reachable for a non-positive value.
  8. data.max_steps scheduler adoption when the scheduler still has its default 1000 horizon.
  9. If either gradient-checkpointing flag is true, set both root and model flags true.

Top-level aliases​

These keys are moved into run before schema validation:

name: demo
seed: 42
device: cpu
max_steps: 100
output_dir: runs/demo
log_every: 10

If both a top-level alias and nested run field exist, the top-level alias overwrites the nested value for that field.

Compatibility section aliases:

hub: {} # accepted only when distributed is absent
diloco: {} # accepted only when distributed is absent

Serialization and redaction​

plain = config.to_dict()
safe = config.to_dict(redact_secrets=True)
yaml_text = config.to_yaml(redact_secrets=True)
path = config.save("run.yaml")

save() always redacts distributed.token. to_dict() and to_yaml() default to unredacted output. Checkpoints also request redaction.

Path semantics​

SettingRelative-path base
checkpoint.directoryrun.output_dir
distributed.state_dirrun.output_dir, then node_id
distributed.cache_dirProcess working directory
logging.fileProcess working directory
logging.json_fileProcess working directory
data.text_pathProcess working directory
serialized data.datasetProcess working directory

v2 optimizer fields​

optimizer: muon
muon_plus: true
cautious: true

The canonical mapping form is:

optimizer:
name: muon # adamw or muon
lr: 0.0003
muon_plus: false
cautious: false
muon_momentum: 0.95
muon_ns_steps: 5
muon_norm_eps: 0.00000001

optimizer: muon and the root-level muon_plus/cautious forms are normalized into OptimizerConfig. Conflicting duplicate values are rejected. muon_plus requires name: muon; cautious works with either optimizer.

v2 systems fields​

shape_validation:
enabled: true
alignment: auto
check_batch: true
check_sequence: true
check_model: true
check_vocab: false
warn_on_cpu: false

ooo_backprop: false
ooo_streams: 4

ooo_streams is constrained to 1–8. Shape warnings are non-fatal. See the v2 optimizer, scheduling, and shape validation pages.

v2 distributed fields​

distributed:
async_delta_upload: true
delta_upload_queue_size: 1
delta_upload_overflow: skip
delta_upload_shutdown_timeout: 5.0
async_global_poll: true

Queue size is intentionally one in v2. An occupied upload slot causes the next boundary to skip and log rather than block the inner loop. Set both async flags to false for the legacy synchronous transport path.

run:
name: local
seed: 1234
device: cpu
max_steps: 4
output_dir: runs/local

model:
name: reference_transformer
vocab_size: 128
max_seq_len: 32
n_layer: 2
n_head: 4
n_kv_head: 2
d_model: 64
d_ff: 128

data:
synthetic: true
num_tokens: 32
block_size: 32
micro_batch_size: 1
target_batch_size: 2
num_workers: 0

optimizer:
lr: 0.0003
weight_decay: 0.01

scheduler:
name: cosine
warmup_steps: 1
max_steps: 4

precision:
mode: fp32

checkpoint:
enabled: true
directory: checkpoints
every_steps: 2
keep_last: 2

logging:
level: INFO
every_steps: 1

For loader and model implementation details, continue to Data and Reference model. For execution, see Runtime and Trainer.