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
72 changes: 2 additions & 70 deletions api/torch/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@nanobind_abseil/google:nanobind.bzl", "nanobind_extension")
load("@nanobind_bazel//:build_defs.bzl", "nanobind_extension")
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_python//python:defs.bzl", "py_library", "py_test")

Expand All @@ -32,53 +30,12 @@ cc_library(
],
)

cc_library(
name = "kv_cache_manager_torch",
srcs = ["kv_cache_manager.cc"],
hdrs = ["kv_cache_manager.h"],
copts = [
"-std=c++20",
"-fexceptions",
"-march=x86-64-v2",
],
features = [
"-use_header_modules",
],
visibility = ["//visibility:public"],
deps = [
"//core:host_memory_allocator",
"//core:xla_raw_transfer_headers",
"//frameworks/torch:torch_tpu_utils",
"//frameworks/torch:torch_utils",
"//kv_cache:kv_cache_manager_base",
"@com_google_absl//absl/status:statusor",
"@torch_tpu//shims/torch:aten_headers",
"@torch_tpu//shims/torch:torch_headers",
],
)

nanobind_extension(
name = "_kv_cache_manager",
srcs = ["kv_cache_manager_module.cc"],
features = [
"-use_header_modules",
],
visibility = ["//visibility:public"],
deps = [
":kv_cache_manager_torch",
"//core:raw_transfer_core",
"//frameworks/torch:torch_nanobind_utils",
"//kv_cache:kv_cache_manager_base",
"@com_google_absl//absl/status:statusor",
],
)

py_library(
name = "kv_cache_manager_torch_py",
srcs = ["kv_cache_manager.py"],
visibility = ["//visibility:public"],
deps = [
":_kv_cache_manager",
"//frameworks/torch:_kv_cache_manager",
"@torch_tpu//shims/torch:pytorch",
"@torch_tpu//torch_tpu",
],
Expand Down Expand Up @@ -136,31 +93,6 @@ py_test(
],
)

nanobind_extension(
name = "_raiden_transfer_engine",
srcs = ["raiden_transfer_engine.cc"],
copts = [
"-fno-strict-aliasing",
"-fexceptions",
],
features = [
"-use_header_modules",
],
visibility = ["//visibility:public"],
deps = [
":kv_cache_manager_torch",
"//core:raw_transfer_core",
"//frameworks/torch:torch_nanobind_utils",
"//kv_cache:kv_cache_manager_base",
"//transport:socket_transport",
"@com_google_absl//absl/log",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@nanobind",
"@torch_tpu//shims/torch:aten_headers",
],
)

py_library(
name = "raiden_transfer_engine",
srcs = ["raiden_transfer_engine.py"],
Expand All @@ -169,7 +101,7 @@ py_library(
],
visibility = ["//visibility:public"],
deps = [
":_raiden_transfer_engine",
"//frameworks/torch:_raiden_transfer_engine",
"@torch_tpu//shims/torch:pytorch",
"@torch_tpu//torch_tpu",
"@torch_tpu//torch_tpu:_loader",
Expand Down
2 changes: 1 addition & 1 deletion api/torch/kv_cache_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import torch

# Import Pybind11 dynamic binary extension E2E!
from api.torch import _kv_cache_manager
from frameworks.torch import _kv_cache_manager


class KVCacheManager:
Expand Down
2 changes: 1 addition & 1 deletion api/torch/raiden_transfer_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def _load_torch_tpu_common() -> None:

_load_torch_tpu_common()

from . import _raiden_transfer_engine as _impl
from frameworks.torch import _raiden_transfer_engine as _impl

RaidenTransferEngine = _impl.RaidenTransferEngine

Expand Down
61 changes: 61 additions & 0 deletions frameworks/torch/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,64 @@ cc_library(
"@torch_tpu//shims/torch:torch_headers",
],
)

cc_library(
name = "kv_cache_manager_torch",
srcs = ["kv_cache_manager.cc"],
hdrs = ["kv_cache_manager.h"],
copts = [
"-std=c++20",
"-fexceptions",
"-march=x86-64-v2",
],
features = [
"-use_header_modules",
],
visibility = ["//visibility:public"],
deps = [
":torch_tpu_utils",
":torch_utils",
"//core:host_memory_allocator",
"//core:xla_raw_transfer_headers",
"//kv_cache:kv_cache_manager_base",
"@com_google_absl//absl/status:statusor",
"@torch_tpu//shims/torch:aten_headers",
"@torch_tpu//shims/torch:torch_headers",
],
)

nanobind_extension(
name = "_kv_cache_manager",
srcs = ["kv_cache_manager_module.cc"],
features = [
"-use_header_modules",
],
visibility = ["//visibility:public"],
deps = [
":kv_cache_manager_torch",
":torch_nanobind_utils",
"//core:raw_transfer_core",
"//kv_cache:kv_cache_manager_base",
"@com_google_absl//absl/status:statusor",
],
)

nanobind_extension(
name = "_raiden_transfer_engine",
srcs = ["raiden_transfer_engine.cc"],
features = [
"-use_header_modules",
],
visibility = ["//visibility:public"],
deps = [
":kv_cache_manager_torch",
":torch_nanobind_utils",
"//core:raw_transfer_core",
"//kv_cache:kv_cache_manager_base",
"//transport:socket_transport",
"@com_google_absl//absl/log",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@torch_tpu//shims/torch:aten_headers",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "api/torch/kv_cache_manager.h"
#include "frameworks/torch/kv_cache_manager.h"

#include <cstddef>
#include <cstdint>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
#include "nanobind/stl/string.h"
#include "nanobind/stl/vector.h"
#include "absl/status/statusor.h"
#include "api/torch/kv_cache_manager.h"
#include "core/raw_transfer_core.h"
#include "frameworks/torch/kv_cache_manager.h"
#include "frameworks/torch/torch_nanobind_utils.h"

namespace nb = nanobind;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "api/torch/kv_cache_manager.h"
#include "core/raw_transfer_core.h"
#include "frameworks/torch/kv_cache_manager.h"
#include "frameworks/torch/torch_nanobind_utils.h"
#include "kv_cache/kv_cache_manager_base.h"
#include "transport/socket_transport.h"
Expand Down