Repository navigation
Conversation
… gRPC Without a runtime flag atomesh probes a gRPC worker as SGLang, then vLLM, then ATOM, and an ATOM worker registers with the labels GetModelInfo returns: model and tokenizer paths, served name, context length, EOS ids, chat template, default template kwargs and reasoning markers. The tokenizer job renders an ATOM chat with the label's template when no flag names one, and merges the default template kwargs under the request's own; a server of another protocol version is refused without retries. With `--dp-aware`, `get_dp_info` asks an ATOM gRPC worker's GetServerInfo for its DP size and model id, chosen by the same `determine_runtime_type` worker creation uses; HTTP workers keep `/server_info`. `BasicWorker::get_grpc_client` strips a worker's `@rank` suffix before connecting, which fixes rank workers' connects and health checks for SGLang and vLLM too. A pair of ATOM gRPC workers goes to `AtomPairs` (`engine/atom/pair.rs`), which keeps ATOM's HTTP P/D flow. Relay runs P with streaming off and max_tokens 1, releases P's load when P completes, and sends D the enriched kv_transfer_params; chunked starts P and D together and returns D's stream only after P completes, a failure on either side cancelling the other. P's transfer info comes from GetServerInfo through the shared `parse_atom_prefill_info`, P is picked by the shared rank mapping, and `Dispatcher::holds_load` keeps the pipeline from taking a second pair. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…omesh discovery and P/D Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… P/D Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
With
A small fix, following how
Could you cover this in the stack, or as a follow-up on top of it? It is the remaining piece for tiered cache-aware routing over gRPC P/D. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
Two critical tokenizer registration issues can route chats with the wrong template during concurrent worker admission and discard an explicit file-backed template override when a worker specifies no template file.
9 open issues
Prevent conflicting templates for in-flight model workers · New Preserve file-backed tokenizer when worker has no template · New Reject requests when the loaded template differs from the worker's Validate the template after resolving the final rank mapping Missing template record bypasses worker-template readiness check Block chat routing until replacement tokenizer config is reconciled Streaming renderers retain D's load after client disconnect Make tokenize and detokenize resolve models during worker swaps DeepSeek built-in encoders ignore advertised chat templates
Review effort: Balanced
…discovery and P/D
|
Fixes the template-replacement races at their source in 02e31a7: all live workers of a model serve one template. A worker with another template is refused at registration while one is registered; changing it is a redeploy, and an ATOM model's last worker leaving drops its tokenizer. This supersedes the swap-aware |
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical template-admission and lifecycle races can route chats with incompatible prompt IDs, and registration can discard explicit tokenizer-file overrides.
10 open issues
Prevent stale tokenizer jobs from publishing removed workers’ templates · New Validate rendered template identity before dispatching to replacement workers · New Preserve file-backed tokenizer when worker has no template Prevent conflicting templates for in-flight model workers Reject requests when the loaded template differs from the worker's Validate the template after resolving the final rank mapping Missing template record bypasses worker-template readiness check Streaming renderers retain D's load after client disconnect Make tokenize and detokenize resolve models during worker swaps DeepSeek built-in encoders ignore advertised chat templates
1 resolved since last review
Review effort: Balanced
| error::internal_error("model_id_not_set", "model_id not set in request") | ||
| })?; | ||
| let tokenizer = lookup_tokenizer(model_id_str, &components.tokenizer_registry)?; | ||
| let workers = components.worker_registry.get_by_model(model_id_str); |
There was a problem hiding this comment.
Fixed in 16076b3. A chat carries the fingerprint of the template its tokenizer was loaded with (RenderedTemplate), and placement offers it only ATOM workers serving that template: own file, else --chat-template, else the advertised one. With none, or a tokenizer dropped mid-render, it gets a retryable 503 chat_template_changed. Test: test_a_chat_is_placed_only_on_workers_serving_its_template.
A worker's tokenizer job could still be queued or loading when the worker, its model's last, was removed. A successor with another template then registered, as no tokenizer was loaded yet, and the old job published the removed worker's template; the successor's own job found the model loaded and every chat for it rendered with the old template. A job a worker's registration submits now names that worker, and once it has loaded, drops what it loaded unless that worker is still registered serving the job's template. The check runs after publishing, under the model's registration lock: a removal that ran before it is seen, and one that runs after it finds the tokenizer and drops it with the model's last worker. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When an ATOM model's last worker leaves, its tokenizer goes with it, and a successor may register with another template. A chat that rendered with the old tokenizer meanwhile was placed from the live registry, and its ids went to the successor, which reads them with its own template. A chat now carries the template its prompt rendered with (`RenderedTemplate`: the fingerprint of the file or text the tokenizer was loaded with, read with that tokenizer), and placement offers it only the ATOM workers serving that template: a worker's own file, else --chat-template, else the one it advertised. When a pool has none, or the tokenizer was dropped while the prompt rendered, the chat gets a 503 chat_template_changed, to be retried. A prompt ATOM rendered is not bound, nor is a worker other than ATOM's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
Critical registration and tokenizer-lookup races can admit conflicting templates or send incompatible prompt tokens, while missing template fallback can cause every chat to fail with 503 errors.
10 open issues
Keep tokenizer and registry ID from the same lookup · New Use the loaded tokenizer file path as the placement template fallback · New Validate rendered template identity before dispatching to replacement workers Preserve file-backed tokenizer when worker has no template Prevent conflicting templates for in-flight model workers Reject requests when the loaded template differs from the worker's Validate the template after resolving the final rank mapping Missing template record bypasses worker-template readiness check Streaming renderers retain D's load after client disconnect DeepSeek built-in encoders ignore advertised chat templates
2 resolved since last review
Review effort: Balanced
… lookup Chat preparation looked the tokenizer up by name and, on a miss, again through `TokenizerRegistry::get`. A tokenizer job publishing between the two, or a model named by the tokenizer's id, left preparation with a tokenizer but no registry entry, so it skipped the built-in-encoder refusal and the template fingerprint placement binds the chat with. One lookup (name, then id, as `get` reads) now returns both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nt does A chat's template fingerprint ranks the file its tokenizer was loaded with first, but placement compared an ATOM worker's template against `--chat-template` alone. A tokenizer added with `chat_template_path` and no worker or router file rendered every chat with that file and then had no worker serve it: 503 `chat_template_changed`. The fallback a worker without its own file serves is now the tokenizer's file, else `--chat-template`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🔵 Needs a closer look
A critical registration race allows workers with incompatible templates to become active while tokenizer loading is pending, causing persistent 503 chat_template_changed failures.
8 open issues
Validate rendered template identity before dispatching to replacement workers Preserve file-backed tokenizer when worker has no template Prevent conflicting templates for in-flight model workers Reject requests when the loaded template differs from the worker's Validate the template after resolving the final rank mapping Missing template record bypasses worker-template readiness check Streaming renderers retain D's load after client disconnect DeepSeek built-in encoders ignore advertised chat templates
2 resolved since last review
Review effort: Balanced
An ATOM worker is checked against the template its model's tokenizer was loaded with. Before that tokenizer has loaded there was nothing to check against, so a second worker with another template registered and went active beside the first; once the first one's template loaded, the second's chats answered 503 chat_template_changed for as long as both stayed. With no tokenizer loaded yet, the template the model's registered workers serve (recorded when each registered, before its tokenizer job) is now the one a new worker must match. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🔵 Needs a closer look
The worker-admission path can discard an explicit tokenizer template-file override when the first worker advertises an inline template, silently replacing the configured template.
7 open issues
Validate rendered template identity before dispatching to replacement workers Preserve file-backed tokenizer when worker has no template Reject requests when the loaded template differs from the worker's Validate the template after resolving the final rank mapping Missing template record bypasses worker-template readiness check Streaming renderers retain D's load after client disconnect DeepSeek built-in encoders ignore advertised chat templates
1 resolved since last review
Review effort: Balanced
…e an advertised one Admission read an ATOM worker's template as its own file, else --chat-template, else the template it advertised, and placement as its own file, else the file the model's tokenizer was loaded with, else --chat-template, else the advertised one. A tokenizer registered with a template file therefore took a worker advertising a template for another template: the first such worker dropped the file-backed tokenizer and reloaded it with the advertised template, and later ones were refused. Admission now ranks the templates as placement does, so the file is kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🔵 Needs a closer look
Concurrent registrations can admit conflicting templates before either worker is published, leaving a registered worker unusable and potentially causing every chat request for a P/D model to return 503.
6 open issues
Validate rendered template identity before dispatching to replacement workers Reject requests when the loaded template differs from the worker's Validate the template after resolving the final rank mapping Missing template record bypasses worker-template readiness check Streaming renderers retain D's load after client disconnect DeepSeek built-in encoders ignore advertised chat templates
1 resolved since last review
Review effort: Balanced
|
Fixes the review's registration-race point in 7f44954. While a model's tokenizer is still loading, a new ATOM worker is checked against the template the model's registered workers serve, so a worker with another template is refused, not activated. Test: |
…step The template check ran when the worker was created and the worker was published a step later, so two registrations with different templates could both pass the check before either was registered, leaving a model with two templates. The check now runs in the register step, under one lock with the registry insert: of two concurrent registrations with different templates, the second sees the first's workers and is refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🔵 Needs a closer look
Human assessment is needed because tokenizer cleanup can race with same-template worker registration, deleting a tokenizer still in use and causing chat and text-completion requests to fail with 500 errors.
6 open issues
Validate rendered template identity before dispatching to replacement workers Reject requests when the loaded template differs from the worker's Validate the template after resolving the final rank mapping Missing template record bypasses worker-template readiness check Streaming renderers retain D's load after client disconnect DeepSeek built-in encoders ignore advertised chat templates
Review effort: Balanced
|
Fixes the review's template-file point in 356436b. Admission now ranks a worker's template as placement does: its own file, then the file the model's tokenizer was loaded with, then |
… admitted with Removing a model's last ATOM worker checked that none was left and then dropped the model's tokenizer. A worker with the same template could be admitted against that tokenizer and registered in between, its tokenizer job finding the tokenizer loaded, and be left serving a model without one. The check and the drop now run under the admission lock, so such a worker is registered before the check and keeps the tokenizer, or is admitted after the drop and loads it again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🔵 Needs a closer look
Human assessment is needed because interacting worker-update and tokenizer-loading lifecycles can leave mismatched templates or stale tokenizers active, causing persistent chat failures or incorrect tokenization.
6 open issues
Validate rendered template identity before dispatching to replacement workers Reject requests when the loaded template differs from the worker's Validate the template after resolving the final rank mapping Missing template record bypasses worker-template readiness check Streaming renderers retain D's load after client disconnect DeepSeek built-in encoders ignore advertised chat templates
Review effort: Balanced
|
Fixes both registration races from the last two reviews:
|
|
No blocking issues: all six are fixed or answered in their threads, and none needs a change at 2d4da70. A model's live workers serve one template, admitted under the lock of the registry insert (c0780dd) that the last-worker tokenizer drop also takes (2d4da70). A chat goes only to workers serving its Per issue
|
…sh discovery and P/D Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
ATOM gRPC idx2idx dispatch remaps prefill ranks without aligning planning, so load-aware policies can route requests to an overloaded rank despite an available alternative.
7 open issues
Validate rendered template identity before dispatching to replacement workers Reject requests when the loaded template differs from the worker's Validate the template after resolving the final rank mapping Missing template record bypasses worker-template readiness check Streaming renderers retain D's load after client disconnect ATOM gRPC planning ignores idx2idx when selecting the prefill rank · New DeepSeek built-in encoders ignore advertised chat templates
Review effort: Balanced
| AtomPairs::new( | ||
| worker_registry.clone(), | ||
| ctx.router_config.atom_pd_rank_mapping_policy, | ||
| ) |
Main renders every chat in Rust: a checkpoint with ChatControls renders with its encoder, and one llm-tokenizer renders with an uncontrolled built-in encoder is refused at registration. So chats_without_template and the built-in-encoder 501 go; prepare_chat renders a model with controls through chat_render, bound to no template, and keeps the ATOM worker's default kwargs, reasoning toggle and template fingerprint for template models. forget_tokenizer drops the controls with the rest. Test plans carry prefill_tokens: 0, and the 501 tests now check the controlled render. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
Verified critical inconsistencies in template validation and rendering defaults can admit incompatible workers and produce prompt IDs that differ from workers’ HTTP routes.
9 open issues
Validate replacements against the admitted template identity · New Apply template defaults in the native encoder path · New Validate rendered template identity before dispatching to replacement workers Reject requests when the loaded template differs from the worker's Validate the template after resolving the final rank mapping Missing template record bypasses worker-template readiness check Streaming renderers retain D's load after client disconnect ATOM gRPC planning ignores idx2idx when selecting the prefill rank DeepSeek built-in encoders ignore advertised chat templates
Review effort: Balanced
| /// ATOM is sent the text as well; an ATOM worker must serve the same template. | ||
| pub fn served_by(&self, worker: &dyn Worker) -> bool { | ||
| worker.metadata().runtime_type != RuntimeType::Atom | ||
| || served_template(worker, self.fallback_file.as_deref()) == self.fingerprint |
| .map_err(|e| error::internal_error("invalid_reasoning_toggle", e))?; | ||
|
|
||
| let (text, prompt_opener) = match controls { | ||
| Some(_) => chat_render::render_chat(&body_ref, sent, &*tokenizer, controls), |


Part E of the 8 PRs proposed in #3657 (regrouped by function). No blocking issues.
Based on D, which it needs.
Why
An ATOM gRPC port never registered with atomesh, DP-aware discovery asked HTTP for its DP size, and a P/D pair of ATOM workers went through SGLang's dual dispatch, so D never got P's KV.
What changed
--chat-templateis set. A model's live workers serve one template; its last worker leaving drops the tokenizer. A model withChatControls(DeepSeek V3.2/V4/V4.1, Kimi-K3) renders with its encoder, as main'schat_renderdoes; a template model whose ATOM worker reports no template, with no--chat-template, gets 501 naming HTTP routing.--dp-aware, an ATOM worker's DP size comes from GetServerInfo; aurl@rankgRPC worker of any runtime connects to its instance's URL.--kv-events, an ATOM gRPC worker's KV event sources come from GetServerInfo, as an HTTP worker's do; other gRPC workers are skipped.AtomPairs(engine/atom/pair.rs) keeps ATOM's HTTP P/D flow: relay, or chunked. P's GetServerInfo is read once per instance within its health timeout (504), again after re-registration; a mixed ATOM/non-ATOM pair gets 500.Size: over 1,000 lines and 15 files: P/D pairs workers only discovery registers, with their ranks.
Review focus
@rankconnect fix reaches SGLang and vLLM ranks too.Testing
Stubs: registration (labels, parsers, ranks, runtime, health, one template per model, admission/teardown races, stale jobs, placement); relay, chunked, cancels, idx2idx; refusals; prefill re-reads.
jasen/atom-grpc-e-mesh-discovery-pd@ 2d4da70: all tests pass (Evidence); fmt clean; 1 new clippy warning.Follow-ups
none
What changed, in detail
RenderedTemplate), and placement offers it only the ATOM workers serving that template (their own file, else the file the tokenizer was loaded with, else--chat-template, else the one they advertised, as the chat's fingerprint ranks them); with none, it gets a 503chat_template_changed, to retry. A chat's tokenizer and what it was loaded with come from one registry lookup.Stack
ATOM serves
atom.grpc.v1.AtomEnginebeside its HTTP server (token ids in, token ids out, ATOM's P/D flow unchanged), and atomesh routes to ATOM gRPC workers over a Generate call per request or one Session per instance. One linear stack, merged bottom to top: A, B, C, D, E, F, G, H; each PR's base is the one before it.Evidence
In
atom/mesh(rustc and clippy 1.100.0), at 2d4da70:cargo fmt --checkandcargo clippy --all-targetswith and withoutatom-enginepass.a_leaving_last_worker_keeps_the_tokenizer_a_same_template_worker_was_admitted_withfails without the tokenizer-teardown lock (3 of 3 runs) and passes with it.Clippy against D (warnings matched by message and file):
The new one:
result_large_erronlookup_tokenizer_entry, which returns aResponseerror aslookup_tokenizerbeside it does.🤖 Generated with Claude Code