feat: implement DGR-006 tensor bundle boundary

This commit is contained in:
Dobromir Popov
2026-07-14 13:44:37 +03:00
parent 91c450840d
commit 7925e5253d
16 changed files with 802 additions and 94 deletions

View File

@@ -33,6 +33,16 @@ enum SchemaVersion {
SCHEMA_VERSION_1 = 1;
}
// Certified transformer boundary family. Names alone are not an adapter: a
// Node must select an explicit architecture contract before interpreting a
// TensorBundle.
enum ArchitectureType {
ARCHITECTURE_TYPE_UNSPECIFIED = 0;
ARCHITECTURE_TYPE_DENSE = 1;
ARCHITECTURE_TYPE_MOE = 2;
ARCHITECTURE_TYPE_MLA = 3;
}
// ---------------------------------------------------------------------------
// Tensor bundle — the public activation boundary
// ---------------------------------------------------------------------------
@@ -142,6 +152,11 @@ message TensorBundle {
// boundary payload can evolve without a whole-protocol version bump.
uint32 bundle_version = 1;
repeated NamedTensor tensors = 2;
// Explicit adapter selection; names are never interpreted through unchecked
// substitutions. UNSPECIFIED is accepted only for legacy DGR-002 bundles.
ArchitectureType architecture = 3;
// Adapter-owned semantic boundary, such as "pre_tail_residual".
string boundary_point = 4;
}
// ---------------------------------------------------------------------------
@@ -393,8 +408,9 @@ message ActivationChunk {
// A decode step is one token: the envelope's identity fields are already fixed
// for the life of the stream, so repeating them per token is pure overhead on
// the hottest path. A DecodeStep carries only what changes — the step, the
// position, and one tensor — and inherits the rest from the SessionOpen
// handshake. A peer may always fall back to ActivationChunk with PHASE_DECODE.
// position, and one compact boundary encoding — and inherits the rest from the
// SessionOpen handshake. A Node may always fall back to ActivationChunk with
// PHASE_DECODE.
message DecodeStep {
// Idempotency step within the session; also orders the stream.
uint64 idempotency_step = 1;
@@ -402,11 +418,50 @@ message DecodeStep {
uint64 position = 2;
// Tokens the receiver's cache must already hold. A mismatch is a CACHE_MISS.
uint64 expected_past_len = 3;
// The single boundary tensor for this token, typically [1, 1, hidden].
// Legacy compact one-tensor boundary, typically [1, 1, hidden]. New readers
// accept it as a TensorBundle with one member; writers retain it where the
// selected architecture genuinely requires only one tensor.
NamedTensor tensor = 4;
// Work id for attribution; the session/epoch/fingerprint/range are inherited.
string work_id = 5;
int64 deadline_unix_nanos = 6;
// Versioned architecture boundary. This carries sidebands such as MoE router
// state or MLA/IndexShare state; when both fields are set, bundle is
// authoritative and tensor is retained only for older-Node forwarding.
TensorBundle bundle = 7;
}
// Exact request-level identity for a tail result. Runtime recipe identity is
// deliberately repeated here: sampling the right logits with the wrong chat
// template or reasoning mode is a different request, not a compatible result.
message RequestRecipeIdentity {
string request_id = 1;
string runtime_recipe_digest = 2;
string chat_template_id = 3;
string chat_template_version = 4;
string reasoning_mode = 5;
ArchitectureType architecture = 6;
}
// Sampling is an explicit tail-only operation. A non-tail Shard never applies
// final norm, LM head, row pruning, or sampling to its boundary output.
message SamplingParameters {
float temperature = 1;
float top_p = 2;
uint32 top_k = 3;
uint64 seed = 4;
bool greedy = 5;
}
// Typed tail completion. The oneof keeps token id 0 unambiguous and prevents a
// caller from treating an activation tensor as an inferred completion.
message TailResult {
RequestRecipeIdentity identity = 1;
SamplingParameters sampling = 2;
oneof output {
TensorBundle logits = 3;
uint32 sampled_token_id = 4;
}
}
// Drop session state for a Route Session. Bounded memory does not depend on
@@ -471,7 +526,8 @@ message SessionResponse {
ActivationChunk chunk = 2;
Ack ack = 3;
FlowControl flow_control = 4;
ShardStatus status = 5;
ShardStatus status = 5;
TailResult tail_result = 6;
}
}