Train with automatic checkpoint saving:
using Sovwave
# Your model and data
model = WaveModel(cfg)
inputs = [rand(32) for _ in 1:100]
targets = [rand(16) for _ in 1:100]
# Train with checkpoints every 10 epochs
trained_model, history = train!(
model, inputs, targets, cfg.train;
checkpoint_dir = "my_checkpoints", # Where to save
checkpoint_every = 10, # Save every N epochs
verbose = true
)Every checkpoint includes:
.mkvfile: Dual-stream video with model weights + visualization.mp4file: Single-stream version (double-click to view!)_meta.yamlfile: Configuration and metadata
# Double-click the .mp4 file in your file browser, or:
vlc my_checkpoints/checkpoint_epoch_0010.mp4
mpv my_checkpoints/checkpoint_epoch_0010.mp4
ffplay my_checkpoints/checkpoint_epoch_0010.mp4What you'll see:
- Potts q-state domain visualization (magenta/yellow/cyan)
- Wave lattice evolution from step n to step n_final
- Visual representation of learned quantum states
using Sovwave
# Load checkpoint
checkpoint = load_model("my_checkpoints/checkpoint_epoch_0010.mkv")
# Inspect
summary = inspect_model(checkpoint)
println("Loaded model from epoch 10")
println("Parameters: ", summary[:total_parameters])
println("Energy: ", checkpoint.total_energy)
# Resume training from checkpoint
new_model, history = train!(checkpoint, inputs, targets, cfg.train)# Extract visual frames
ffmpeg -i checkpoint_epoch_0010.mkv -map 0:v:0 frame_%04d.png
# Extract model weight frames (lossless)
ffmpeg -i checkpoint_epoch_0010.mkv -map 0:v:1 -c copy weights.mkvtrain!(model, inputs, targets, cfg;
checkpoint_dir = "checkpoints", # Directory to save (auto-created)
checkpoint_every = 10, # Save every N epochs (default: 10)
audio_cfg = WaveAudioConfig(...), # Optional audio config
verbose = true # Show checkpoint save messages
)checkpoints/
├── checkpoint_epoch_0010.mkv # Epoch 10 full model
├── checkpoint_epoch_0010.mp4 # Epoch 10 viewable video
├── checkpoint_epoch_0010_meta.yaml # Epoch 10 metadata
├── checkpoint_epoch_0020.mkv # Epoch 20 full model
├── checkpoint_epoch_0020.mp4 # Epoch 20 viewable video
└── checkpoint_epoch_0020_meta.yaml # Epoch 20 metadata
✅ Resume Training: Load any checkpoint and continue training
✅ Visual Progress: Watch model evolution as a video
✅ No Extra Storage: Checkpoints are tiny (3-5 KB typical)
✅ Universal Viewing: MP4 files work everywhere
✅ Lossless Weights: Exact model state preserved in MKV
✅ Metadata Included: YAML files store full configuration
- Checkpoint save time: ~5-20ms per checkpoint
- Storage per checkpoint: 3-10 KB (depends on model size)
- Training slowdown: <0.1% (only saves on checkpoint epochs)
Checkpoints are saved asynchronously and don't block training.
train!(model, inputs, targets, cfg;
checkpoint_dir = "checkpoints",
checkpoint_every = 5,
video_cfg = WaveVideoConfig(
frames = 16, # More frames = longer video
fps = 8, # Faster playback
render_mode = :potts_model_q_state_domains,
pixel_scale = 4, # Larger pixels
target_height = 720 # HD resolution
)
)- Check that
checkpoint_dirpath is writable - Ensure
ffmpegis installed:which ffmpeg - Set
verbose=trueto see error messages
- MP4 export requires
ffmpegwith H.264 codec - Install:
sudo apt install ffmpeg(Linux) orbrew install ffmpeg(Mac)
- Reduce
video_cfg.frames(default: 8) - Use
include_audio=falsein save_model options - Checkpoints scale with model size (nodes × layers)
using Sovwave
# Large dataset, long training
cfg = WaveMLConfig(
train = WaveTrainConfig(epochs=1000, batch_size=32)
)
model = WaveModel(cfg)
# Save checkpoints every 50 epochs
trained, history = train!(
model, large_inputs, large_targets, cfg.train;
checkpoint_dir = "long_training_checkpoints",
checkpoint_every = 50,
verbose = true
)
# Result: 20 checkpoints saved (epochs 50, 100, 150, ..., 1000)
# Can resume from any checkpoint if training is interruptedThe checkpoint feature is backward compatible:
# Old code (still works, no checkpoints saved)
train!(model, inputs, targets, cfg.train)
# New code (checkpoints saved)
train!(model, inputs, targets, cfg.train; checkpoint_dir="ckpt")If you don't specify checkpoint_dir, no checkpoints are saved.
See Also:
specs/CPU_Optimization_Winners.md- Training performance improvementstest_checkpoint_saving.jl- Full example with verificationdocs/WaveML_User_Guide.md- Complete WaveML documentation