# Old ALI Runner Infrastructure (Legacy Lambda-Autoscaled EC2)

Concise reference for the pre-OSDC runner world. Load this when a `runs-on` label has a
bare or dotted prefix (`linux.`, `lf.`, `c.`, `lf.c.`) or an `arc.yaml` identity/
passthrough entry, and you need to know what infra it is, who owns it, and why it still
exists. For the current OSDC/ARC routing, see the main `SKILL.md`.

## What it is

The legacy infra provisions ONE ephemeral EC2 instance per job:

1. GitHub emits a `workflow_job` (queued) webhook.
2. The webhook lands in SQS.
3. A scale-up Lambda (the `terraform-aws-github-runner` module) reads the job's labels.
4. It does an **exact-match** lookup of the label set in `scale-config.yml`.
5. It calls `RunInstances` to launch a single EC2 instance of the matching type/AMI.
6. The instance boots and the self-hosted runner registers with GitHub via
   `config.sh --labels <exact label set>`.
7. GitHub matches the queued job to that runner; the job runs; the instance is torn down.

One fresh VM per job, provisioned on demand.

**Contrast with OSDC/ARC**: Actions Runner Controller runs the GitHub runner as a POD on
a pre-existing EKS nodepool — the Kubernetes scheduler places the pod, no per-job VM
boot. Old ALI = a Lambda launches a VM per job; OSDC = pods on a warm cluster.

## Dot / bare prefix semantics

The old infra encodes fleet + canary in the label prefix itself. The prefixed copies are
generated by `validate_scale_config.py --generate` (test-infra), which prefix-substitutes
each runner type in `.github/scale-config.yml` to produce the derivative
`canary-scale-config.yml` / `lf-scale-config.yml` / `lf-canary-scale-config.yml`:

| Prefix | Meaning |
|--------|---------|
| `""` (bare, e.g. `linux.2xlarge`) | Meta prod EC2 |
| `c.` | Meta canary EC2 |
| `lf.` | Linux Foundation prod EC2 |
| `lf.c.` | Linux Foundation canary EC2 |

These are the DOTTED / bare prefixes. The current determinator can **never** emit them —
it emits only the dash prefixes `mt-` / `lf-` / `c-mt-`. The dot->dash shift is exactly
the ALI->OSDC migration.

## Ownership map

- **`test-infra/terraform-aws-github-runner`** — the Lambda autoscaler + SQS +
  AMI/launch-template Terraform module (the mechanism).
- **`test-infra:.github/scale-config.yml`** + **`.github/lf-scale-config.yml`** — the
  label definitions (instance type, AMI, disk, max-available) for Meta and LF
  respectively. `validate_scale_config.py --generate` prefix-substitutes the source
  `scale-config.yml` to generate the `c.` / `lf.` / `lf.c.` prefixed copies
  (`canary-scale-config.yml` / `lf-scale-config.yml` / `lf-canary-scale-config.yml`).
  (`variants:` is a separate feature — a per-runner-type AMI override, e.g. the Windows
  `wincanary` / `wincanarylf` variants — not the prefix generator.)
- **`pytorch-gha-infra/runners`** — the Meta-side deploy that wires the module to AWS
  (env `gh-ci`, `AWS_PROFILE=fbossci`).
- The **Linux Foundation** operates a structurally-parallel deploy of the same module
  OUTSIDE these repos (its own AWS account); its specs mirror Meta's scale-config.

## How to tell a job is on old ALI today

- Its `runs-on` is a bare or dotted label with NO dash prefix (`linux.rocm.gpu.2`,
  `linux.dgx.b200.8`, and historically `lf.linux.*`), OR
- The bare label has an identity/passthrough entry in `pytorch/pytorch:.github/arc.yaml`
  `runner_mapping` (`mapped == clean`), which `map_ec2_to_arc.py` leaves un-prefixed so
  it lands on the existing self-hosted runner.

Current passthrough / identity labels (from `arc.yaml` — literal self-hosted / partner
HW, not OSDC): `linux.dgx.b200.8`, `linux.idc.xpu`, `linux.client.xpu`,
`linux.google.tpuv7x.1`, `linux.rocm.gpu.2`, `linux.rocm.gpu.mi210.1/.2`,
`linux.rocm.gpu.gfx942.1/.4`, `linux.rocm.gpu.gfx950.1/.2`, `linux.rocm.gpu.gfx1100`,
and the amd-do-prefixed `amd-do-linux.rocm.gpu.gfx950.1/.2`.

## Status

Legacy. The determinator no longer routes anything to old ALI except via `arc.yaml`
identity passthrough — partner hardware, or capacity not yet on OSDC (e.g.
`linux.dgx.b200.8`, kept "until OSDC capacity is available"). It is being decommissioned
as OSDC capacity lands. The dot->dash migration completed in pytorch/pytorch PR #189219
(which removed the `arc` experiment and the `use-arc` output); main's build/test path no
longer has an EC2 fallback, so the determinator must never emit a bare/dotted prefix (see
the `_runner-determinator.yml` checkout comment citing #189113/#189171).
