// SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. // SPDX-License-Identifier: Apache-2.0 use super::*; pub mod distributed_leader_worker; pub mod null; use crate::block_manager::block::{ BlockDataProvider, ReadableBlock, WritableBlock, transfer::{TransferContext, TransferError, WriteToStrategy}, }; use crate::block_manager::locality::Logical; use crate::block_manager::storage::{self, nixl::NixlDescriptor}; use tokio::sync::oneshot; pub enum LogicalKinds { Simple, Sharded, } pub trait LogicalResources: Clone + Send + Sync + 'static + std::fmt::Debug { fn handle_transfer( &self, sources: &[RB], targets: &mut [WB], ctx: Arc, ) -> Result, TransferError> where RB: ReadableBlock + WriteToStrategy + storage::Local, ::StorageType: NixlDescriptor, ::StorageType: NixlDescriptor, RB: BlockDataProvider>, WB: WritableBlock + BlockDataProviderMut>; } /// Individual block storage - cannot be cloned to ensure uniqueness #[derive(Debug)] pub struct LogicalBlockData { block_id: BlockId, block_set_id: usize, worker_id: WorkerID, resources: Arc, storage_type: StorageType, storage: std::marker::PhantomData, page_size: usize, } impl LogicalBlockData { pub fn new( block_id: BlockId, block_set_id: usize, worker_id: WorkerID, resources: Arc, storage_type: StorageType, page_size: usize, ) -> Self { Self { block_id, block_set_id, worker_id, resources, storage_type, storage: std::marker::PhantomData, page_size, } } pub fn resources(&self) -> Arc { self.resources.clone() } } impl BlockDataExt for LogicalBlockData { fn block_id(&self) -> BlockId { self.block_id } fn block_set_id(&self) -> usize { self.block_set_id } fn worker_id(&self) -> WorkerID { self.worker_id } fn storage_type(&self) -> &StorageType { &self.storage_type } fn is_fully_contiguous(&self) -> bool { unimplemented!() } fn num_layers(&self) -> usize { unimplemented!() } /// Even though the block is logical, we still need to know this for the token block stuff. fn page_size(&self) -> usize { self.page_size } fn num_outer_dims(&self) -> usize { unimplemented!() } fn num_inner_dims(&self) -> usize { unimplemented!() } fn is_local(&self) -> Option<&dyn BlockDataViews> { None } fn is_local_mut(&mut self) -> Option<&mut dyn BlockDataViews> { None } }