Skip to content

Add hash resolution and independent prefetch/move hints - #181

Open
Flasew wants to merge 4 commits into
ai-dynamo:mainfrom
Flasew:independent-hint
Open

Flasew wants to merge 4 commits into
ai-dynamo:mainfrom
Flasew:independent-hint

Conversation

@Flasew

@Flasew Flasew commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Add hash resolution and independent KV prefetch/move

This PR adds kv.prefetch and kv.move request-independent hints, so a router can ask KVCR to copy or move cached blocks using a source endpoint and block hashes. KVCR uses framework's KeyAdaptor to resolve those hashes to full KVCR BlockKeys, and starts the transfer independently of the request carrying the hint. kv.fetch remains request-scoped advice: the framework supplies full keys and starts copying through fetch() or deliver().

Supersedes #154. The move and invalidation mechanism is included here.

Commits

Commit Change
e6df929 — request advice Make kv.fetch advice always mean copy. Supplied mode fields are ignored, and submit_hint() still starts no transfer.
76fb194 — hash resolution Ask a source to translate advertised hashes into full keys and layouts through KeyAdapter.decode_from_router. Validate replies and handle lookup failures and timeouts.
93785b2 — move and invalidation internal mechanism Allow internal fetches to name their source directly and request removal of its cached copies. Reuse existing transfers without adding a public framework move() API.
ca89731 — independent hints Connect kv.prefetch and kv.move to lookup and transfer, check destination compatibility, and collect results without depending on an inference request.

Behavior

Independent hints. kv.prefetch copies blocks into KVCR-managed DRAM (G2); kv.move also requests removal of the source copies. Both carry source_control_endpoint and block_hashes. They can target blocks unrelated to the request carrying them, run without a request ID, and share an envelope with request advice. Discarding the carrier request does not cancel them.

Their source transfers read only complete G2 copies. If those copies disappear, the transfers fail instead of using framework memory. Ordinary request-scoped copying can still use framework memory.

Hash resolution. The destination first asks the source for full BlockKey values and layout/size information, adding one metadata round trip before transfer. This lookup does not reserve memory; the transfer checks availability again. The framework integration owns the hash-to-key map and decides how to handle collisions. Missing or ambiguous hashes and adapter failures are reported per hash, allowing the other hashes to proceed. KVCR adds no second index and does not reject inventory updates on collision. A worker cannot resolve against itself.

Move semantics. The destination includes move intent in the transfer request, and the source owns invalidation. Before transferring blocks eligible for removal, the source marks them for removal and stops accepting new reads and deposits. After a successful native transfer, it removes their G2 copies once existing readers and claims are released. This is eager removal: KVCR frees the source cache memory as soon as it is safe, rather than merely making the blocks evictable. A failed transfer cancels that move's pending removal and restores access after cleanup. If the destination already has complete copies, it sends an invalidate message and the source performs the same removal without another transfer.

G2 removal respects no_evict and does not touch framework-owned memory. Removing G3 copies as part of a move is not implemented. Inventory events reflect actual additions and removals. Destination completion means its data is ready; source cleanup may finish later.

For moves, the destination extends the completion allowance for the full-key fetch from operation_timeout_ms to abandon_timeout_ms, starting after hash resolution. The source still caps the transfer at its normal operation_timeout_ms. This gives the destination extra time to process completion after the source finishes. Source removal does not wait for a destination acknowledgement, so a destination that exceeds this longer deadline can still report a timeout after the source has removed its copy.

Independent hints use the existing KVCR.poll_completed() loop on both workers. Integrations must keep servicing that loop even when no inference request is active. At the source, polling admits moves and processes invalidation and cleanup. At the destination, it starts transfers after resolution, processes transfer completions, and releases temporary claims. Independent hint results are handled internally and do not appear in the returned framework completion list. See hash-addressed operations for detailed contracts.

Validation

  • Source tests: lookup failures and collisions, self-source rejection, and when framework memory may be used.
  • Destination tests: invalid or late replies, copied bytes, cached and partially cached moves, existing readers, no_evict, failures, and inventory updates.
  • Hint tests: unrelated carrier requests, mixed actions, disappearing or incomplete source copies, delayed transfers, overlapping actions, different layouts, and cleanup.

@copy-pr-bot

copy-pr-bot Bot commented Nov 5, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

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>
@Flasew Flasew changed the title Independent hint Add hash resolution and independent prefetch/move hints Nov 6, 2026
@Flasew
Flasew marked this pull request as ready for review November 6, 2026 04:58
@Flasew
Flasew requested a review from mkhazraee November 6, 2026 04:58
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>

This branch has not been deployed

No deployments
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.

1 participant