Skip to content

Resolve router hashes and execute independent copy and move hints - #3

Draft
Flasew wants to merge 8 commits into
mainfrom
independent-hint
Draft

Flasew wants to merge 8 commits into
mainfrom
independent-hint

Conversation

@Flasew

@Flasew Flasew commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

Depends on ai-dynamo/kvcr#154, which adds source-owned G2 removal for move hints, and should merge after it. Review only the three feature commits. The comparison against upstream main currently also includes the parent PR's changes.

Allow kv.fetch hints to place blocks in managed destination G2 without waiting for a framework request for those keys. An unrelated request can carry the hint. Transfers continue to use complete BlockKey values and the existing fetch/move machinery.

The feature is split into three commits:

1. Hash resolution — ea35bc4

Add the source-side resolve_hashes / hashes_resolved exchange. The source resolves each uint64 hash through KeyAdapter.decode_from_router() and returns its full key, ordered layout labels, and piece sizes. The adapter owns reverse lookup: return a full key, raise KeyError for not_found, or ValueError for ambiguous_hash. Lookup runs on progress and must not block; KVCR maintains no additional hash index.

Resolution requires a managed G2 record with layout metadata. It neither reserves source memory nor transfers data; source admission revalidates residency later. A request from the same KVCR instance fails with self_source before lookup, including through endpoint aliases. Framework-only lookup and remote G3 staging are unsupported.

Ambiguity policy belongs to the integration. The companion vLLM adapter accepts inventory updates, tracks all colliding full keys, and rejects lookup until a hash becomes unique again. This includes collisions across KV cache groups. Its map requires KV cache events to be enabled. Request-scoped transfers retain exact keys supplied by the framework.

2. Independent hints — 70c41c7

scope defaults to "request": with a request ID, the hint records advice for later framework calls. Explicit scope: "independent", or submission without a request ID, starts placement immediately. mode remains "copy" or "move", defaulting to copy.

The path is submit_hint → _IndependentHintHandler → hash resolution → destination key/layout validation → ordinary core.fetch. Resolution adds one round trip before the existing transfer protocol. _HashResolutionOp tracks this exchange locally; only the resolution request and reply are wire messages. Both owners must continue calling poll_completed().

Independent work outlives its carrier request. Private advice IDs prevent collisions with request advice; completion releases temporary claims and advice. Per-hash outcomes allow partial success and are reported internally without entering framework completion results. There is no public hint-result polling API. Move inherits the base commit’s best-effort G2 removal, existing-reader protection, and no_evict behavior; completion can precede source cleanup.

Nonfatal fetch-admission exceptions fail the affected group and discard its private advice; unexpected exceptions warn once. Fatal progress errors continue to propagate to the caller.

3. Framework fallback policy — 1cd447f

Add boolean allow_framework, defaulting to true in both scopes. If source G2 disappears after resolution, the transfer may obtain the same full key from framework memory, preserving existing behavior. false requires complete managed G2 at source admission: missing/incomplete keys fail without acquiring or reusing framework pins. The policy survives retries and deferred admission, and applies to subsequent request-scoped fetch/deliver operations too.

This provides a managed-memory-only policy without pinning during resolution. It does not make framework-only hashes resolvable.

Validation

Core unit and native KVCR tests run without vLLM or Dynamo:

  • Resolution tests check adapter errors, full-key identity, malformed/wrong-endpoint/duplicate/late replies, deadlines, progress while the source owner lock is held, and self-source rejection before lookup. Independent-operation tests check carrier lifetime, mixed actions, advice isolation, layouts, cached/partial destinations, copy/move overlap, cleanup, recovery after nonfatal admission errors, and fatal progress failure during actual fetch admission. Unit tests control messages and completions to establish race ordering.
  • Framework-policy tests remove or replace source G2 between resolution and admission, including capacity waits and metadata retries. They verify default/allowed fallback, denied fallback, exact-key preservation, and incomplete-source behavior. Source tests also check denial of existing-pin reuse.
  • Native scenarios use two processes, real NIXL/UCX and ZMQ, and JSON hints. They verify bytes through subsequent loads, source/inventory changes, reader and no_evict protection, source/destination collisions, collision recovery, cached destinations, mixed batches, disappearance/rebinding races, and drained claims/pins/advice.

Separate integration validation uses the companion vLLM adapter and temporary Dynamo composer. vLLM units check inventory/tier/collision transitions. The two-manager runner and local Dynamo-driven extension exercise production adapter callbacks, unchanged composed envelopes, unrelated carriers, ordinary loads, partial failures, rebinding, and overlapping actions. The Dynamo-driven scenarios were rerun after review. A corrected live Qwen/A100 test submits known/unknown self-addressed copy/move actions through LLMEngine.add_request: all fail with self_source before lookup or transfer, preserving cached bytes and carrier output.

Native/component transfers use CPU buffers. The live test covers rejection on one engine, superseding the earlier self-copy success claim. Full frontend HTTP/discovery transport, two complete serving workers, GPU-to-GPU transfer, and throughput are outside this validation. Unit/native checks cover the reviewed code; the independent-hint commit was also rechecked without the later framework-policy commit.

luckyq and others added 4 commits November 3, 2026 09:51
…ned vLLM nightly (ai-dynamo#160)

## Problem
- `Dockerfile.quick-start-vllm` pins Dynamo v1.6.0 (`701da25`) with vLLM
nightly `edad8b03`. Every worker built from it exits at import (`cannot
import name 'get_engine_zmq_addresses'`), so the quick start cannot
start a worker (ai-dynamo#159).
- The build-time check imports `dynamo.vllm` but not the worker entry
point, so the mismatch passes the build.

## Fix
- `DYNAMO_REF` → `318ab039` (Dynamo main, 2026-11-02). Dynamo dropped
the renamed import on 2026-10-23 (ai-dynamo/dynamo#16757); v1.6.0 and
v1.6.1 both still have it. `VLLM_IMAGE` and `KVCR_VLLM_REF` are
unchanged.
- The compatibility check now also runs `import dynamo.vllm.main`, so a
Dynamo/vLLM pair that cannot start a worker fails the build instead of
the first `python -m dynamo.vllm`.

## Validation
- Image built from this Dockerfile unchanged otherwise
(`ghcr.io/luckyq/kvcr-phase1:qs-218c7816b34b`, 7 min); the new import
check passes.
- 2×H100 (dynamo-aws-dev-02), Qwen3-8B, Guard mode, Phase 1 harness
TC-01/02/03: 3/3 PASS (`source_write == remote_deliver`, 0 token
mismatches).
- Same Dynamo revision with the full matrix earlier today: dense 6/6,
2P+1D 6/6, Qwen3.5-4B hybrid 6/6.

Fixes ai-dynamo#159.

Signed-off-by: doxu <doxu@nvidia.com>
…eyAdapter API (ai-dynamo#162)

Signed-off-by: doxu <doxu@nvidia.com>
## Summary

- Add an experimental SGLang Direct Linker quick start and Dockerfile.
- Use KVCR-owned inventory and Dynamo router hints for peer KV reuse.
- Scope the example to dense Qwen3-32B BF16 with TP1 workers.

The recipe pins Dynamo
[#17655](ai-dynamo/dynamo#17655) (`fe81cfd`) and
SGLang [#45650](sgl-project/sglang#45650)
(`5b65e08`); KVCR is installed from the build checkout.

## Validation

- Built the Dockerfile from this PR and ran its import/version canary.
- Two B200 nodes, one TP1 worker per node: ten 116K-token requests
restored 115,968 tokens via router-generated hints and RDMA, with
matching output IDs. Mooncake linker `local_first` and `random` ran
against the same inputs.
- The cross-node test used a harness and a chroot in retained GPU pods;
the guide's same-host deployment was not run as written.

Signed-off-by: linhu-nv <linhu@nvidia.com>
Co-authored-by: Ziqi Fan <ziqif@nvidia.com>
Signed-off-by: Moein Khazraee <moein@nvidia.com>
Keep kv.fetch as source advice for later framework fetch/deliver calls. Remove
obsolete payload handling and clarify that hint hashes differ from full
BlockKey inventory and transfer identities.

Validation: hint parser/fetch suites, Ruff, and whitespace checks.

Signed-off-by: Weiyang Wang <wafrank@nvidia.com>
Add metadata-only peer resolution through the adapter's reverse lookup, with
complete keys, layouts, and per-hash failures. Reject self-addressed resolution
by process incarnation. The integration owns the reverse index and ambiguity
policy; lookup acquires no source-memory claims.

Include the full client lifecycle: validate peer, hash set, reply rows, and
deadline, then deliver completion on the owner thread through a callback.
Neither endpoint depends on hint execution or move state. Extend the existing
remote-source/target suites for lookup failures, owner-independent replies,
malformed/late responses, and exactly-once completion.

Validation: full unit suite, Ruff, and whitespace checks.

Assisted-by: OpenAI Codex
Assisted-by: Anthropic Claude
Signed-off-by: Weiyang Wang <wafrank@nvidia.com>
Add internal full-key fetches from a named peer, with optional source removal.
Keep the source through deferred admission and require managed source G2,
without acquiring or borrowing framework pins. The public framework API and
ordinary copying remain unchanged.

Withdraw eligible source copies before transfer; successful writes leave
removal pending until readers drain, while failure reopens admission. Honor
no_evict, invalidate cached destination hits, and publish actual residency
changes. Hash lookup excludes keys pending removal.

Extend existing remote tests for exact bytes, cache hits, protection, partial
failure, source validation, busy producers, readers, and pin exclusion.

Validation: full unit suite, Ruff, and whitespace checks.

Signed-off-by: Weiyang Wang <wafrank@nvidia.com>
Connect kv.prefetch and kv.move to hash resolution and named-source transfers.
Actions outlive their carrier request, preserve request advice, validate local
identity/layout compatibility, and aggregate per-hash results across layouts.
Consume internal completions and release temporary destination claims.

Extend the existing hint suite for carrier independence, copied bytes, cached
moves, source disappearance, capacity waits, overlapping actions, layout groups,
timeouts, and cleanup. Document the hint flow and source removal ordering,
including the planned request-scoped kv.migrate hint for cold starts.

Validation: full unit suite, native two-peer NIXL/UCX scenarios, Ruff, and
whitespace checks.

Assisted-by: OpenAI Codex
Assisted-by: Anthropic Claude
Signed-off-by: Weiyang Wang <wafrank@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants