Long story short
Your model class, two configs and a folder of shard zips go into one call:
from resontech import TrainingConfig, FederationConfig
job = sdk.rt_submit(
model=MyResNet,
name="my-fl-job",
shards_dir="./shards",
training=TrainingConfig(num_classes=10, local_epochs=2, batch_size=32, learning_rate=1e-3, img_size=224),
federation=FederationConfig(num_rounds=5, min_clients=1, job_name="my-fl-job"),
)
print(job.dashboard_url)sdk is the client from Install the SDK. Set it up there first: pip install, your two keys and a connection check.Full path
1. Define your model
A standard nn.Module with a num_classes argument in __init__ and a forward(B, 3, H, W) -> logits. The SDK copies the class source into the job as model_def.py.
import torch.nn as nn
from torchvision import models
class MyResNet(nn.Module):
def __init__(self, num_classes: int):
super().__init__()
self.backbone = models.resnet18(weights=None)
self.backbone.fc = nn.Linear(self.backbone.fc.in_features, num_classes)
def forward(self, x):
return self.backbone(x)import the class needs in the same file or notebook cell as the class. Imports from elsewhere don’t travel with it.To override the executor, the persistor or the data loader, see Custom training classes.
2. Describe training and federation
from resontech import TrainingConfig, FederationConfig
training = TrainingConfig(
num_classes=10,
local_epochs=2,
batch_size=32,
learning_rate=1e-3,
img_size=224,
)
federation = FederationConfig(
num_rounds=5,
min_clients=1,
job_name="my-fl-job",
)Settings without a typed field (mixup, weight decay, a custom scheduler) go into TrainingConfig.extra. Every field: Training config reference.
3. Submit
job = sdk.rt_submit(
model=MyResNet,
name="my-fl-job",
shards_dir="./shards", # one shard_*.zip per worker
requirements_txt="./requirements.txt", # optional
training=training,
federation=federation,
)
print(f"Submitted: {job.id}")
print(f"Track at: {job.dashboard_url}")rt_submit() returns once your shards are uploaded: a minute or two for a few GB. The number of zips in shards_dir is the number of GPU workers; how to split your data: Dataset format & sharding. You get back a Job with .id and .dashboard_url.
4. Track progress
Open job.dashboard_url to watch the round counter, browse the job’s files and download the trained model. From Python:
sdk.jobs.get(job.id)returns the job’s current state.sdk.storage.list("jobs/<name>/")lists its files in your bucket.sdk.storage.presign_get(key)gives a download link for any of them.
More patterns: Track jobs & download results.
What’s next
- Tune the configs: Training config reference lists every TrainingConfig and FederationConfig field.
- Port a training script you already have: Port a centralized recipe to FL.
- Start from a working example: job_training_sdk trains a small CNN on MNIST with a complete submit script.
- Browse more recipes: FL examples gallery covers vision, language, speech, embeddings, medical imaging and image generation.