Skip to content

Optional Terraform module: autoscaling RL worker fleet + S3 job queue - #5

Open
mmjerge wants to merge 2 commits into
experimentsfrom
infra-terraform
Open

Optional Terraform module: autoscaling RL worker fleet + S3 job queue#5
mmjerge wants to merge 2 commits into
experimentsfrom
infra-terraform

Conversation

@mmjerge

@mmjerge mmjerge commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Optional Terraform module for the RL worker fleet

Infrastructure-as-code for the experiment fleet that ran (and is running) the RL campaigns, so anyone on the project can deploy an identical setup into their own AWS account. Fully optional: the training code has no dependency on this directory.

What it deploys

  • Autoscaling group of single-GPU workers (L40S 48GB types, prioritized list) spanning every AZ. EC2 searches the whole (type x AZ) grid and backfills toward worker_count automatically -- this replaced manual instance launching after a day of InsufficientInstanceCapacity whack-a-mole across p4d/g6e sizes and four AZs. Fleet-of-singles rationale: the GRPO/RLOO loop is single-GPU, so the experiment matrix (seeds x cache configs x tasks) parallelizes across independent workers, and single-GPU types actually have capacity.
  • Self-provisioning workers: at boot each instance runs scripts/provision_worker.sh (repo checkout, pinned Python stack frozen from the reference box, canonical HELMET splits from S3, model download, smoke test), then starts scripts/worker_loop.sh -- claim a job from the S3 queue, run it, sync logs/artifacts to S3, park failures in queue/failed/, self-stop when the queue drains.
  • IAM role scoped to: read canonical-splits bucket, read/write results bucket, stop worker-tagged instances only.
  • Results bucket with optional read-only grants for collaborators' AWS accounts (Matthias' account is granted on the live deployment).
  • Optional spot mode (capacity-optimized) for when jobs checkpoint/resume.

Battle-tested

This config is extracted from the live fleet currently running the 7B @32k flagship campaign (3 workers, S3 queue). The sharp edges it encodes were all hit in practice: capacity scarcity, the 30GB-optimizer-state OOM (paged 8-bit optimizer now in the driver), silent queue-draining on job failure (now parked visibly), and zombie GPU processes after kills.

Usage

See terraform/README.md -- terraform apply -var worker_count=N -var ssh_public_key_path=..., then drop job scripts into s3://<results-bucket>/queue/pending/.

mmjerge added 2 commits August 9, 2026 22:03
Deploys N single-GPU workers (DL base AMI + provision_worker.sh at boot),
the kv-worker IAM role (canonical-splits read, results read/write,
tag-scoped self-stop), the results bucket with optional collaborator read
grants, and SSH key/security group. Fleet-of-singles rationale and job
queue usage documented in terraform/README.md. Fully optional: training
code has no dependency on this directory; distinct resource names so it
coexists with the hand-built infra.
…pacity hunting)

Replaces fixed aws_instance workers with an autoscaling group spanning
every default-VPC subnet and a prioritized list of L40S types
(g6e.2/4/8xlarge). EC2 searches the (type x AZ) grid and backfills toward
desired_capacity automatically -- no manual InsufficientInstanceCapacity
retries. Workers are stateless queue consumers (worker_loop at boot,
self-stop on drain); optional spot mode (capacity-optimized) for when
jobs can checkpoint/resume.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant