standardized_vllm¶
standardized_vllm
¶
StandardizedVLLM: nnsight's VLLM engine renamed to the standard vocabulary.
StandardizedVLLM
¶
StandardizedVLLM(repo_id: str, *args: Any, family: ModuleType | None = None, rename: dict[str, str | list[str]] | None = None, envoys: dict | None = None, **kwargs: Any)
Bases: Standardized, VLLM
A causal language model on the vLLM engine whose modules answer to the standard names.
StandardizedTransformer's counterpart for nnsight's VLLM: the same
vocabulary (model.layers[i].self_attn, .mlp, model.norm,
model.lm_head), the same values with the same layouts, and the same
methods, over the engine's continuous batching. The family is vLLM's own
implementation of the checkpoint's model_type, a module under
nnterp.families.vllm.
It is nnsight's VLLM otherwise, with vLLM's defaults: a trace is a
generation request (max_tokens=16 and temperature=1.0 unless you
say), sampling settings go on trace/invoke, one prompt per invoke,
and a block runs in the engine's worker, where nnterp has to be importable.
What that changes for the values:
- A request is one sequence, so every value's batch axis is 1:
layer_outputis[1, tokens, hidden_size], the whole prompt on the prefill and one token on each decode step (tracer.iter). logitsis this step's,[1, 1, vocab_size]: the engine computes the last position only.logits[:, -1]andnext_token_probsread the same on both engines.- Values are private copies, so a saved one stays what it was read as.
- The queries, keys, values and head outputs are what goes into and
comes out of the engine's attention layer, for this step's tokens. The
scores and the pattern are inside its kernel, so they are recomputed
from the queries and keys: read-only, and on the prefill only (a decode
step raises
Unavailable). There is noattention_mask. project_on_vocabruns the engine's modules, so it works inside a trace only.
| PARAMETER | DESCRIPTION |
|---|---|
repo_id
|
A HuggingFace repo id.
TYPE:
|
family
|
The family to use instead of the one looked up: a module or
any object with
TYPE:
|
rename
|
Extra aliases, merged over the family's; a key given here wins.
TYPE:
|
envoys
|
Extra
TYPE:
|
**kwargs
|
Passed through to
TYPE:
|
| ATTRIBUTE | DESCRIPTION |
|---|---|
family |
The vLLM family the checkpoint resolved to, or the
|
| RAISES | DESCRIPTION |
|---|---|
UnsupportedFamily
|
when no family is passed and vLLM's implementation
of the checkpoint's |
lm_head_output
class-attribute
instance-attribute
¶
lm_head_output = unavailable("vLLM never calls lm_head: its logits processor projects with lm_head's weight and applies any softcap and scale in the same call, on the last position only; read logits")
attention_mask
class-attribute
instance-attribute
¶
attention_mask = unavailable('a vLLM request is one unpadded sequence; there is no mask')
token_embeddings
¶
token_embeddings(value: Tensor) -> Residual
The embedding module's output, [1, tokens, hidden_size]; what a family scales or adds positions to comes after.
final_norm_output
¶
final_norm_output(value: Tensor) -> Residual
The final norm's output, [1, tokens, hidden_size]: every position of the step, of which the engine projects the last.
A family whose blocks hand the stream on in two halves calls the final
norm with both, and the norm returns (normed, residual): this is
the normed half. Assign to replace it; in-place edits reach the model.
project_on_vocab
¶
Logits for a residual-stream tensor: the final norm, lm_head, and vLLM's logits processor.
The logit lens, inside a trace: the modules are the engine's, so there
is nothing to call outside one. The processor applies the model's
softcapping and scaling where it has them. hidden is [...,
hidden]; the leading dimensions are kept. A family whose model
projects another way defines def project_on_vocab(model, hidden)
in its module.
order
¶
Not supported on the vllm engine: the forward order is measured on StandardizedTransformer only.
rank
¶
Not supported on the vllm engine: the forward order is measured on StandardizedTransformer only.