Skip to content

[request path] Send forward requests through the binary training transport - #153

Merged
micahtyong merged 1 commit into
mainfrom
micah/perf-4b/O1-forward-binary
Oct 28, 2026
Merged

micahtyong merged 1 commit into
mainfrom
micah/perf-4b/O1-forward-binary

Conversation

@micahtyong

@micahtyong micahtyong commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Spindle serves two kinds of training requests. forward_backward runs the model forward and backward and accumulates gradients. forward (Tinker's forward_only=True) runs the model forward only, to score tokens without training. Both return the same payload: a log probability for every token and every candidate label in the batch.

A request travels through three hops: the SDK sends it to the frontend, the frontend hands it to the engine, and the engine calls the trainer. The result comes back along the same path. In #42, forward_backward got a binary transport for this trip, with results encoded as protobuf. forward never did. Its request went to the trainer as JSON, its result came back as JSON through the engine and the frontend, and only then did the frontend re-encode it as protobuf for the SDK. For a batch of 128 examples with 5 labels per position that result is about a million floats. As JSON, where every float is written out as text and parsed twice, that is about 20 MB per call. As protobuf it is 4 MB.

This change gives forward the same binary transport and protobuf results that forward_backward has. Two smaller things come with it:

  • The engine batches queued forwards the way it already batches forward_backward. The SDK splits a large forward into chunks; those chunks now run as one trainer call instead of several. Forwards never share a call with forward_backward, because the two need different GPU work.
  • If a shared forward call fails, the engine reruns each request on its own. One client's bad input then fails only that client's request.

E2E results

Same setup as #152: a 4B LoRA classifier on 4×H100; each step runs two forward calls, one forward_backward, then optim_step, one after another; 128 examples of about 1,631 tokens with 5 candidate labels per position; 16 steady-state steps. Step-0 log probabilities are bit-identical before and after.

Before WandB / After WandB

Median per step Before After
Time outside the trainer 8.95 s 5.67 s
One forward: encode the result and send it trainer → engine 0.63 s 0.11 s
One forward: engine → frontend 0.97 s 0.03 s

🤖 Generated with Claude Code

@micahtyong
micahtyong force-pushed the micah/perf-4b/O1-forward-binary branch from 40963a8 to 17a8df7 Compare October 28, 2026 16:28
@micahtyong
micahtyong marked this pull request as ready for review October 28, 2026 21:36
@micahtyong
micahtyong added this pull request to stack #162 October 28, 2026 21:37
@micahtyong
micahtyong force-pushed the micah/perf-4b/O1-forward-binary branch from 17a8df7 to 0d60783 Compare October 28, 2026 21:43
@micahtyong
micahtyong force-pushed the micah/perf-4b/O1-forward-binary branch from 0d60783 to 3291eae Compare October 28, 2026 21:48
@micahtyong
micahtyong force-pushed the micah/perf-4b/O1-forward-binary branch from 3291eae to df48366 Compare October 28, 2026 21:49
@micahtyong
micahtyong force-pushed the micah/perf-4b/O1-forward-binary branch 2 times, most recently from f2d664b to 6680c76 Compare October 28, 2026 21:54
Base automatically changed from micah/perf-4b/O0-frontend-region to main October 28, 2026 21:54
Forward requests used the JSON executor path: the engine serialized every
token and label to JSON for the backend, and the result came back as JSON
through the engine and frontend before being re-encoded as protobuf. Route
them through the same binary batch transport and protobuf results as
forward_backward, and batch queued forward requests together.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@micahtyong
micahtyong force-pushed the micah/perf-4b/O1-forward-binary branch from 6680c76 to dd28703 Compare October 28, 2026 21:54
@micahtyong
micahtyong merged commit c837665 into main Oct 28, 2026
4 checks passed
@micahtyong
micahtyong deleted the micah/perf-4b/O1-forward-binary branch October 28, 2026 21:57
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