Training /Submit via SDK

Submit a training job (SDK)

One rt_submit() call: define a model, ship the shards, watch it run.

Long story short

Your model class, two configs and a folder of shard zips go into one call:

submit.py
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)
note
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.

model.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)
warn
Keep every 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

submit.py
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

submit.py
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