Skip to main content

Crate fuel_tensor

Crate fuel_tensor 

Source
Expand description

fuel-tensor — Fuel’s user-facing Tensor handle and Device abstraction, moved here from fuel-core (board #109; CireSnave: “Move Tensor into fuel-tensor. We can worry about a semantic split later.”). This is a MECHANICAL move – every item below kept its own content; only the crate boundary changed. fuel-core’s own lib.rs re-exports these same paths so existing fuel_tensor::lazy::Tensor / fuel::Tensor call sites keep compiling.

The moved cluster (lazy, device, the 3 GPU backend bridges, dtype’s WithDType/IntDType/FloatDType trio, pipelined_bridge, judge, factories, planner, decode_shape, lazy_latent_cache, test_utils, scheduling, inference_context, kv_block_pool_device, persistent_decode, nf4) moved together in one PR because it is one mutually-referencing graph, not several independent files that happen to touch Tensor – measured via a full crate::-reference census before any file moved, not assumed from file names. See docs/release-0.13.0-wave.md.

use fuel_tensor::lazy::{Tensor, realize_many_f32};
use fuel_tensor::Device;
let dev = Device::cpu();
let a = Tensor::from_f32((0..6).map(|x| x as f32).collect::<Vec<_>>(), (2, 3), &dev)?;
let b = Tensor::from_f32_on(a.graph(), (0..12).map(|x| x as f32).collect::<Vec<_>>(), (3, 4), &dev)?;
let c = a.matmul(&b)?;
assert_eq!(c.shape().dims(), &[2, 4]);
let out = realize_many_f32(&[&c]);
assert_eq!(out[0].len(), 8);

Re-exports§

pub use device::Device;
pub use device::NdArray;
pub use dtype::FloatDType;
pub use dtype::IntDType;
pub use dtype::WithDType;

Modules§

awq
HuggingFace *-AWQ (GEMM-version) weight loading (ROADMAP row 31).
cuda_backend
Thin re-export layer for CUDA backend types, plus the bridge that turns a [fuel_cuda_backend::CudaDevice] into a crate::Device.
decode_shape
The identity a held decode plan is baked against.
device
Device abstraction for CPU, CUDA, and Metal backends.
dtype
Types for elements that can be stored and manipulated using tensors.
factories
Backend factory registry — Step 12 of the backend-agnostic refactor.
inference_context
Persistent inference state for the pipelined executor (Phase 7.6 step 9c, sub-phase E.3.0).
judge
The Judge — Phase 6b’s empirical profiler.
kv_block_pool_device
Device-backed KV block pool — the thin integration layer that binds the pure KvBlockPool host-side allocator to real device Storage (multi-session serving, Increment 2, Part 2).
lazy
Phase 6a bridge: a lazy-computation-graph tensor that wraps fuel_graph::NodeHandle and presents it through an API compatible with fuel-core’s eager Tensor.
lazy_latent_cache
LatentCache — a general N-slot decode cache backed by Tensor, the structural generalization of [fuel_transformers::models::lazy_kv_cache:: LazyKvCache] that unblocks latent / pruned KV compression.
metal_backend
Thin re-export layer for Metal backend types, plus the bridge that turns a [fuel_metal_backend::MetalDevice] into a crate::Device.
nf4
bitsandbytes NF4 weight materialization helpers.
persistent_decode
The shared persistent-decode rebind driver (GAP-029 increment 2b).
pipelined_bridge
Bridge from fuel-core’s user-facing Tensor::realize_* API to fuel-storage’s PipelinedExecutor (Phase 7.6 step 9c, sub-phases E.1 + E.2).
planner
Load-time planning driver.
reproducibility
Strict reproducibility mode (ROADMAP item 13(b)).
scheduling
Orchestrator for the Phase 6b probe → judge → dispatch pipeline.
test_utils
Test helpers. The eager-Tensor helpers (test_device!, assert_tensor_eq, to_vec{0,1,2,3}_round) were removed in B6; what remains is host-slice and lazy infrastructure that the lazy_* port tests use.

Macros§

bail
Returns early from a function with a formatted error message.

Structs§

Layout
Describes the memory layout of a tensor: shape, strides, and start offset.
Shape
A shape represents the dimensions of a tensor.
Storage
Owns a typed contiguous buffer on one device. The boxed DynBackendStorage is the actual byte holder; Storage is a thin wrapper that gives the eager-dispatch op methods (matmul, conv, unary, binary, …) somewhere to live.

Enums§

D
Dimension indexing from the right (end) of a shape.
DType
The different types of elements allowed in tensors.
DTypeParseError
Error returned when a string cannot be parsed as a DType.
DeviceLocation
Identifies a physical device location (CPU or a specific GPU).
Error
The main error type for the fuel library.
HostBuffer
Host-addressable tensor storage holding a typed vector of elements.

Traits§

Context
Attach more context to an error.

Type Aliases§

Result
A specialized Result type for fuel operations.