Skip to content

[Protocol]: Add portable non-generative inference task RPCs #10

Closed

Description

@connorcarpenter15

Existing proposals

  • I searched the existing issues and did not find this proposal.

Intended consumers

Both direct engine clients and distributed frameworks.

Problem and use case

OpenEngine.Generate can only return autoregressive generation events. It cannot represent embeddings, classification outputs, or model-native pairwise scores.

Consequently, Dynamo, llm-d, SGLang Model Gateway (SMG), and direct clients must use engine-specific APIs or HTTP fallbacks for common non-generative workloads. This prevents OpenEngine from being a comprehensive engine boundary and prevents a scheduler from discovering and routing these tasks uniformly.

Reranking does not require a separate engine primitive. It is deterministic composition over scoring: score one query against multiple candidates, stable-sort the results, apply an optional limit, and project the original candidate metadata. Gateways and clients already own the documents and should perform that response shaping.

Evidence from engine protocols

  • SGLang's native gRPC service exposes typed TextEmbed, Embed, and Classify RPCs. Its Score and Rerank methods are OpenAI-compatible JSON pass-through RPCs rather than typed native task messages.
  • SGLang's engine-level scoring supports causal-model label-token probabilities and sequence-classification/reward outputs. Its rerank handler adapts to scoring, embedding, or generation, then sorts, limits, and optionally echoes documents.
  • vLLM pooling models support pooled/token embeddings, classification, reward, and scoring. Score and Rerank share one serving implementation; rerank differs in request/response shaping, sorting, and top_n.
  • TensorRT-LLM exposes an encode path for encoder, classifier, and reward-model outputs and supports grouped multi-item scoring inputs.
  • SMG's worker contracts expose Embed for SGLang, vLLM, and TensorRT-LLM. Gateway-facing rerank compatibility can be implemented over OpenEngine scoring.

Proposed contract

Add three typed unary methods to the existing service:

service OpenEngine {
  rpc Embed(EmbedRequest) returns (EmbedResponse);
  rpc Classify(ClassifyRequest) returns (ClassifyResponse);
  rpc Score(ScoreRequest) returns (ScoreResponse);
}

The contract should provide:

  • a common request context for model, request ID, metadata, priority, and adapter selection;
  • text and token-ID task inputs with stable caller-provided item IDs;
  • pooled and token-level dense embedding outputs with explicit shape;
  • sequence and token-level classification outputs;
  • explicit output semantics such as logits, probabilities, log probabilities, similarity, relevance, reward, or model-defined scores;
  • grouped query + repeated candidates scoring, plus explicit pairwise batching where portable;
  • optional label-token scoring for causal models;
  • stable group/candidate correlation and responses in input order;
  • usage metadata and deterministic validation/error behavior.

Rerank is deliberately not an OpenEngine RPC. A gateway implements it as:

  1. call Score with one query and the candidate list;
  2. stable-sort by the advertised score direction, breaking ties by original index;
  3. apply top_n if requested;
  4. attach or omit the documents according to the external API.

A server-side result limit may be added later as a capability-gated optimization, but it must not become a separate inference capability.

Presence, defaults, and validation

  • request_id and model are required and non-empty.
  • Every task item sets exactly one input representation.
  • Item, group, and candidate IDs are non-empty and unique within their scope.
  • Empty batches and malformed pair/group shapes are invalid.
  • Embedding and task-output shapes agree with the flattened value count and all values are finite.
  • Classification and scoring identify their value semantics, normalization, granularity, and whether larger values are better.
  • Label-token scoring preserves the requested token order and rejects unsupported normalization.
  • Score responses preserve request group/candidate order; the engine does not sort or echo source documents.
  • Unsupported modalities, granularities, pairing modes, and options are rejected rather than silently coerced.
  • Batch atomicity and any partial per-item failure behavior are specified explicitly.

Request and response lifecycle

These RPCs are unary. Acceptance means the complete request was validated and admitted; a successful response is terminal. gRPC cancellation cancels queued or running work, and request IDs integrate with existing Abort behavior. Validation, unsupported-task, admission, and execution failures remain distinguishable.

Discovery and capability impact

Model discovery advertises support for embed, classify, and score independently, including:

  • supported input representations and modalities;
  • pooled versus token-level output;
  • dtype/dimension where fixed;
  • supported classification/scoring semantics and normalization;
  • score pairing modes and label-token scoring;
  • batch, group, candidate, and tensor limits.

A model may support any subset independently of generation. Lack of a task capability is not inferred from the engine name or model architecture.

Alternatives considered

  • Reuse Generate: generation events cannot safely represent tensors, labels, or model-native pair scores.
  • Return google.protobuf.Struct or OpenAI JSON: loses portable validation and generated-client type safety.
  • Add only Embed: insufficient for current vLLM, SGLang, and TensorRT-LLM classifier/reward/scoring paths.
  • Add a distinct Rerank RPC: duplicates Score execution and moves gateway-owned sorting, limiting, and document projection into the engine contract.
  • Add one generic Infer RPC: too weakly typed for the common tasks already shared across engines.

Out of scope

RAG orchestration, document storage, chat templates, OpenAI/Cohere/Jina endpoint compatibility, gateway response shaping, and requiring every engine/model to implement every task.

Proposal checklist

  • The behavior is portable and does not expose one engine's internal scheduler model as the common API.
  • I have identified the corresponding documentation changes.
  • Keep Score and define reranking as a derived gateway/client operation.
  • Add typed RPCs/messages for embed, classify, and score.
  • Add task capability discovery to model metadata.
  • Document batching, score semantics, cancellation, errors, and usage.
  • Add conformance examples for text/token inputs and all three target engines.
  • Update docs/api.md and generated package documentation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions