Skip to main content

Crate tensor_wasm_tenant

Crate tensor_wasm_tenant 

Source
Expand description

Multi-tenant CUDA context management for Craton TensorWasm.

This crate owns the per-tenant runtime handle (TenantContext) and the concurrent registry that maps a tensor_wasm_core::types::TenantId to it (TenantRegistry). The registry also decides between MPS-backed shared contexts and per-tenant cuCtxCreate fallback via a filesystem probe — see docs/MPS-SETUP.md for daemon configuration and SECURITY.md for the threat model that motivates the IsolationKind taxonomy.

§Quick start

Two distinct capability primitives:

use tensor_wasm_core::types::TenantId;
use tensor_wasm_tenant::{TenantContext, TenantRegistry};

let (reg, admin_cap) = TenantRegistry::new();
let (ctx, tenant_cap) = reg
    .register_with_capability(TenantContext::builder(TenantId(1)).build())
    .unwrap();
ctx.consume_bytes_with_capability(&tenant_cap, 4096).unwrap();
assert_eq!(ctx.bytes_in_use(), 4096);
// Admin cap is required to look the tenant up again by id.
assert!(reg.get(TenantId(1), &admin_cap).is_some());

Re-exports§

pub use context::isolation_downgrade_count;
pub use context::IsolationKind;
pub use context::RateLimited;
pub use context::TenantCapability;
pub use context::TenantContext;
pub use context::TenantContextBuilder;
pub use registry::MpsDecision;
pub use registry::RegistryAdminCapability;
pub use registry::RegistryError;
pub use registry::TenantRegistry;
pub use registry::MPS_CONTROL_PATH;
pub use registry::MPS_PIPE_DIRECTORY_ENV;

Modules§

context
TenantContext: per-tenant CUDA context + stream + memory pool.
registry
TenantRegistry: TenantIdTenantContext mapping and lifecycle.