nemo_automodel.components.speculative.eagle.remote.server
nemo_automodel.components.speculative.eagle.remote.server
Remote EAGLE-3 target server.
Runs the frozen target model and, for each training request, produces the
draft-vocab supervision (aux hidden states, target_probs, position_mask)
and ships it back to the training client. The supervision computation reuses the
co-located building blocks verbatim — HFEagle3TargetModel.generate_batch
for the forward + aux capture and _compute_target_distribution for the
draft-vocab projection — so a remote run is numerically identical to a
co-located one.
The HTTP request handling is split from the http.server plumbing
(TargetModelServer holds the pure logic) so it can be unit-tested on
CPU with the NCCL data plane disabled (wire-format path).
Module Contents
Classes
Functions
Data
API
Request-handling logic for the remote target server (HTTP-transport agnostic).
Subclasses serve other draft algorithms over the same transport by overriding
_supervise, handle_model_info, and, for extra endpoints,
post_routes.
Parameters:
A loaded HFEagle3TargetModel (or any object exposing the same
generate_batch / get_input_embeddings surface).
TCP rendezvous port for the NCCL data plane.
Bind/advertise address (rendezvous master for NCCL).
Serialize one full weight as a {"weight": ...} wire blob.
Parameters:
Tensor of shape [vocab, hidden], either a plain tensor or a sharded DTensor that is gathered to the full tensor first.
Returns: bytes
Wire bytes holding the full weight on CPU.
Run the target on one decoded request and return its supervision tensors.
Parameters:
Request tensors on the server device: input_ids,
attention_mask and loss_mask, each of shape [batch, sequence].
Returns: dict[str, torch.Tensor]
Tensors in the order they are sent over NCCL: aux_hidden_states of shape
Send the pending supervision tensors over NCCL (after the HTTP flush).
Run the target and serialize the supervision.
Returns (body, used_nccl). When NCCL is used the body is the JSON
metadata only and the tensors are queued for flush_nccl_send
(sent after the HTTP response is flushed, to avoid a recv deadlock).
Return the target input-embedding weight (used once to seed the draft).
Return the POST endpoints other than /generate.
Returns: dict[str, tuple[Callable[[bytes], bytes], str]]
Mapping from endpoint name to (handler, content_type). /generate
Produce the precomputed draft-vocab supervision for one batch.
Mirrors the co-located path exactly: generate_batch runs the target and
returns shifted logits / input_ids / loss_mask plus the aux hidden states;
_compute_target_distribution then projects the shifted logits onto the
draft vocab. Returns the tensors in the order they are sent over NCCL.
Run the blocking HTTP server until the client disconnects or Ctrl-C.