Skip to content

Add a Beam BF16 LoRA recipe and a blog reproduction reference run - #252

Merged
Fred Robinson (frrad) merged 5 commits into
mainfrom
bb/https-modal-com-slack-com-archives-d0ce0tq2f7f-p-thr_dbnae2xvsn
Nov 18, 2026
Merged

Fred Robinson (frrad) merged 5 commits into
mainfrom
bb/https-modal-com-slack-com-archives-d0ce0tq2f7f-p-thr_dbnae2xvsn

Conversation

@frrad

@frrad Fred Robinson (frrad) commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds a bundled two-node recipe for BF16 LoRA on reflection/Beam-1.0-501B-A23B, and a reference run that reproduces the published Beam LoRA training through the stock Tinker SDK.

  • Recipe. beam-501b-a23b-lora-5k trains on two eight-H200 nodes and samples on one eight-B300 node. Attention and MLP gates are separate LoRA targets, and training uses routing replay. It trains on miles-v0.2.0-8c5de26 and samples on sglang-v0.5.23-e003cf9, which serves Beam LoRA. Trainers use local Triton and TorchInductor caches, because fresh multi-node workers reading the shared caches have loaded zero-filled generated modules.
  • Reference run. reference_runs/configs/beam_blog_repro.toml selects the recipe and scripts/beam_blog_repro.py. The script trains on DAPO-Math with CISPO, one update of rollout prefetch and a 400-update cosine schedule, evaluates on AIME25, and resumes from checkpoints. The index holds an earlier 42-update execution and the digitized published curve.
  • Catalog. catalog.py defines the output format every reference script writes (Record, Evaluation, Update, read_output), and tests check every indexed output and both scripts' outputs against it. An index entry for an execution outside Spindle records source instead of Spindle provenance. The format is described in reference_runs/README.md.
  • Routing replay. The replay wrapper finds rollout_data by name in Miles' own run_forward_backward signature, so it works whether a caller passes it by position or keyword, on both v0.1.1 and v0.2.0, and fails at trainer startup if the parameter is missing.
  • Proxy auth. The Beam script runs training in a supervised worker. The worker is now forked, so it keeps patches the parent installed, such as the headers examples/shared-server/with_proxy_auth.py adds. A worker started from a fresh interpreter lost them and could not reach a proxy-protected server.
  • The Beam script and its tests are fully typed. AGENTS.md and the comment on the ANN ignore list now say that list only shrinks.

Testing

Pre-commit, the CPU suite (1,689 passed, 10 skipped) and all three CI jobs pass on 03c28c5, this PR rebased onto main after #382 and #290. The only conflict was in CHANGELOG.md. The GPU stages below ran on 84163b1 and 45b534e, before #382 changed Miles checkpoint restore.

End to end, the stock-Tinker reference client ran against a deployment of this PR through with_proxy_auth.py, in three stages:

  1. Start on 84163b1 (this PR before the rebase onto main; same Beam runtime code): the trainer started on two nodes, saved a step-0 checkpoint, published the adapter, ran the step-0 AIME25 evaluation and accepted updates 1 and 2. It stopped with a step-2 checkpoint.
  2. Cold restore on 45b534e: fresh trainer containers restored the step-2 checkpoint, with optimizer state, and saved it again. All 16 tensor shards (43.5 GB) and both metadata files are bitwise identical to the original. The DCP index matches in all 1,873 entries and differs only in storage_meta (save path and save ID).
  3. Continue on 45b534e from the restored checkpoint: updates 3 to 11 were accepted, with AIME25 evaluations at 5 and 10 and checkpoints at 10 and 11.
AIME25 (30 problems × 8 samples, 4,096-token cap) Step 0 Step 5 Step 10
This PR, Miles v0.2.0 42.08% 42.08% 43.33%
Earlier run, Miles v0.1.2 40.42% 42.08% 45.00%

Updates 1–10 are the learning-rate warmup, so little change is expected yet.

Median seconds, updates 1–11 This PR, Miles v0.2.0 Earlier run, Miles v0.1.2
Native forward/backward 372.7 438.4
Trainer API wall time 455.4 508.7
Between accepted updates 604.2 601.9

The between-updates median for this PR leaves out the gap across the planned restart. Batch rewards for updates 1–11 track the earlier run within a few points.

Not validated: the full 100-update run and its learning comparison with the published curve, the launcher's automatic indexing of a completed Beam run, and Beam on any GPU type other than H200 trainers and B300 samplers.

🤖 Generated with Claude Code

@frrad Fred Robinson (frrad) changed the title Add an experimental Beam BF16 LoRA recipe and pinned runtimes Add Beam BF16 LoRA support Nov 11, 2026
@frrad
Fred Robinson (frrad) marked this pull request as ready for review November 11, 2026 23:53
@frrad Fred Robinson (frrad) changed the title Add Beam BF16 LoRA support Add Beam BF16 LoRA support and a reference run Nov 12, 2026
@frrad
Fred Robinson (frrad) force-pushed the bb/https-modal-com-slack-com-archives-d0ce0tq2f7f-p-thr_dbnae2xvsn branch from 49a3a98 to 594edf2 Compare November 16, 2026 21:13
Micah Yong (micahtyong) added a commit that referenced this pull request Nov 17, 2026
Merge #252's current head. Its Miles v0.2.0 image already includes the
Kimi K3 change, so the K3 recipe now uses trainer_image "miles-v0.2.0"
and the K3-only trainer image and the fork_image() helper are gone.
kimi_k3_image.py keeps only the sampler image.

Kimi K3 trains with megatron_to_hf_mode "raw", which Spindle only passes
to Miles, so miles-v0.2.0 no longer rejects it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread docs/deployment-configs.md Resolved

def _gather_capture(self, written: Path, path: Path) -> None:
"""Make every node's writes to a capture on the checkpoint volume visible here."""
if not on_checkpoint_volume(path):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this necessary to restore multi-node on 0.2.0 or why this change?


image = image_at(MILES_COMMIT)
# Beam on the Megatron Bridge (modal-projects/miles#37).
beam_image = image_at("3280b7a5e3c4399c1ac18bed568859c9068852c3")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just call this image_ or something? ideally this is just a linear list of commits on our shared 0.2.0 fork branch. mb add a comment about this. is image_020_0001_sha mb better? ff to rename the existing one to be consistent

revision="803bccbcb947d3041f5b57e11c986f8523a0cb56",
core_packages=CORE_SAMPLER_PACKAGES,
).add_local_python_source("spindle", ignore=ignore_config_source)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same naming thing as above

def on_checkpoint_volume(path: Path) -> bool:
"""Whether ``path`` lives on the checkpoint volume, where nodes see only committed writes."""
return (
"SPINDLE_CHECKPOINT_VOLUME" in os.environ

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does this relate to the existing _checkpoint_volume_path function? can we do something cleaner?

def run(args, batch_id, model, *batch_args, **kwargs):
rollout_data = batch_args[-1]
def run(args, batch_id, model, *slot_and_data, **kwargs):
# v0.2.0 passes adapter_slots before rollout_data; preserve both native arguments.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait this is very scary - can you do something more explicit here? like actually check the version and branch on that potentially?

self._bridge.save_slot(slot, path, include_optimizer=include_optimizer)
)
# Outside _run: a bad capture fails this request, not the shared trainer.
self._gather_capture(written, Path(path))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we adding this?

Fred Robinson (frrad) added a commit that referenced this pull request Nov 17, 2026
Reuse the stock Tinker workload with a pinned tokenizer and the existing
TP2/CP8 H200 topology. Keep the response cap at 2048 tokens; this is not a
256K-context validation. Record no execution until a GPU run exists.

Enable Miles v0.2.0 multi-node captures by committing each node's files
before coordinator reload and sharing the checkpoint I/O lock for
volume-backed captures, including their metadata writes. Local captures
keep their independent persistence path.

Adapt the generic backend changes from #252 commits 53f80f7, 594edf2 and
18054ed, with its owner's agreement. Leave Beam recipes and images out.
Fred Robinson (frrad) added a commit that referenced this pull request Nov 17, 2026
Reuse the stock Tinker workload with a pinned tokenizer and the existing
TP2/CP8 H200 topology. Keep the response cap at 2048 tokens; this is not a
256K-context validation. Record no execution until a GPU run exists.

Enable Miles v0.2.0 multi-node captures by committing each node's files
before coordinator reload and sharing the checkpoint I/O lock for
volume-backed captures, including their metadata writes. Local captures
keep their independent persistence path.

Adapt the generic backend changes from #252 commits 53f80f7, 594edf2 and
18054ed, with its owner's agreement. Leave Beam recipes and images out.
@frrad
Fred Robinson (frrad) force-pushed the bb/https-modal-com-slack-com-archives-d0ce0tq2f7f-p-thr_dbnae2xvsn branch from 18054ed to 96ba5c4 Compare November 17, 2026 23:53
@frrad
Fred Robinson (frrad) changed the base branch from main to reference-dapo-multinode November 17, 2026 23:53
@frrad
Fred Robinson (frrad) force-pushed the bb/https-modal-com-slack-com-archives-d0ce0tq2f7f-p-thr_dbnae2xvsn branch 6 times, most recently from c09c2f4 to e36bfcc Compare November 18, 2026 03:52
@frrad
Fred Robinson (frrad) force-pushed the bb/https-modal-com-slack-com-archives-d0ce0tq2f7f-p-thr_dbnae2xvsn branch 2 times, most recently from f7ed75a to b5140f9 Compare November 18, 2026 04:20
@frrad
Fred Robinson (frrad) force-pushed the bb/https-modal-com-slack-com-archives-d0ce0tq2f7f-p-thr_dbnae2xvsn branch from b5140f9 to 84163b1 Compare November 18, 2026 05:46

@micahtyong Micah Yong (micahtyong) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the PR body and some of the image names are a bit out of date with latest main, but otherwise LGTM

name = "beam-501b-a23b-lora-5k"
model = "reflection/Beam-1.0-501B-A23B"
weights_revision = "12950ae640b48cbbe9b5bb7735bf197507d6383f"
max_context_length = 5120

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very small context length. Can we serve up to 64k context? This can be a follow-up PR since this one is quite big now

Base automatically changed from reference-dapo-multinode to main November 18, 2026 20:03
@frrad
Fred Robinson (frrad) force-pushed the bb/https-modal-com-slack-com-archives-d0ce0tq2f7f-p-thr_dbnae2xvsn branch from 84163b1 to 45b534e Compare November 18, 2026 20:12
@frrad Fred Robinson (frrad) changed the title Add Beam BF16 LoRA support and a reference run Add a Beam BF16 LoRA recipe and a blog reproduction reference run Nov 18, 2026
Miles v0.1.1 and v0.2.0 put rollout_data at different positions in
run_forward_backward, because v0.2.0 adds adapter_slots before it. The
replay wrapper now binds each call to the wrapped function's own
signature and reads rollout_data by name, so positional and keyword
calls work on both versions. Installing the hooks fails at trainer
startup when that function has no rollout_data parameter.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
beam-501b-a23b-lora-5k trains reflection/Beam-1.0-501B-A23B with BF16
LoRA on two eight-H200 trainer nodes, with separate attention and MLP
gate targets and routing replay. It trains on miles-v0.2.0-8c5de26 and
samples on sglang-v0.5.23-e003cf9, which serves Beam LoRA.

reference_runs/configs/beam_blog_repro.toml selects that recipe and
scripts/beam_blog_repro.py, a stock-Tinker client that trains on
DAPO-Math, evaluates on AIME25 and can resume from checkpoints. The
index holds an earlier 42-update execution, converted to the catalog
output format, and the digitized curve from the published Beam LoRA
run, which records source instead of Spindle provenance.

catalog.py now defines the output format every reference script
writes (Record, Evaluation, Update and read_output), and tests check
every indexed output and each script's output against it. A Spindle
index entry needs its trainer image, Miles commit, Tinker SDK and
hardware; an external entry records only its source.

The Beam script and its tests are fully typed, without ANN ignores.
AGENTS.md and the ignore list say that list only shrinks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The test checked that /proc/PID/stat existed and then read it. When the
killed descendant disappeared between the two calls, the read raised
ProcessLookupError and the test failed, although the supervisor had
done its job.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A fresh two-node Miles v0.2.0 worker reading the shared Triton and
TorchInductor caches loaded a generated module filled with zeros and
failed its first forward_backward. qwen38-27b-lora-256k already sets
trainer-local caches for this; the Beam recipe now does the same.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The script ran training in a child process started from a fresh
interpreter. Patches the parent had installed were lost, including the
proxy headers that examples/shared-server/with_proxy_auth.py adds to
every ServiceClient, so a Beam run against a proxy-protected server
failed to authenticate. The worker is now forked and leads its own
session, so it keeps those patches and the supervisor can still stop
its whole process group at the deadline. The hidden --worker flag is
gone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@frrad
Fred Robinson (frrad) force-pushed the bb/https-modal-com-slack-com-archives-d0ce0tq2f7f-p-thr_dbnae2xvsn branch from 45b534e to 03c28c5 Compare November 18, 2026 23:00
@frrad
Fred Robinson (frrad) merged commit 58d64b2 into main Nov 18, 2026
3 checks passed
@frrad
Fred Robinson (frrad) deleted the bb/https-modal-com-slack-com-archives-d0ce0tq2f7f-p-thr_dbnae2xvsn branch November 18, 2026 23:04
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.

2 participants