Skip to content
Open
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
8e596e9
[ATOM gRPC] Engine: token-id prompts reuse block-hash chains; an idle…
Jasen2201 Nov 21, 2026
a352312
[ATOM gRPC] The atom.grpc.v1 service: proto, generated modules, info,…
Jasen2201 Nov 21, 2026
6cb9d26
[ATOM gRPC] Generate: kv_transfer-only prompts, structured-output 500…
Jasen2201 Nov 22, 2026
207f47a
[ATOM gRPC] Abort reaches a Generate call before its submission
Jasen2201 Nov 22, 2026
20c9edb
[ATOM gRPC] Refuse named chat templates under --grpc-port; PrepareStr…
Jasen2201 Nov 22, 2026
c991bec
[ATOM gRPC] Install the gRPC step flush before the listener starts
Jasen2201 Nov 22, 2026
6201e41
TokenPrefixChains: an extension too large to store keeps the prompt i…
Jasen2201 Nov 22, 2026
e8244ee
PP head: an idle loop waits for input
Jasen2201 Nov 22, 2026
b707277
tests: drop the dcp_ops stub the BlockManager no longer imports
Jasen2201 Nov 22, 2026
c642e7b
[ATOM gRPC] Drain the gRPC server before the engine closes
Jasen2201 Nov 22, 2026
54dc67b
[ATOM gRPC] End gRPC calls at shutdown instead of draining them
Jasen2201 Nov 22, 2026
78c76f8
[ATOM gRPC] Admit Generate requests past 4 MiB; keep a stream's token…
Jasen2201 Nov 22, 2026
936bf9f
[ATOM gRPC] Stop the gRPC server on its own loop's main task
Jasen2201 Nov 23, 2026
49810d0
[ATOM gRPC] Test that Generate refuses stop ids with a response schema
Jasen2201 Nov 23, 2026
035c7e4
tests: pin the too-large-extension guard and the idle wait's clear-fi…
Jasen2201 Nov 23, 2026
b742f0d
TokenPrefixChains: rehash a reuse when reuse turns off before it fini…
Jasen2201 Nov 23, 2026
7559ca4
Merge the engine prefix chains and idle wait (#3672) into the proto a…
Jasen2201 Nov 23, 2026
a4a6492
GetServerInfo: carry the body of /kv_event_sources
Jasen2201 Nov 23, 2026
3a3c2f2
tests: stop ids given to preprocess reach the seq, and the stop strin…
Jasen2201 Nov 23, 2026
8a0349d
Merge main into the engine changes
Jasen2201 Nov 23, 2026
c948721
Merge main into the proto and ATOM gRPC server
Jasen2201 Nov 23, 2026
e6f2716
gRPC GetModelInfo names atomesh's tool-call and reasoning parsers
Jasen2201 Nov 23, 2026
88aac79
gRPC Generate carries the DP session-affinity ids
Jasen2201 Nov 23, 2026
27f6c43
gRPC GenerateComplete carries ttft_s, tpot_s and latency_s
Jasen2201 Nov 23, 2026
7e9384f
gRPC Generate serves unstreamed n above 1, one complete per sibling
Jasen2201 Nov 23, 2026
4d812bf
gRPC Generate aborts every sibling a failed submission dispatched
Jasen2201 Nov 23, 2026
c7190fd
gRPC Generate times each output as the engine delivers it
Jasen2201 Nov 23, 2026
83d83c1
gRPC GetModelInfo says where a streamed chat's usage goes
Jasen2201 Nov 23, 2026
4f59f0e
gRPC GetModelInfo says when a reply starts in reasoning without an op…
Jasen2201 Nov 23, 2026
24015e0
Merge main into the engine's prefix chains and idle wait
Jasen2201 Nov 23, 2026
ff12602
Merge the engine's prefix chains and idle wait into the proto and ATO…
Jasen2201 Nov 23, 2026
b36017a
Give the engine's new test files the full source header
Jasen2201 Nov 23, 2026
7cd42cc
Merge the engine's full test headers into the proto and server
Jasen2201 Nov 23, 2026
881c07d
Give the proto, the server and their generated modules the full sourc…
Jasen2201 Nov 23, 2026
230de15
CoreManager refuses a bad rank hint before registering callbacks
Jasen2201 Nov 23, 2026
83673de
CoreManager drops the callbacks of seqs a failed send never delivered
Jasen2201 Nov 23, 2026
51402a6
Merge main into the engine's prefix chains and idle wait
Jasen2201 Nov 24, 2026
7f77c64
Merge the engine's merge of main into the atom.grpc.v1 service
Jasen2201 Nov 24, 2026
c4da343
A Generate cancelled twice settles its structured submission first
Jasen2201 Nov 24, 2026
d0496ea
Merge main into the engine's prefix chains and idle wait
Jasen2201 Nov 24, 2026
5108e84
Merge the engine's merge of main into the atom.grpc.v1 service
Jasen2201 Nov 24, 2026
59121a7
A token-id prompt skips the prefix chain store when reuse is off
Jasen2201 Nov 26, 2026
3db668f
Merge the engine's skip of a turned-off prefix chain store into the A…
Jasen2201 Nov 26, 2026
5a5ee19
Merge main into the proto and ATOM gRPC server
Jasen2201 Nov 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions atom/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1494,11 +1494,6 @@ def _resolve_synthetic_acceptance(self) -> None:
form is converted to a length and everything downstream reads only
``synthetic_acceptance_rates``.
"""
# Local import: the schedule lives next to the kernel that consumes it,
# and that module pulls in triton, which has no business loading just
# because someone imported a config.
from atom.model_ops.rejection_sampler import acceptance_length_to_rates

if (
self.synthetic_acceptance_length is not None
and self.synthetic_acceptance_rate is not None
Expand All @@ -1510,6 +1505,9 @@ def _resolve_synthetic_acceptance(self) -> None:
length = self.synthetic_acceptance_length
if self.synthetic_acceptance_rate is None and length is None:
return
# Below the return: the rejection sampler pulls in triton, which a config
# without forced acceptance has no business loading.
from atom.model_ops.rejection_sampler import acceptance_length_to_rates

n = self.num_speculative_tokens
if not n:
Expand Down
33 changes: 31 additions & 2 deletions atom/distributed/dcp_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@

"""DCP token-ownership arithmetic shared by attention and KV transfer.

These helpers are pure ``//`` / ``%`` so they stay elementwise over Python
ints, numpy arrays, and torch tensors. They live outside ``dcp_ops`` so P/D
These helpers are ``//``, ``%`` and ``np.clip``, so they stay elementwise over
Python ints, numpy arrays, and torch tensors. They live outside ``dcp_ops`` so P/D
relayout can follow the same rule without importing Triton or aiter.
"""

import numpy as np


def dcp_owner_rank(pos, dcp_size, cp_kv_cache_interleave_size=1):
"""Which DCP rank owns global token ``pos`` under interleaved KV storage.
Expand Down Expand Up @@ -44,3 +46,30 @@ def dcp_global_pos(local_index, dcp_rank, dcp_size, cp_kv_cache_interleave_size=
return (
(local_index // cp_kv_cache_interleave_size) * dcp_size + dcp_rank
) * cp_kv_cache_interleave_size + (local_index % cp_kv_cache_interleave_size)


def get_dcp_local_seq_lens(seq_lens, dcp_size, dcp_rank, cp_kv_cache_interleave_size=1):
"""Compute per-DCP-rank local sequence lengths.

With interleaved storage, token i is stored on rank
(i // cp_kv_cache_interleave_size) % dcp_size.

Args:
seq_lens: numpy array of sequence lengths
dcp_size: DCP world size
dcp_rank: this rank's DCP rank
cp_kv_cache_interleave_size: interleaving granularity (default 1 = token-level)

Returns:
local_seq_lens: numpy array of local sequence lengths
"""
full_chunks = seq_lens // (cp_kv_cache_interleave_size * dcp_size)
base = full_chunks * cp_kv_cache_interleave_size

remainder_total = seq_lens - base * dcp_size
remainder = np.clip(
remainder_total - dcp_rank * cp_kv_cache_interleave_size,
0,
cp_kv_cache_interleave_size,
)
return base + remainder
182 changes: 182 additions & 0 deletions atom/entrypoints/grpc/atom_grpc.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
// SPDX-License-Identifier: MIT
// Copyright (C) 2026, Advanced Micro Devices, Inc. All rights reserved.

// After editing, rewrite the Python modules: python -m atom.entrypoints.grpc.generate

syntax = "proto3";

package atom.grpc.v1;

import "atom/model_engine/zmq_protocol/engine_v1.proto";

// ATOM's own gRPC service, beside its HTTP server: token ids in, token ids out.
service AtomEngine {
// Streaming: one chunk per engine step, then a complete. Not streaming: one
// complete. An error, when there is one, is the last message.
rpc Generate(GenerateRequest) returns (stream GenerateResponse);
// An unknown or finished request_id is not an error.
rpc Abort(AbortRequest) returns (AbortResponse);
rpc GetModelInfo(GetModelInfoRequest) returns (GetModelInfoResponse);
rpc GetServerInfo(GetServerInfoRequest) returns (GetServerInfoResponse);
rpc HealthCheck(HealthCheckRequest) returns (HealthCheckResponse);
// Many requests on one stream: each Frames is one engine_v1 message.
rpc Session(stream Frames) returns (stream Frames);
// The structured-output fields of a chat sent over the Session, derived as the
// HTTP chat route derives them; the request's SamplingParams takes them.
rpc PrepareStructuredOutput(PrepareStructuredOutputRequest)
returns (PrepareStructuredOutputResponse);
}

// The version GetServerInfo reports; a client refuses a server with another.
// A change an older peer could misread bumps CURRENT.
enum ProtocolVersion {
PROTOCOL_VERSION_UNSPECIFIED = 0;
PROTOCOL_VERSION_CURRENT = 1;
}

message GenerateRequest {
string request_id = 1;
repeated uint32 prompt_token_ids = 2;
// Read as the HTTP routes read a request: an absent max_tokens takes their
// default, not SamplingParams'. Its stop_strings are not read (the stops are
// stop_token_sequences); logprobs and the structured-output fields are refused.
atom.engine.v1.SamplingParams sampling = 3;
repeated atom.engine.v1.TokenIds stop_token_sequences = 4; // the stop strings, tokenized
optional string kv_transfer_params_json = 5; // the HTTP routes' kv_transfer_params
optional int32 data_parallel_rank = 6;
bool stream = 7;
StructuredOutput structured_output = 8; // absent: no chat-level input, as on /v1/completions
// Session affinity, as the HTTP routes read it from x-dynamo-session-id,
// x-session-id or x-correlation-id, and x-dynamo-parent-session-id; the engine
// reads them only under ATOM_DP_SESSION_AFFINITY.
optional string dp_session_id = 9;
optional string dp_parent_session_id = 10;
}

// What ATOM's HTTP chat route derives a chat request's structured output from,
// for a prompt the client rendered.
message StructuredOutput {
optional string tools_json = 1; // the top-level tools
optional string tool_choice_json = 2; // a JSON string or object
optional string response_format_json = 3;
string chat_template_kwargs_json = 4; // the merged kwargs the prompt was rendered with
bool prompt_opens_reasoning = 5; // the prompt ends in one of reasoning_open_markers
// One item per chat message: the tools it declares (Kimi-K3's dynamic tools),
// or null. Absent when no message declares any.
optional string message_tools_json = 6;
}

message GenerateResponse {
oneof response {
GenerateStreamChunk chunk = 1;
GenerateComplete complete = 2;
GenerateError error = 3;
}
}

message GenerateStreamChunk {
repeated uint32 token_ids = 1; // this engine step's ids, every id of an MTP step
uint32 prompt_tokens = 2;
uint32 completion_tokens = 3; // so far, this step's included
uint32 cached_tokens = 4; // the prefix-cache hit, as the HTTP usage reports it
}

message GenerateComplete {
repeated uint32 output_ids = 1; // every output id, on a non-streaming call only
// The engine's own reason, such as stop_<token id>; the HTTP routes map it
// with atom.entrypoints.openai.protocol.openai_stop_reason.
string finish_reason = 2;
uint32 prompt_tokens = 3;
uint32 completion_tokens = 4;
uint32 cached_tokens = 5;
optional string kv_transfer_params_json = 6; // the engine's output kv_transfer_params
// In seconds, as the HTTP usage reports them: from Generate's arrival to the
// first output id and to this complete, and per output id after the first.
double ttft_s = 7;
double tpot_s = 8;
double latency_s = 9;
// Which sibling this answers, below the request's n. An n above 1 that greedy
// sampling leaves standing (it collapses to 1, as on HTTP) is served unstreamed
// and without kv_transfer_params: one complete per sibling, as each ends.
uint32 index = 10;
}

message GenerateError {
string message = 1;
uint32 http_status = 2; // the status the HTTP routes answer the same request with
}

message AbortRequest {
string request_id = 1;
}

message AbortResponse {}

message GetModelInfoRequest {}

message GetModelInfoResponse {
string model_path = 1;
string tokenizer_path = 2;
string served_model_name = 3;
uint32 max_context_length = 4;
repeated uint32 eos_token_ids = 5;
// As --chat-template left it; absent: none. One template: --grpc-port refuses
// a tokenizer with named ones.
optional string chat_template = 6;
string default_chat_template_kwargs_json = 7; // --default-chat-template-kwargs, a JSON object
// A rendered prompt ending in one of these, trailing whitespace aside, opens
// a reasoning channel.
repeated string reasoning_open_markers = 8;
// atomesh's parsers for this model's tool-call and reasoning formats, named by
// server.py's router_parser_names; absent: atomesh's model-name mapping chooses.
optional string tool_call_parser = 9;
optional string reasoning_parser = 10;
// A streamed chat's usage rides on its finish chunk, and include_usage adds
// "usage": null to the chunks before it; false: a usage-only chunk ends every
// stream. APICompatibility.usage_on_finish, which the model's encoder selects.
bool usage_on_finish = 11;
// The opener a reply starts after though the prompt does not end on it: the
// dialect's prompt opener, for a template that closes a reasoning block it never
// opens (DeepSeek-R1's); absent: none. Off where reasoning_toggle_json's kwarg
// holds its off value, as api_server.reasoning_channel decides.
optional string implicit_reasoning_opener = 12;
string reasoning_toggle_json = 13; // [kwarg, off value, on value]; empty: none
}

message GetServerInfoRequest {}

message GetServerInfoResponse {
uint32 protocol_version = 1; // ProtocolVersion.PROTOCOL_VERSION_CURRENT
string kv_transfer_info_json = 2; // the body of /kv_transfer_info
string server_info_json = 3; // the body of /server_info
string kv_event_sources_json = 4; // the body of /kv_event_sources
}

message HealthCheckRequest {}

message HealthCheckResponse {
bool healthy = 1; // false exactly when /health answers 503
string message = 2; // why not, as /health's 503 detail says
}

// One engine_v1 message: frame 0 its Envelope, then the data frames its
// BufferRefs point into.
message Frames {
repeated bytes frames = 1;
}

// The chat's StructuredOutput and the request fields the chat route also reads,
// each as GenerateRequest's field of the same name carries it.
message PrepareStructuredOutputRequest {
StructuredOutput structured_output = 1;
atom.engine.v1.SamplingParams sampling = 2;
repeated atom.engine.v1.TokenIds stop_token_sequences = 3;
optional string kv_transfer_params_json = 4;
}

message PrepareStructuredOutputResponse {
oneof response {
atom.engine.v1.SamplingParams sampling = 1; // only the fields the chat route derives
GenerateError error = 2;
}
}
73 changes: 73 additions & 0 deletions atom/entrypoints/grpc/atom_grpc_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading