Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 28 additions & 0 deletions tensorrt_llm/_torch/disaggregation/base/memory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The kinds of memory a cache backend can access."""

import enum

__all__ = ["MemoryKind"]


class MemoryKind(enum.Enum):
"""Memory a backend can access: HOST is CPU-addressable; DEVICE is the GPU holding the cache.

Each region of memory is of one kind."""

HOST = "host"
DEVICE = "device"
8 changes: 8 additions & 0 deletions tensorrt_llm/_torch/disaggregation/blob/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
"""The blob backend: KV rows shared through a byte store.

So far this package holds the private driver boundary (``store.py``) and the key encoding
(``keys.py``). Nothing here imports an optional store SDK at import time, and the only thing
shared with the public backend contract is ``MemoryKind``.
"""
33 changes: 33 additions & 0 deletions tensorrt_llm/_torch/disaggregation/blob/keys.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
"""Store keys for blob objects.

A private encoding of the lender's opaque object names, not a stable public format. The key
carries ``FORMAT_VERSION``, which covers the key spelling and the payload layout alike: after an
incompatible change, objects written under the old version are never looked up, so they miss
instead of being misread.
"""

from __future__ import annotations

import re

FORMAT_VERSION = 1

_PREFIX = re.compile(r"[A-Za-z0-9_-]{1,64}")
_SEPARATOR = "/"


def encode_key(prefix: str, name: bytes) -> str:
"""``"<prefix>/v<FORMAT_VERSION>/<hex of name>"``.

Args:
prefix: The store partition the objects live in, for example a deployment name; matches
``[A-Za-z0-9_-]{1,64}``.
name: The lender's opaque object name; encoded whole, never parsed.
"""
if not _PREFIX.fullmatch(prefix):
raise ValueError(f"bad key prefix {prefix!r}: expected [A-Za-z0-9_-]{{1,64}}")
if not name:
raise ValueError("an object name is non-empty")
return f"{prefix}{_SEPARATOR}v{FORMAT_VERSION}{_SEPARATOR}{name.hex()}"
Loading
Loading