story: DGR-035 Implement dense architecture boundary input/output
This commit is contained in:
@@ -14,7 +14,7 @@ from meshnet_node.architecture_boundary import (
|
||||
TailOutput,
|
||||
adapter_for,
|
||||
)
|
||||
from meshnet_node.native_protocol import ProtocolError, decode_bundle
|
||||
from meshnet_node.native_protocol import ProtocolError, decode_bundle, encode_bundle, encode_tensor, pb
|
||||
|
||||
|
||||
def _f32(values: list[float]) -> bytes:
|
||||
@@ -119,3 +119,29 @@ def test_typed_tail_result_binds_sampling_and_request_recipe_identity() -> None:
|
||||
assert result.sampled_token_id == 42
|
||||
assert result.output_kind == "sampled_token_id"
|
||||
assert result.message.WhichOneof("output") == "sampled_token_id"
|
||||
|
||||
|
||||
def test_typed_tail_result_accepts_validated_logits_under_the_explicit_contract() -> None:
|
||||
adapter = adapter_for(Architecture.DENSE)
|
||||
identity = ProtocolIdentity(
|
||||
request_id="request-1",
|
||||
runtime_recipe_digest="sha256:recipe",
|
||||
chat_template_id="llama3",
|
||||
chat_template_version="2",
|
||||
reasoning_mode="max",
|
||||
architecture=Architecture.DENSE,
|
||||
)
|
||||
logits = encode_bundle(
|
||||
[encode_tensor("logits", _f32([0.1, 0.9]), [1, 2], pb.DTYPE_FLOAT32)],
|
||||
architecture=adapter.protocol_architecture,
|
||||
boundary_point="dense.tail.logits.v1",
|
||||
)
|
||||
|
||||
result = adapter.tail_result(
|
||||
identity=identity,
|
||||
sampling=SamplingParameters(temperature=0.7, top_p=0.9, top_k=20, seed=9),
|
||||
output=TailOutput.logits(logits),
|
||||
)
|
||||
|
||||
assert result.output_kind == "logits"
|
||||
assert result.message.WhichOneof("output") == "logits"
|
||||
|
||||
Reference in New Issue
Block a user