interplane.Get Omega
Read in your language

aien-sovereign-core-mv

AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.

Brought by drakestapleton

GitHub aien-dev/aien-sovereign-core-mv#107 (code only)

closed derived 5f57e9b17c2f8bc5 #107

Imported from GitHub aien-dev/aien-sovereign-core-mv#107 (code only)

GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed).

Base 17d75028cab1d3bb4a89e6ac443c91096f9287af · Head 111e10acea762e3b4d29ee1087fd62b419ec4aaa

Apply it

git checkout -b patch-5f57e9b17c2f8bc5 17d75028cab1d3bb4a89e6ac443c91096f9287af
curl -fsSL https://interplane.io/drakestapleton/aien-sovereign-core-mv/patches/5f57e9b17c2f8bc5.patch | git am

Raw patch (mbox) · Diff

Provenance

This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:

github-import 1
aien-dev/aien-sovereign-core-mv
107
111e10acea762e3b4d29ee1087fd62b419ec4aaa
{"kind":"github-import","owner":"aien-dev","repo":"aien-sovereign-core-mv","number":107,"url":"https://github.com/aien-dev/aien-sovereign-core-mv/pull/107","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:35:58Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/Cargo.lock b/Cargo.lock
index 3da36e70..60733a20 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -86,6 +86,7 @@ dependencies = [
  "reqwest 0.12.28",
  "serde",
  "serde_json",
+ "sha2 0.10.9",
  "tokenizers",
  "tokio",
 ]
diff --git a/crates/aien-inference-abi/Cargo.toml b/crates/aien-inference-abi/Cargo.toml
index 52308ef5..74714647 100644
--- a/crates/aien-inference-abi/Cargo.toml
+++ b/crates/aien-inference-abi/Cargo.toml
@@ -18,5 +18,6 @@ rayon = "1.10"
 aien-kv-cache = { path = "../aien-kv-cache" }
 aien-platform = { path = "../aien-platform" }
 parking_lot = "0.12"
+sha2 = "0.10"
 
 
diff --git a/crates/aien-inference-abi/build.rs b/crates/aien-inference-abi/build.rs
index 66bda56f..199439aa 100644
--- a/crates/aien-inference-abi/build.rs
+++ b/crates/aien-inference-abi/build.rs
@@ -4,9 +4,11 @@ use std::process::Command;
 
 fn main() {
     println!("cargo:rustc-check-cfg=cfg(has_blackwell_cuda)");
+    println!("cargo:rerun-if-env-changed=AIEN_FORCE_CPU_STUB");
     println!("cargo:rerun-if-changed=cuda/blackwell_gemm.cu");
     println!("cargo:rerun-if-changed=cuda/paged_attention_bf16.cu");
     println!("cargo:rerun-if-changed=cuda/blackwell_layer.cu");
+    println!("cargo:rerun-if-changed=cuda/tensor_abi.h");
     println!("cargo:rerun-if-changed=build.rs");
 
     let nvcc = PathBuf::from("/usr/local/cuda/bin/nvcc");
diff --git a/crates/aien-inference-abi/cuda/blackwell_layer.cu b/crates/aien-inference-abi/cuda/blackwell_layer.cu
index 7dfb245b..a06218e7 100644
--- a/crates/aien-inference-abi/cuda/blackwell_layer.cu
+++ b/crates/aien-inference-abi/cuda/blackwell_layer.cu
@@ -5,6 +5,7 @@
 #include <stdio.h>
 #include <math.h>
 #include <atomic>
+#include "tensor_abi.h"
 
 extern std::atomic<uint64_t> g_kernel_exec_count;
 
@@ -24,12 +25,12 @@ struct KvLayoutDesc {
 
 // Resident Layer Weights on GPU
 struct BlackwellResidentLayerWeights {
-    float *d_norm1;      // [hidden_dim]
-    float *d_w_qkv;      // [q_dim + 2 * kv_dim, hidden_dim]
-    float *d_w_o;        // [hidden_dim, q_dim]
-    float *d_norm2;      // [hidden_dim]
-    float *d_w_gate_up;  // [2 * intermediate_dim, hidden_dim]
-    float *d_w_down;     // [hidden_dim, intermediate_dim]
+    ResidentTensor d_norm1;      // [hidden_dim]
+    ResidentTensor d_w_qkv;      // [q_dim + 2 * kv_dim, hidden_dim]
+    ResidentTensor d_w_o;        // [hidden_dim, q_dim]
+    ResidentTensor d_norm2;      // [hidden_dim]
+    ResidentTensor d_w_gate_up;  // [2 * intermediate_dim, hidden_dim]
+    ResidentTensor d_w_down;     // [hidden_dim, intermediate_dim]
 };
 
 // Resident Model Weights on GPU
@@ -44,10 +45,10 @@ struct BlackwellResidentModelWeights {
     float rms_norm_eps;
     float rope_theta;
 
-    float *d_embed_tokens; // [vocab_size, hidden_dim]
+    ResidentTensor d_embed_tokens; // [vocab_size, hidden_dim]
     BlackwellResidentLayerWeights *layers;
-    float *d_final_norm;   // [hidden_dim]
-    float *d_lm_head;      // [vocab_size, hidden_dim]
+    ResidentTensor d_final_norm;   // [hidden_dim]
+    ResidentTensor d_lm_head;      // [vocab_size, hidden_dim]
 };
 
 // Persistent GPU Activation Workspace
@@ -572,8 +573,116 @@ __global__ void argmax_sampling_kernel(
 // C-ABI Execution Functions
 // ----------------------------------------------------------------------------
 
+static bool valid_tensor_view(const TensorView *view) {
+    if (!view || !view->address || view->descriptor.residency != TENSOR_HOST ||
+        view->descriptor.rank == 0 || view->descriptor.rank > 4 ||
+        view->descriptor.byte_len == 0 ||
+        view->descriptor.byte_len > SIZE_MAX) return false;
+    const TensorDescriptor &desc = view->descriptor;
+    uint64_t bytes_per_element;
+    switch (desc.dtype) {
+        case TENSOR_F32: bytes_per_element = 4; break;
+        case TENSOR_BF16: case TENSOR_FP16: bytes_per_element = 2; break;
+        case TENSOR_FP8_E4M3FN: case TENSOR_FP8_E5M2:
+        case TENSOR_INT8: case TENSOR_INT4: bytes_per_element = 1; break;
+        default: return false;
+    }
+    if (desc.layout != TENSOR_ROW_MAJOR && desc.layout != TENSOR_COLUMN_MAJOR &&
+        desc.layout != TENSOR_STRIDED) return false;
+    if (desc.dtype == TENSOR_INT4 && desc.quant.packing == PACKING_NONE) return false;
+    if (desc.quant.scheme != QUANT_NONE && desc.quant.scheme != QUANT_SYMMETRIC &&
+        desc.quant.scheme != QUANT_AFFINE) return false;
+    if (desc.quant.scheme == QUANT_NONE &&
+        (desc.quant.scale_count || desc.quant.zero_point_count)) return false;
+    if (desc.quant.scheme != QUANT_NONE &&
+        (!desc.quant.scales || desc.quant.scale_count == 0)) return false;
+    if (desc.quant.scale_count && !desc.quant.scales) return false;
+    if (desc.quant.zero_point_count && !desc.quant.zero_points) return false;
+    if (desc.quant.scale_count > SIZE_MAX / sizeof(float) ||
+        desc.quant.zero_point_count > SIZE_MAX / sizeof(int32_t)) return false;
+    if (desc.layout == TENSOR_ROW_MAJOR) {
+        uint64_t elements = 1;
+        uint64_t stride = 1;
+        for (int index = (int)desc.rank - 1; index >= 0; --index) {
+            if (!desc.shape[index] || desc.strides[index] != stride ||
+                elements > UINT64_MAX / desc.shape[index] ||
+                stride > UINT64_MAX / desc.shape[index]) return false;
+            elements *= desc.shape[index];
+            stride *= desc.shape[index];
+        }
+        if (elements > UINT64_MAX / bytes_per_element) return false;
+        uint64_t expected = desc.dtype == TENSOR_INT4 ? elements / 2 + elements % 2 : elements * bytes_per_element;
+        if (desc.byte_len != expected) return false;
+    }
+    return true;
+}
+
+static bool dense_f32_view(const TensorView *view, uint32_t rank,
+                           uint64_t dim0, uint64_t dim1 = 0) {
+    return valid_tensor_view(view) && view->descriptor.dtype == TENSOR_F32 &&
+           view->descriptor.layout == TENSOR_ROW_MAJOR &&
+           view->descriptor.quant.scheme == QUANT_NONE &&
+           view->descriptor.rank == rank &&
+           view->descriptor.shape[0] == dim0 &&
+           (rank == 1 || view->descriptor.shape[1] == dim1);
+}
+
+static const float *dense_f32_data(const ResidentTensor &tensor) {
+    return static_cast<const float *>(tensor.address);
+}
+
+static bool resident_dense_f32(const ResidentTensor &tensor) {
+    return tensor.address && tensor.descriptor.residency == TENSOR_DEVICE &&
+           tensor.descriptor.dtype == TENSOR_F32 &&
+           tensor.descriptor.layout == TENSOR_ROW_MAJOR &&
+           tensor.descriptor.quant.scheme == QUANT_NONE;
+}
+
 extern "C" {
 
+int blackwell_tensor_upload(const TensorView *host, ResidentTensor *device,
+                            cudaStream_t stream) {
+    if (!device || !valid_tensor_view(host)) return -1;
+    *device = {};
+    device->descriptor = host->descriptor;
+    device->descriptor.residency = TENSOR_DEVICE;
+    device->descriptor.quant.scales = nullptr;
+    device->descriptor.quant.zero_points = nullptr;
+    if (cudaMalloc(&device->address, (size_t)host->descriptor.byte_len) != cudaSuccess) return -2;
+    if (cudaMemcpyAsync(device->address, host->address, (size_t)host->descriptor.byte_len,
+                        cudaMemcpyHostToDevice, stream) != cudaSuccess) goto failed;
+    if (host->descriptor.quant.scale_count) {
+        void *scales = nullptr;
+        size_t bytes = (size_t)host->descriptor.quant.scale_count * sizeof(float);
+        if (cudaMalloc(&scales, bytes) != cudaSuccess) goto failed;
+        device->descriptor.quant.scales = static_cast<const float *>(scales);
+        if (cudaMemcpyAsync(scales, host->descriptor.quant.scales, bytes,
+                            cudaMemcpyHostToDevice, stream) != cudaSuccess) goto failed;
+    }
+    if (host->descriptor.quant.zero_point_count) {
+        void *zero_points = nullptr;
+        size_t bytes = (size_t)host->descriptor.quant.zero_point_count * sizeof(int32_t);
+        if (cudaMalloc(&zero_points, bytes) != cudaSuccess) goto failed;
+        device->descriptor.quant.zero_points = static_cast<const int32_t *>(zero_points);
+        if (cudaMemcpyAsync(zero_points, host->descriptor.quant.zero_points, bytes,
+                            cudaMemcpyHostToDevice, stream) != cudaSuccess) goto failed;
+    }
+    // Host views may reference temporary fused buffers. Finish transfer before return.
+    if (cudaStreamSynchronize(stream) != cudaSuccess) goto failed;
+    return 0;
+failed:
+    blackwell_tensor_free(device);
+    return -3;
+}
+
+void blackwell_tensor_free(ResidentTensor *device) {
+    if (!device) return;
+    if (device->address) cudaFree(device->address);
+    if (device->descriptor.quant.scales) cudaFree((void *)device->descriptor.quant.scales);
+    if (device->descriptor.quant.zero_points) cudaFree((void *)device->descriptor.quant.zero_points);
+    *device = {};
+}
+
 int blackwell_execute_layer(
     int layer_idx,
     const BlackwellResidentLayerWeights *weights,
@@ -594,6 +703,12 @@ int blackwell_execute_layer(
 ) {
     int M = plan->num_tokens;
     if (M <= 0) return 0;
+    if (!resident_dense_f32(weights->d_norm1) ||
+        !resident_dense_f32(weights->d_w_qkv) ||
+        !resident_dense_f32(weights->d_w_o) ||
+        !resident_dense_f32(weights->d_norm2) ||
+        !resident_dense_f32(weights->d_w_gate_up) ||
+        !resident_dense_f32(weights->d_w_down)) return -2;
 
     float *d_x_in = is_ping ? workspace->d_x_b : workspace->d_x_a;
     float *d_x_out = is_ping ? workspace->d_x_a : workspace->d_x_b;
@@ -605,14 +720,14 @@ int blackwell_execute_layer(
 
     // 1. RMSNorm on x_in -> x_norm
     rmsnorm_batch_kernel<<<M, 256, 0, stream>>>(
-        d_x_in, weights->d_norm1, workspace->d_x_norm, M, hidden_dim, eps
+        d_x_in, dense_f32_data(weights->d_norm1), workspace->d_x_norm, M, hidden_dim, eps
     );
 
     // 2. Fused QKV GEMM -> qkv
     float alpha = 1.0f, beta = 0.0f;
     cublasSgemm(cublas_handle, CUBLAS_OP_T, CUBLAS_OP_N,
                 qkv_dim, M, hidden_dim,
-                &alpha, weights->d_w_qkv, hidden_dim,
+                &alpha, dense_f32_data(weights->d_w_qkv), hidden_dim,
                 workspace->d_x_norm, hidden_dim,
                 &beta, workspace->d_qkv, qkv_dim);
 
@@ -649,7 +764,7 @@ int blackwell_execute_layer(
     // 5. O Projection GEMM -> attn_proj
     cublasSgemm(cublas_handle, CUBLAS_OP_T, CUBLAS_OP_N,
                 hidden_dim, M, q_dim,
-                &alpha, weights->d_w_o, q_dim,
+                &alpha, dense_f32_data(weights->d_w_o), q_dim,
                 workspace->d_attn_out, q_dim,
                 &beta, workspace->d_attn_proj, hidden_dim);
 
@@ -661,13 +776,13 @@ int blackwell_execute_layer(
 
     // 7. Post-Attention RMSNorm -> post_norm
     rmsnorm_batch_kernel<<<M, 256, 0, stream>>>(
-        workspace->d_x_norm, weights->d_norm2, workspace->d_post_norm, M, hidden_dim, eps
+        workspace->d_x_norm, dense_f32_data(weights->d_norm2), workspace->d_post_norm, M, hidden_dim, eps
     );
 
     // 8. Fused Gate/Up GEMM -> gate_up
     cublasSgemm(cublas_handle, CUBLAS_OP_T, CUBLAS_OP_N,
                 2 * intermediate_dim, M, hidden_dim,
-                &alpha, weights->d_w_gate_up, hidden_dim,
+                &alpha, dense_f32_data(weights->d_w_gate_up), hidden_dim,
                 workspace->d_post_norm, hidden_dim,
                 &beta, workspace->d_gate_up, 2 * intermediate_dim);
 
@@ -680,7 +795,7 @@ int blackwell_execute_layer(
     // 10. Down Projection GEMM -> mlp_out
     cublasSgemm(cublas_handle, CUBLAS_OP_T, CUBLAS_OP_N,
                 hidden_dim, M, intermediate_dim,
-                &alpha, weights->d_w_down, intermediate_dim,
+                &alpha, dense_f32_data(weights->d_w_down), intermediate_dim,
                 workspace->d_act, intermediate_dim,
                 &beta, workspace->d_mlp_out, hidden_dim);
 
@@ -705,14 +820,17 @@ int blackwell_execute_step(
     int M = plan->num_tokens;
     if (M <= 0) return 0;
     int R = plan->terminal_count;
+    if (!resident_dense_f32(model->d_embed_tokens) ||
+        !resident_dense_f32(model->d_final_norm) ||
+        !resident_dense_f32(model->d_lm_head)) return -2;
 
     // Async upload of input embeddings or tokens to persistent GPU workspace
-    if (plan->h_input_tokens != NULL && model->d_embed_tokens != NULL) {
+    if (plan->h_input_tokens != NULL && model->d_embed_tokens.address != NULL) {
         cudaMemcpyAsync(workspace->d_tokens, plan->h_input_tokens,
                         (size_t)M * sizeof(uint32_t),
                         cudaMemcpyHostToDevice, stream);
         embedding_lookup_kernel<<<M, 256, 0, stream>>>(
-            workspace->d_tokens, model->d_embed_tokens, workspace->d_x_a,
+            workspace->d_tokens, dense_f32_data(model->d_embed_tokens), workspace->d_x_a,
             M, model->hidden_dim, model->vocab_size
         );
     } else if (plan->h_input_embeddings != NULL) {
@@ -754,13 +872,14 @@ int blackwell_execute_step(
 
     // Execute all layers sequentially on stream without synchronizing
     for (int l = 0; l < model->num_layers; l++) {
-        blackwell_execute_layer(
+        int layer_status = blackwell_execute_layer(
             l, &model->layers[l], plan, workspace, kv_pool, layout,
             stream, cublas_handle, l % 2,
             model->hidden_dim, model->num_q_heads, model->num_kv_heads,
             model->head_dim, model->intermediate_dim,
             model->rms_norm_eps, model->rope_theta
         );
+        if (layer_status != 0) return layer_status;
     }
 
     float *d_x_final = (model->num_layers % 2 == 1) ? workspace->d_x_b : workspace->d_x_a;
@@ -772,14 +891,14 @@ int blackwell_execute_step(
 
     // Final RMSNorm on terminal rows
     rmsnorm_batch_kernel<<<R, 256, 0, stream>>>(
-        workspace->d_term_x, model->d_final_norm, workspace->d_x_norm, R, model->hidden_dim, model->rms_norm_eps
+        workspace->d_term_x, dense_f32_data(model->d_final_norm), workspace->d_x_norm, R, model->hidden_dim, model->rms_norm_eps
     );
 
     // LM Head GEMM -> logits [R, vocab_size]
     float alpha = 1.0f, beta = 0.0f;
     cublasSgemm(cublas_handle, CUBLAS_OP_T, CUBLAS_OP_N,
                 model->vocab_size, R, model->hidden_dim,
-                &alpha, model->d_lm_head, model->hidden_dim,
+                &alpha, dense_f32_data(model->d_lm_head), model->hidden_dim,
                 workspace->d_x_norm, model->hidden_dim,
                 &beta, workspace->d_logits, model->vocab_size);
 
@@ -870,52 +989,53 @@ void blackwell_workspace_free(BlackwellWorkspaceC *ws) {
 }
 
 BlackwellResidentLayerWeights* blackwell_layer_weights_create(
-    const float *h_norm1,
-    const float *h_w_qkv,
-    const float *h_w_o,
-    const float *h_norm2,
-    const float *h_w_gate_up,
-    const float *h_w_down,
+    const TensorView *h_norm1,
+    const TensorView *h_w_qkv,
+    const TensorView *h_w_o,
+    const TensorView *h_norm2,
+    const TensorView *h_w_gate_up,
+    const TensorView *h_w_down,
     int hidden_dim,
     int q_dim,
     int kv_dim,
     int intermediate_dim,
     cudaStream_t stream
 ) {
+    int qkv_dim = q_dim + 2 * kv_dim;
+    if (!dense_f32_view(h_norm1, 1, hidden_dim) ||
+        !dense_f32_view(h_w_qkv, 2, qkv_dim, hidden_dim) ||
+        !dense_f32_view(h_w_o, 2, hidden_dim, q_dim) ||
+        !dense_f32_view(h_norm2, 1, hidden_dim) ||
+        !dense_f32_view(h_w_gate_up, 2, 2 * intermediate_dim, hidden_dim) ||
+        !dense_f32_view(h_w_down, 2, hidden_dim, intermediate_dim)) return NULL;
     BlackwellResidentLayerWeights *lw = (BlackwellResidentLayerWeights*)calloc(1, sizeof(BlackwellResidentLayerWeights));
     if (!lw) return NULL;
-
-    int qkv_dim = q_dim + 2 * kv_dim;
-
-    cudaMalloc((void**)&lw->d_norm1, (size_t)hidden_dim * sizeof(float));
-    cudaMemcpyAsync(lw->d_norm1, h_norm1, (size_t)hidden_dim * sizeof(float), cudaMemcpyHostToDevice, stream);
-
-    cudaMalloc((void**)&lw->d_w_qkv, (size_t)qkv_dim * hidden_dim * sizeof(float));
-    cudaMemcpyAsync(lw->d_w_qkv, h_w_qkv, (size_t)qkv_dim * hidden_dim * sizeof(float), cudaMemcpyHostToDevice, stream);
-
-    cudaMalloc((void**)&lw->d_w_o, (size_t)hidden_dim * q_dim * sizeof(float));
-    cudaMemcpyAsync(lw->d_w_o, h_w_o, (size_t)hidden_dim * q_dim * sizeof(float), cudaMemcpyHostToDevice, stream);
-
-    cudaMalloc((void**)&lw->d_norm2, (size_t)hidden_dim * sizeof(float));
-    cudaMemcpyAsync(lw->d_norm2, h_norm2, (size_t)hidden_dim * sizeof(float), cudaMemcpyHostToDevice, stream);
-
-    cudaMalloc((void**)&lw->d_w_gate_up, (size_t)2 * intermediate_dim * hidden_dim * sizeof(float));
-    cudaMemcpyAsync(lw->d_w_gate_up, h_w_gate_up, (size_t)2 * intermediate_dim * hidden_dim * sizeof(float), cudaMemcpyHostToDevice, stream);
-
-    cudaMalloc((void**)&lw->d_w_down, (size_t)hidden_dim * intermediate_dim * sizeof(float));
-    cudaMemcpyAsync(lw->d_w_down, h_w_down, (size_t)hidden_dim * intermediate_dim * sizeof(float), cudaMemcpyHostToDevice, stream);
-
+    if (blackwell_tensor_upload(h_norm1, &lw->d_norm1, stream) != 0 ||
+        blackwell_tensor_upload(h_w_qkv, &lw->d_w_qkv, stream) != 0 ||
+        blackwell_tensor_upload(h_w_o, &lw->d_w_o, stream) != 0 ||
+        blackwell_tensor_upload(h_norm2, &lw->d_norm2, stream) != 0 ||
+        blackwell_tensor_upload(h_w_gate_up, &lw->d_w_gate_up, stream) != 0 ||
+        blackwell_tensor_upload(h_w_down, &lw->d_w_down, stream) != 0) {
+        blackwell_tensor_free(&lw->d_norm1);
+        blackwell_tensor_free(&lw->d_w_qkv);
+        blackwell_tensor_free(&lw->d_w_o);
+        blackwell_tensor_free(&lw->d_norm2);
+        blackwell_tensor_free(&lw->d_w_gate_up);
+        blackwell_tensor_free(&lw->d_w_down);
+        free(lw);
+        return NULL;
+    }
     return lw;
 }
 
 void blackwell_layer_weights_free(BlackwellResidentLayerWeights *lw) {
     if (!lw) return;
-    if (lw->d_norm1) cudaFree(lw->d_norm1);
-    if (lw->d_w_qkv) cudaFree(lw->d_w_qkv);
-    if (lw->d_w_o) cudaFree(lw->d_w_o);
-    if (lw->d_norm2) cudaFree(lw->d_norm2);
-    if (lw->d_w_gate_up) cudaFree(lw->d_w_gate_up);
-    if (lw->d_w_down) cudaFree(lw->d_w_down);
+    blackwell_tensor_free(&lw->d_norm1);
+    blackwell_tensor_free(&lw->d_w_qkv);
+    blackwell_tensor_free(&lw->d_w_o);
+    blackwell_tensor_free(&lw->d_norm2);
+    blackwell_tensor_free(&lw->d_w_gate_up);
+    blackwell_tensor_free(&lw->d_w_down);
     free(lw);
 }
 
@@ -929,11 +1049,14 @@ BlackwellResidentModelWeights* blackwell_model_weights_create(
     int vocab_size,
     float rms_norm_eps,
     float rope_theta,
-    const float *h_embed_tokens,
-    const float *h_final_norm,
-    const float *h_lm_head,
+    const TensorView *h_embed_tokens,
+    const TensorView *h_final_norm,
+    const TensorView *h_lm_head,
     cudaStream_t stream
 ) {
+    if (!dense_f32_view(h_embed_tokens, 2, vocab_size, hidden_dim) ||
+        !dense_f32_view(h_final_norm, 1, hidden_dim) ||
+        !dense_f32_view(h_lm_head, 2, vocab_size, hidden_dim)) return NULL;
     BlackwellResidentModelWeights *mw = (BlackwellResidentModelWeights*)calloc(1, sizeof(BlackwellResidentModelWeights));
     if (!mw) return NULL;
 
@@ -948,16 +1071,17 @@ BlackwellResidentModelWeights* blackwell_model_weights_create(
     mw->rope_theta = rope_theta;
 
     mw->layers = (BlackwellResidentLayerWeights*)calloc(num_layers, sizeof(BlackwellResidentLayerWeights));
-
-    cudaMalloc((void**)&mw->d_embed_tokens, (size_t)vocab_size * hidden_dim * sizeof(float));
-    cudaMemcpyAsync(mw->d_embed_tokens, h_embed_tokens, (size_t)vocab_size * hidden_dim * sizeof(float), cudaMemcpyHostToDevice, stream);
-
-    cudaMalloc((void**)&mw->d_final_norm, (size_t)hidden_dim * sizeof(float));
-    cudaMemcpyAsync(mw->d_final_norm, h_final_norm, (size_t)hidden_dim * sizeof(float), cudaMemcpyHostToDevice, stream);
-
-    cudaMalloc((void**)&mw->d_lm_head, (size_t)vocab_size * hidden_dim * sizeof(float));
-    cudaMemcpyAsync(mw->d_lm_head, h_lm_head, (size_t)vocab_size * hidden_dim * sizeof(float), cudaMemcpyHostToDevice, stream);
-
+    if (!mw->layers ||
+        blackwell_tensor_upload(h_embed_tokens, &mw->d_embed_tokens, stream) != 0 ||
+        blackwell_tensor_upload(h_final_norm, &mw->d_final_norm, stream) != 0 ||
+        blackwell_tensor_upload(h_lm_head, &mw->d_lm_head, stream) != 0) {
+        blackwell_tensor_free(&mw->d_embed_tokens);
+        blackwell_tensor_free(&mw->d_final_norm);
+        blackwell_tensor_free(&mw->d_lm_head);
+        free(mw->layers);
+        free(mw);
+        return NULL;
+    }
     return mw;
 }
 
@@ -968,6 +1092,7 @@ void blackwell_model_weights_set_layer(
 ) {
     if (mw && lw && layer_idx >= 0 && layer_idx < mw->num_layers) {
         mw->layers[layer_idx] = *lw;
+        free((void *)lw);
     }
 }
 
@@ -975,18 +1100,18 @@ void blackwell_model_weights_free(BlackwellResidentModelWeights *mw) {
     if (!mw) return;
     if (mw->layers) {
         for (int i = 0; i < mw->num_layers; i++) {
-            if (mw->layers[i].d_norm1) cudaFree(mw->layers[i].d_norm1);
-            if (mw->layers[i].d_w_qkv) cudaFree(mw->layers[i].d_w_qkv);
-            if (mw->layers[i].d_w_o) cudaFree(mw->layers[i].d_w_o);
-            if (mw->layers[i].d_norm2) cudaFree(mw->layers[i].d_norm2);
-            if (mw->layers[i].d_w_gate_up) cudaFree(mw->layers[i].d_w_gate_up);
-            if (mw->layers[i].d_w_down) cudaFree(mw->layers[i].d_w_down);
+            blackwell_tensor_free(&mw->layers[i].d_norm1);
+            blackwell_tensor_free(&mw->layers[i].d_w_qkv);
+            blackwell_tensor_free(&mw->layers[i].d_w_o);
+            blackwell_tensor_free(&mw->layers[i].d_norm2);
+            blackwell_tensor_free(&mw->layers[i].d_w_gate_up);
+            blackwell_tensor_free(&mw->layers[i].d_w_down);
         }
         free(mw->layers);
     }
-    if (mw->d_embed_tokens) cudaFree(mw->d_embed_tokens);
-    if (mw->d_final_norm) cudaFree(mw->d_final_norm);
-    if (mw->d_lm_head) cudaFree(mw->d_lm_head);
+    blackwell_tensor_free(&mw->d_embed_tokens);
+    blackwell_tensor_free(&mw->d_final_norm);
+    blackwell_tensor_free(&mw->d_lm_head);
     free(mw);
 }
 
diff --git a/crates/aien-inference-abi/cuda/tensor_abi.h b/crates/aien-inference-abi/cuda/tensor_abi.h
new file mode 100644
index 00000000..a119e845
--- /dev/null
+++ b/crates/aien-inference-abi/cuda/tensor_abi.h
@@ -0,0 +1,61 @@
+#pragma once
+
+#include <cuda_runtime.h>
+#include <stdint.h>
+
+// Numeric tags mirror src/tensor_abi.rs. Keep this layout stable across FFI.
+enum TensorDType : uint32_t {
+    TENSOR_F32 = 1, TENSOR_BF16 = 2, TENSOR_FP16 = 3,
+    TENSOR_FP8_E4M3FN = 4, TENSOR_FP8_E5M2 = 5,
+    TENSOR_INT8 = 6, TENSOR_INT4 = 7,
+};
+enum TensorLayout : uint32_t {
+    TENSOR_ROW_MAJOR = 1, TENSOR_COLUMN_MAJOR = 2, TENSOR_STRIDED = 3,
+};
+enum TensorResidency : uint32_t { TENSOR_HOST = 1, TENSOR_DEVICE = 2 };
+enum QuantScheme : uint32_t { QUANT_NONE = 0, QUANT_SYMMETRIC = 1, QUANT_AFFINE = 2 };
+enum TensorPacking : uint32_t {
+    PACKING_NONE = 0, INT4_LOW_SIGNED = 1, INT4_HIGH_SIGNED = 2,
+    INT4_LOW_UNSIGNED = 3, INT4_HIGH_UNSIGNED = 4,
+};
+
+struct AbiQuantization {
+    QuantScheme scheme;
+    int32_t axis;
+    uint32_t group_size;
+    TensorPacking packing;
+    const float *scales;
+    uint64_t scale_count;
+    const int32_t *zero_points;
+    uint64_t zero_point_count;
+};
+
+struct TensorDescriptor {
+    TensorDType dtype;
+    TensorLayout layout;
+    uint32_t rank;
+    TensorResidency residency;
+    uint64_t shape[4];
+    uint64_t strides[4];
+    uint64_t byte_len;
+    AbiQuantization quant;
+};
+
+struct TensorView {
+    const void *address;
+    TensorDescriptor descriptor;
+};
+
+struct ResidentTensor {
+    void *address;
+    TensorDescriptor descriptor;
+};
+
+static_assert(sizeof(AbiQuantization) == 48, "quant ABI drift");
+static_assert(sizeof(TensorDescriptor) == 136, "tensor descriptor ABI drift");
+static_assert(sizeof(TensorView) == 144, "tensor view ABI drift");
+static_assert(sizeof(ResidentTensor) == 144, "resident tensor ABI drift");
+
+extern "C" int blackwell_tensor_upload(
+    const TensorView *host, ResidentTensor *device, cudaStream_t stream);
+extern "C" void blackwell_tensor_free(ResidentTensor *device);
diff --git a/crates/aien-inference-abi/src/blackwell_batch_executor.rs b/crates/aien-inference-abi/src/blackwell_batch_executor.rs
index e7494dcf..172416f2 100644
--- a/crates/aien-inference-abi/src/blackwell_batch_executor.rs
+++ b/crates/aien-inference-abi/src/blackwell_batch_executor.rs
@@ -10,6 +10,9 @@
 //! - Strict KV transaction semantics (reserve -> execute -> commit / rollback).
 //! - Zero CPU fallback in accelerated mode.
 
+use crate::tensor_abi::ResidentTensor;
+#[cfg(has_blackwell_cuda)]
+use crate::tensor_abi::TensorView;
 use crate::weights::TransformerWeights;
 use crate::{AienInferenceBackend, DecodeOutput, ModelConfig, ScheduledBatch, StepMetrics};
 #[allow(unused_imports)]
@@ -20,12 +23,12 @@ use std::time::Instant;
 
 #[repr(C)]
 pub struct BlackwellResidentLayerWeights {
-    pub d_norm1: *mut f32,
-    pub d_w_qkv: *mut f32,
-    pub d_w_o: *mut f32,
-    pub d_norm2: *mut f32,
-    pub d_w_gate_up: *mut f32,
-    pub d_w_down: *mut f32,
+    pub d_norm1: ResidentTensor,
+    pub d_w_qkv: ResidentTensor,
+    pub d_w_o: ResidentTensor,
+    pub d_norm2: ResidentTensor,
+    pub d_w_gate_up: ResidentTensor,
+    pub d_w_down: ResidentTensor,
 }
 
 #[repr(C)]
@@ -40,10 +43,10 @@ pub struct BlackwellResidentModelWeights {
     pub rms_norm_eps: f32,
     pub rope_theta: f32,
 
-    pub d_embed_tokens: *mut f32,
+    pub d_embed_tokens: ResidentTensor,
     pub layers: *mut BlackwellResidentLayerWeights,
-    pub d_final_norm: *mut f32,
-    pub d_lm_head: *mut f32,
+    pub d_final_norm: ResidentTensor,
+    pub d_lm_head: ResidentTensor,
 }
 
 #[repr(C)]
@@ -112,12 +115,12 @@ extern "C" {
     fn blackwell_workspace_free(ws: *mut BlackwellWorkspaceC);
 
     fn blackwell_layer_weights_create(
-        h_norm1: *const f32,
-        h_w_qkv: *const f32,
-        h_w_o: *const f32,
-        h_norm2: *const f32,
-        h_w_gate_up: *const f32,
-        h_w_down: *const f32,
+        h_norm1: *const TensorView,
+        h_w_qkv: *const TensorView,
+        h_w_o: *const TensorView,
+        h_norm2: *const TensorView,
+        h_w_gate_up: *const TensorView,
+        h_w_down: *const TensorView,
         hidden_dim: std::os::raw::c_int,
         q_dim: std::os::raw::c_int,
         kv_dim: std::os::raw::c_int,
@@ -138,9 +141,9 @@ extern "C" {
         vocab_size: std::os::raw::c_int,
         rms_norm_eps: f32,
         rope_theta: f32,
-        h_embed_tokens: *const f32,
-        h_final_norm: *const f32,
-        h_lm_head: *const f32,
+        h_embed_tokens: *const TensorView,
+        h_final_norm: *const TensorView,
+        h_lm_head: *const TensorView,
         stream: *mut std::ffi::c_void,
     ) -> *mut BlackwellResidentModelWeights;
 
@@ -306,6 +309,11 @@ impl BlackwellBatchExecutor {
             };
 
             // 2. Create resident model weights
+            let embed_view =
+                TensorView::f32_contiguous(&weights.embed_tokens, &[vocab_size, hidden_dim])?;
+            let final_norm_view = TensorView::f32_contiguous(&weights.final_norm, &[hidden_dim])?;
+            let lm_head_view =
+                TensorView::f32_contiguous(&weights.lm_head, &[vocab_size, hidden_dim])?;
             let model_raw = unsafe {
                 blackwell_model_weights_create(
                     config.num_layers as i32,
@@ -317,15 +325,19 @@ impl BlackwellBatchExecutor {
                     vocab_size as i32,
                     config.rms_norm_eps,
                     config.rope_theta,
-                    weights.embed_tokens.as_ptr(),
-                    weights.final_norm.as_ptr(),
-                    weights.lm_head.as_ptr(),
+                    embed_view.as_abi(),
+                    final_norm_view.as_abi(),
+                    lm_head_view.as_abi(),
                     stream,
                 )
             };
             if model_raw.is_null() {
                 return Err("Failed to allocate BlackwellResidentModelWeights on GB10".to_string());
             }
+            let resident_model = BlackwellResidentModel {
+                config: config.clone(),
+                raw: model_raw,
+            };
 
             // 3. Fuse and upload layer weights:
             // W_qkv has width q_dim + 2 * kv_dim (Section 6 correction)
@@ -344,14 +356,26 @@ impl BlackwellBatchExecutor {
                 fused_gate_up[intermediate_dim * hidden_dim..2 * intermediate_dim * hidden_dim]
                     .copy_from_slice(&lw.up_proj);
 
+                let norm1_view = TensorView::f32_contiguous(&lw.input_layernorm, &[hidden_dim])?;
+                let qkv_view = TensorView::f32_contiguous(&fused_qkv, &[qkv_dim, hidden_dim])?;
+                let o_view = TensorView::f32_contiguous(&lw.o_proj, &[hidden_dim, q_dim])?;
+                let norm2_view =
+                    TensorView::f32_contiguous(&lw.post_attention_layernorm, &[hidden_dim])?;
+                let gate_up_view = TensorView::f32_contiguous(
+                    &fused_gate_up,
+                    &[2 * intermediate_dim, hidden_dim],
+                )?;
+                let down_view =
+                    TensorView::f32_contiguous(&lw.down_proj, &[hidden_dim, intermediate_dim])?;
+
                 let layer_raw = unsafe {
                     blackwell_layer_weights_create(
-                        lw.input_layernorm.as_ptr(),
-                        fused_qkv.as_ptr(),
-                        lw.o_proj.as_ptr(),
-                        lw.post_attention_layernorm.as_ptr(),
-                        fused_gate_up.as_ptr(),
-                        lw.down_proj.as_ptr(),
+                        norm1_view.as_abi(),
+                        qkv_view.as_abi(),
+                        o_view.as_abi(),
+                        norm2_view.as_abi(),
+                        gate_up_view.as_abi(),
+                        down_view.as_abi(),
                         hidden_dim as i32,
                         q_dim as i32,
                         kv_dim as i32,
@@ -369,11 +393,6 @@ impl BlackwellBatchExecutor {
                 }
             }
 
-            let resident_model = BlackwellResidentModel {
-                config: config.clone(),
-                raw: model_raw,
-            };
-
             Ok(Self {
                 config,
                 resident_model,
@@ -721,6 +740,43 @@ impl BlackwellBatchExecutor {
     }
 }
 
+#[cfg(all(test, has_blackwell_cuda))]
+mod typed_residency_tests {
+    use super::*;
+    use crate::tensor_abi::{AbiDType, AbiResidency};
+
+    #[test]
+    fn dense_weights_keep_f32_values_with_typed_residency() {
+        let config = ModelConfig {
+            model_id: "typed-residency-test".to_string(),
+            max_sequence_length: 16,
+            block_size: 16,
+            num_layers: 1,
+            num_heads: 2,
+            head_dim: 8,
+            num_kv_heads: 1,
+            hidden_dim: 16,
+            intermediate_dim: 32,
+            vocab_size: 32,
+            rms_norm_eps: 1e-5,
+            rope_theta: 10000.0,
+        };
+        let weights = TransformerWeights::reference_test_weights(&config);
+        let executor = BlackwellBatchExecutor::new(&weights, 2).unwrap();
+        let model = unsafe { &*executor.resident_model.raw };
+        assert_eq!(model.d_embed_tokens.descriptor.dtype, AbiDType::F32);
+        assert_eq!(
+            model.d_embed_tokens.descriptor.residency,
+            AbiResidency::Device
+        );
+        assert_eq!(model.d_embed_tokens.descriptor.shape[..2], [32, 16]);
+        let layer = unsafe { &*model.layers };
+        assert_eq!(layer.d_w_qkv.descriptor.dtype, AbiDType::F32);
+        assert_eq!(layer.d_w_qkv.descriptor.shape[..2], [32, 16]);
+        assert_eq!(layer.d_w_gate_up.descriptor.shape[..2], [64, 16]);
+    }
+}
+
 #[async_trait]
 impl AienInferenceBackend for BlackwellBatchExecutor {
     async fn load_model(&mut self, _config: &ModelConfig) -> Result<(), String> {
diff --git a/crates/aien-inference-abi/src/capsule.rs b/crates/aien-inference-abi/src/capsule.rs
new file mode 100644
index 00000000..b882f424
--- /dev/null
+++ b/crates/aien-inference-abi/src/capsule.rs
@@ -0,0 +1,347 @@
+//! Weight capsule: raw payload bytes plus a tensor index and canonical digests.
+
+use sha2::{Digest, Sha256};
+use std::collections::HashMap;
+use std::fmt;
+use std::ops::Range;
+use std::sync::Arc;
+
+use crate::checkpoint::decode_bf16_to_fp32;
+
+/// Element type stored in a capsule tensor payload.
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
+pub enum WeightDType {
+    F32,
+    Bf16,
+    Fp16,
+    Fp8E4M3Fn,
+    Fp8E5M2,
+    Int8,
+    Int4,
+}
+
+impl WeightDType {
+    fn label(self) -> &'static str {
+        match self {
+            WeightDType::F32 => "f32",
+            WeightDType::Bf16 => "bf16",
+            WeightDType::Fp16 => "fp16",
+            WeightDType::Fp8E4M3Fn => "fp8e4m3fn",
+            WeightDType::Fp8E5M2 => "fp8e5m2",
+            WeightDType::Int8 => "int8",
+            WeightDType::Int4 => "int4",
+        }
+    }
+}
+
+/// Logical tensor layout, independent of packed byte encoding.
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
+pub enum TensorLayout {
+    RowMajor,
+    ColumnMajor,
+    Strided,
+}
+
+impl TensorLayout {
+    fn label(self) -> &'static str {
+        match self {
+            Self::RowMajor => "row-major",
+            Self::ColumnMajor => "column-major",
+            Self::Strided => "strided",
+        }
+    }
+}
+
+/// Quantization metadata. IEEE dtypes use packing `"none"`.
+#[derive(Debug, Clone, PartialEq)]
+pub struct QuantizationDescriptor {
+    pub scheme: String,
+    pub axis: usize,
+    pub group_size: usize,
+    pub scales: Vec<f32>,
+    pub zero_points: Vec<i32>,
+    pub packing: String, // "none" for IEEE dtypes; INT4 uses an explicit nibble order and sign
+}
+
+/// One named tensor view into [`ModelCapsule::bytes`].
+#[derive(Debug, Clone, PartialEq)]
+pub struct CapsuleTensor {
+    pub dtype: WeightDType,
+    pub layout: TensorLayout,
+    pub shape: Vec<usize>,
+    pub logical_strides: Vec<usize>, // element strides for the selected layout
+    pub byte_range: Range<usize>,    // into ModelCapsule::bytes, the whole file
+    pub quant: Option<QuantizationDescriptor>,
+}
+
+/// Immutable model payload plus its tensor index.
+#[derive(Debug, Clone, PartialEq)]
+pub struct ModelCapsule {
+    pub bytes: Arc<[u8]>,
+    pub source_digest: String, // lowercase hex sha256 of bytes
+    pub tensors: HashMap<String, CapsuleTensor>,
+    pub capsule_digest: String,
+}
+
+/// Failures when reading a tensor out of a capsule.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub enum CapsuleError {
+    MissingTensor(String),
+    UnsupportedDtype(String),
+    BadRange(String),
+}
+
+impl fmt::Display for CapsuleError {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        match self {
+            CapsuleError::MissingTensor(name) => write!(f, "missing tensor {name}"),
+            CapsuleError::UnsupportedDtype(dtype) => write!(f, "unsupported dtype {dtype}"),
+            CapsuleError::BadRange(detail) => write!(f, "bad range {detail}"),
+        }
+    }
+}
+
+impl std::error::Error for CapsuleError {}
+
+impl ModelCapsule {
+    pub fn tensor(&self, name: &str) -> Result<&CapsuleTensor, CapsuleError> {
+        self.tensors
+            .get(name)
+            .ok_or_else(|| CapsuleError::MissingTensor(name.to_string()))
+    }
+
+    pub fn tensor_bytes(&self, name: &str) -> Result<&[u8], CapsuleError> {
+        let tensor = self.tensor(name)?;
+        let range = &tensor.byte_range;
+        if range.start > range.end || range.end > self.bytes.len() {
+            return Err(CapsuleError::BadRange(format!(
+                "{name} range {}-{} outside payload length {}",
+                range.start,
+                range.end,
+                self.bytes.len()
+            )));
+        }
+        Ok(&self.bytes[range.start..range.end])
+    }
+
+    /// Allocates. BF16 uses the existing decode_bf16_to_fp32 from checkpoint.rs (crate::checkpoint::decode_bf16_to_fp32). F32 interprets little-endian f32. Other dtypes return UnsupportedDtype. Do not store a decoded copy on the struct.
+    pub fn decode_fp32(&self, name: &str) -> Result<Vec<f32>, CapsuleError> {
+        let tensor = self.tensor(name)?;
+        let raw = self.tensor_bytes(name)?;
+        match tensor.dtype {
+            WeightDType::F32 => {
+                if raw.len() % 4 != 0 {
+                    return Err(CapsuleError::BadRange(format!(
+                        "{name} f32 payload length {} is not a multiple of 4",
+                        raw.len()
+                    )));
+                }
+                let mut out = Vec::with_capacity(raw.len() / 4);
+                for chunk in raw.chunks_exact(4) {
+                    let bits = u32::from_le_bytes([chunk[0], chunk[1], chunk[2], chunk[3]]);
+                    out.push(f32::from_bits(bits));
+                }
+                Ok(out)
+            }
+            WeightDType::Bf16 => Ok(decode_bf16_to_fp32(raw)),
+            other => Err(CapsuleError::UnsupportedDtype(other.label().to_string())),
+        }
+    }
+
+    pub fn owned_payload_len(&self) -> usize {
+        self.bytes.len()
+    }
+}
+
+fn sha256_hex(parts: &[&[u8]]) -> String {
+    let mut hasher = Sha256::new();
+    for part in parts {
+        hasher.update(part);
+    }
+    let digest = hasher.finalize();
+    let mut hex = String::with_capacity(digest.len() * 2);
+    for byte in digest {
+        hex.push_str(&format!("{byte:02x}"));
+    }
+    hex
+}
+
+/// Lowercase hex SHA-256 of `bytes`.
+pub fn source_digest(bytes: &[u8]) -> String {
+    sha256_hex(&[bytes])
+}
+
+/// Canonical capsule digest over the stored bytes and every tensor descriptor.
+/// The length-prefixed binary manifest is sorted by tensor name and versioned.
+pub fn capsule_digest(bytes: &[u8], tensors: &HashMap<String, CapsuleTensor>) -> String {
+    let mut names: Vec<&String> = tensors.keys().collect();
+    names.sort();
+    let mut manifest = Vec::new();
+    manifest.extend_from_slice(b"AIEN-CAPSULE-V1\0");
+    push_len(&mut manifest, names.len());
+    for name in names {
+        let tensor = &tensors[name];
+        push_bytes(&mut manifest, name.as_bytes());
+        push_bytes(&mut manifest, tensor.dtype.label().as_bytes());
+        push_bytes(&mut manifest, tensor.layout.label().as_bytes());
+        push_len(&mut manifest, tensor.shape.len());
+        for dim in &tensor.shape {
+            push_len(&mut manifest, *dim);
+        }
+        push_len(&mut manifest, tensor.logical_strides.len());
+        for stride in &tensor.logical_strides {
+            push_len(&mut manifest, *stride);
+        }
+        push_len(&mut manifest, tensor.byte_range.start);
+        push_len(&mut manifest, tensor.byte_range.end);
+        match &tensor.quant {
+            None => manifest.push(0),
+            Some(quant) => {
+                manifest.push(1);
+                push_bytes(&mut manifest, quant.scheme.as_bytes());
+                push_len(&mut manifest, quant.axis);
+                push_len(&mut manifest, quant.group_size);
+                push_len(&mut manifest, quant.scales.len());
+                for scale in &quant.scales {
+                    manifest.extend_from_slice(&scale.to_bits().to_le_bytes());
+                }
+                push_len(&mut manifest, quant.zero_points.len());
+                for zero_point in &quant.zero_points {
+                    manifest.extend_from_slice(&zero_point.to_le_bytes());
+                }
+                push_bytes(&mut manifest, quant.packing.as_bytes());
+            }
+        }
+    }
+    sha256_hex(&[&manifest, bytes])
+}
+
+fn push_len(buf: &mut Vec<u8>, value: usize) {
+    buf.extend_from_slice(&(value as u64).to_le_bytes());
+}
+
+fn push_bytes(buf: &mut Vec<u8>, value: &[u8]) {
+    push_len(buf, value.len());
+    buf.extend_from_slice(value);
+}
+
+/// Element strides for row-major (C) layout. The last axis has stride 1.
+pub fn row_major_strides(shape: &[usize]) -> Vec<usize> {
+    let rank = shape.len();
+    let mut strides = vec![0; rank];
+    if rank == 0 {
+        return strides;
+    }
+    strides[rank - 1] = 1;
+    for index in (0..rank - 1).rev() {
+        strides[index] = strides[index + 1] * shape[index + 1];
+    }
+    strides
+}
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    #[test]
+    fn source_digest_of_abc_matches_well_known_sha256() {
+        let digest = source_digest(b"abc");
+        assert_eq!(
+            digest,
+            "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"
+        );
+    }
+
+    fn sample_tensor(
+        dtype: WeightDType,
+        shape: Vec<usize>,
+        byte_range: Range<usize>,
+    ) -> CapsuleTensor {
+        let logical_strides = row_major_strides(&shape);
+        CapsuleTensor {
+            dtype,
+            layout: TensorLayout::RowMajor,
+            shape,
+            logical_strides,
+            byte_range,
+            quant: None,
+        }
+    }
+
+    #[test]
+    fn capsule_digest_is_stable_across_hashmap_insertion_order() {
+        let bytes = b"raw-payload-bytes";
+        let tensor_a = sample_tensor(WeightDType::Bf16, vec![2], 0..2);
+        let tensor_b = sample_tensor(WeightDType::F32, vec![1, 1], 2..6);
+
+        let mut first = HashMap::new();
+        first.insert("zeta".to_string(), tensor_a.clone());
+        first.insert("alpha".to_string(), tensor_b.clone());
+
+        let mut second = HashMap::new();
+        second.insert("alpha".to_string(), tensor_b.clone());
+        second.insert("zeta".to_string(), tensor_a.clone());
+
+        let digest_first = capsule_digest(bytes, &first);
+        let digest_second = capsule_digest(bytes, &second);
+        assert_eq!(digest_first, digest_second);
+
+        let mut changed = second.clone();
+        changed.get_mut("alpha").unwrap().logical_strides = vec![2, 1];
+        assert_ne!(digest_first, capsule_digest(bytes, &changed));
+
+        let mut changed = second;
+        changed.get_mut("zeta").unwrap().quant = Some(QuantizationDescriptor {
+            scheme: "test".to_string(),
+            axis: 0,
+            group_size: 2,
+            scales: vec![1.0],
+            zero_points: vec![0],
+            packing: "none".to_string(),
+        });
+        assert_ne!(digest_first, capsule_digest(bytes, &changed));
+    }
+
+    #[test]
+    fn decode_fp32_bf16_one_and_owned_len_and_missing_tensor() {
+        let raw = [0x80u8, 0x3f];
+        let bytes: Arc<[u8]> = Arc::from(raw.as_slice());
+        let mut tensors = HashMap::new();
+        tensors.insert(
+            "w".to_string(),
+            sample_tensor(WeightDType::Bf16, vec![1], 0..2),
+        );
+        let capsule = ModelCapsule {
+            source_digest: source_digest(&bytes),
+            capsule_digest: capsule_digest(&bytes, &tensors),
+            bytes: Arc::clone(&bytes),
+            tensors,
+        };
+
+        let decoded = capsule.decode_fp32("w").unwrap();
+        assert_eq!(decoded.len(), 1);
+        assert!((decoded[0] - 1.0).abs() < 1e-6);
+        assert_eq!(capsule.owned_payload_len(), capsule.bytes.len());
+        assert_eq!(capsule.owned_payload_len(), 2);
+
+        match capsule.tensor("missing") {
+            Err(CapsuleError::MissingTensor(name)) => assert_eq!(name, "missing"),
+            other => panic!("expected MissingTensor, got {other:?}"),
+        }
+        match capsule.decode_fp32("missing") {
+            Err(CapsuleError::MissingTensor(name)) => assert_eq!(name, "missing"),
+            other => panic!("expected MissingTensor, got {other:?}"),
+        }
+        match capsule.tensor_bytes("missing") {
+            Err(CapsuleError::MissingTensor(name)) => assert_eq!(name, "missing"),
+            other => panic!("expected MissingTensor, got {other:?}"),
+        }
+    }
+
+    #[test]
+    fn row_major_strides_match_c_order() {
+        assert_eq!(row_major_strides(&[]), Vec::<usize>::new());
+        assert_eq!(row_major_strides(&[4]), vec![1]);
+        assert_eq!(row_major_strides(&[2, 3, 4]), vec![12, 4, 1]);
+    }
+}
diff --git a/crates/aien-inference-abi/src/checkpoint.rs b/crates/aien-inference-abi/src/checkpoint.rs
index fc6a7d8a..ebd06fce 100644
--- a/crates/aien-inference-abi/src/checkpoint.rs
+++ b/crates/aien-inference-abi/src/checkpoint.rs
@@ -1,9 +1,10 @@
 //! Strict Safetensors checkpoint loader with loud shape and dtype validation.
-//! Ingests BF16 weights, decodes to FP32 for oracle evaluation, and preserves raw BF16 bytes for acceleration.
+//! Ingests BF16 weights into one `ModelCapsule`. FP32 is decoded on demand.
 
 use std::collections::HashMap;
 use std::fmt;
 use std::path::Path;
+use std::sync::Arc;
 
 /// Loud error enum describing checkpoint parsing and validation failures.
 #[derive(Debug, Clone, PartialEq, Eq)]
@@ -30,6 +31,8 @@ pub enum CheckpointError {
     },
     /// Safetensors binary header is malformed, truncated, or invalid JSON.
     InvalidHeader(String),
+    /// A capsule tensor could not be decoded.
+    Capsule(String),
 }
 
 impl fmt::Display for CheckpointError {
@@ -74,44 +77,91 @@ impl fmt::Display for CheckpointError {
             Self::InvalidHeader(err) => {
                 write!(f, "Invalid safetensors header: {}", err)
             }
+            Self::Capsule(err) => write!(f, "Invalid capsule tensor: {}", err),
         }
     }
 }
 
 impl std::error::Error for CheckpointError {}
 
-/// Dual storage representation of loaded model weights:
-/// FP32 floats for the reference correctness oracle and raw BF16 bytes for hardware kernels.
-#[derive(Debug, Clone, Default)]
+/// Checkpoint stored as one capsule. Tensor bytes stay in `capsule.bytes`.
+/// FP32 is produced by `decode_fp32` and is not retained.
+#[derive(Debug, Clone)]
 pub struct LoadedCheckpoint {
-    pub fp32_weights: HashMap<String, Vec<f32>>,
-    pub raw_bf16_weights: HashMap<String, Vec<u8>>,
-    pub shapes: HashMap<String, Vec<usize>>,
+    pub capsule: crate::capsule::ModelCapsule,
+}
+
+impl Default for LoadedCheckpoint {
+    fn default() -> Self {
+        Self::new()
+    }
 }
 
 impl LoadedCheckpoint {
+    /// Empty capsule: empty byte buffer, empty tensor map, digests of that empty input.
     pub fn new() -> Self {
-        Self::default()
+        Self::from_bf16_tensors(Vec::new())
+    }
+
+    /// Builds a checkpoint from BF16 payloads without a safetensors file.
+    /// Payloads are concatenated into one `Arc<[u8]>`. Each tensor records its range.
+    pub fn from_bf16_tensors(items: Vec<(String, Vec<usize>, Vec<u8>)>) -> Self {
+        let mut payload = Vec::new();
+        let mut tensors = HashMap::with_capacity(items.len());
+        for (name, shape, raw) in items {
+            let start = payload.len();
+            payload.extend_from_slice(&raw);
+            let end = payload.len();
+            let logical_strides = crate::capsule::row_major_strides(&shape);
+            tensors.insert(
+                name,
+                crate::capsule::CapsuleTensor {
+                    dtype: crate::capsule::WeightDType::Bf16,
+                    layout: crate::capsule::TensorLayout::RowMajor,
+                    shape,
+                    logical_strides,
+                    byte_range: start..end,
+                    quant: None,
+                },
+            );
+        }
+        Self::from_owned_bytes(Arc::from(payload), tensors)
     }
 
     pub fn tensor_count(&self) -> usize {
-        self.fp32_weights.len()
+        self.capsule.tensors.len()
     }
 
     pub fn contains_tensor(&self, name: &str) -> bool {
-        self.fp32_weights.contains_key(name)
+        self.capsule.tensors.contains_key(name)
     }
 
-    pub fn get_fp32(&self, name: &str) -> Option<&Vec<f32>> {
-        self.fp32_weights.get(name)
+    pub fn decode_fp32(&self, name: &str) -> Result<Vec<f32>, crate::capsule::CapsuleError> {
+        self.capsule.decode_fp32(name)
     }
 
-    pub fn get_raw_bf16(&self, name: &str) -> Option<&Vec<u8>> {
-        self.raw_bf16_weights.get(name)
+    pub fn tensor_bytes(&self, name: &str) -> Result<&[u8], crate::capsule::CapsuleError> {
+        self.capsule.tensor_bytes(name)
     }
 
     pub fn get_shape(&self, name: &str) -> Option<&Vec<usize>> {
-        self.shapes.get(name)
+        self.capsule.tensors.get(name).map(|tensor| &tensor.shape)
+    }
+
+    fn from_owned_bytes(
+        bytes: Arc<[u8]>,
+        tensors: HashMap<String, crate::capsule::CapsuleTensor>,
+    ) -> Self {
+        let source_digest = crate::capsule::source_digest(&bytes);
+        let capsule_digest = crate::capsule::capsule_digest(&bytes, &tensors);
+        Self {
+            capsule: crate::capsule::ModelCapsule {
+                bytes,
+                source_digest,
+                tensors,
+                capsule_digest,
+            },
+        }
     }
 }
 
@@ -179,9 +229,18 @@ pub fn tinyllama_catalog() -> Vec<(String, Vec<usize>)> {
 }
 
 /// Parses a safetensors binary buffer and strictly validates against a specified tensor catalog.
+/// The file is copied once into the capsule. Tensor ranges point into that buffer.
 pub fn parse_safetensors_with_catalog(
     bytes: &[u8],
     catalog: &[(String, Vec<usize>)],
+) -> Result<LoadedCheckpoint, CheckpointError> {
+    let bytes: Arc<[u8]> = Arc::from(bytes.to_vec());
+    parse_safetensors_arc(bytes, catalog)
+}
+
+fn parse_safetensors_arc(
+    bytes: Arc<[u8]>,
+    catalog: &[(String, Vec<usize>)],
 ) -> Result<LoadedCheckpoint, CheckpointError> {
     if bytes.len() < 8 {
         return Err(CheckpointError::InvalidHeader(
@@ -221,18 +280,16 @@ pub fn parse_safetensors_with_catalog(
         CheckpointError::InvalidHeader("Header JSON must be an object".to_string())
     })?;
 
-    let data_bytes = &bytes[header_end..];
+    let data_len = bytes.len() - header_end;
 
-    let mut fp32_weights = HashMap::with_capacity(catalog.len());
-    let mut raw_bf16_weights = HashMap::with_capacity(catalog.len());
-    let mut shapes = HashMap::with_capacity(catalog.len());
+    let mut tensors = HashMap::with_capacity(catalog.len());
 
     for (name, expected_shape) in catalog {
         let info = header_obj
             .get(name)
             .ok_or_else(|| CheckpointError::MissingTensor(name.clone()))?;
 
-        // 1. Verify dtype is BF16
+        // 1. Verify dtype is BF16. This catalog parser does not accept other dtypes.
         let dtype = info
             .get("dtype")
             .and_then(|v| v.as_str())
@@ -272,7 +329,7 @@ pub fn parse_safetensors_with_catalog(
             });
         }
 
-        // 3. Verify offsets and byte length
+        // 3. Verify offsets and byte length. Safetensors offsets are relative to the data blob.
         let offsets_arr = info
             .get("data_offsets")
             .and_then(|v| v.as_array())
@@ -296,34 +353,39 @@ pub fn parse_safetensors_with_catalog(
         let element_count: usize = expected_shape.iter().product();
         let expected_bytes = element_count * 2; // BF16 is 2 bytes per element
 
-        if start > end || (end - start) != expected_bytes || end > data_bytes.len() {
+        if start > end || (end - start) != expected_bytes || end > data_len {
             return Err(CheckpointError::OffsetOutOfBounds {
                 tensor: name.clone(),
                 offset: end,
-                buffer_len: data_bytes.len(),
+                buffer_len: data_len,
             });
         }
 
-        // 4. Ingest raw BF16 bytes and decode to FP32 in-memory
-        let raw_slice = &data_bytes[start..end];
-        let fp32_slice = decode_bf16_to_fp32(raw_slice);
-
-        raw_bf16_weights.insert(name.clone(), raw_slice.to_vec());
-        fp32_weights.insert(name.clone(), fp32_slice);
-        shapes.insert(name.clone(), actual_shape);
+        // Ranges are absolute inside the whole file, including the 8-byte length and JSON header.
+        let abs_start = header_end + start;
+        let abs_end = header_end + end;
+        let logical_strides = crate::capsule::row_major_strides(&actual_shape);
+        tensors.insert(
+            name.clone(),
+            crate::capsule::CapsuleTensor {
+                dtype: crate::capsule::WeightDType::Bf16,
+                layout: crate::capsule::TensorLayout::RowMajor,
+                shape: actual_shape,
+                logical_strides,
+                byte_range: abs_start..abs_end,
+                quant: None,
+            },
+        );
     }
 
-    Ok(LoadedCheckpoint {
-        fp32_weights,
-        raw_bf16_weights,
-        shapes,
-    })
+    Ok(LoadedCheckpoint::from_owned_bytes(bytes, tensors))
 }
 
-/// Loads a TinyLlama safetensors checkpoint directly from a binary byte buffer.
-pub fn load_safetensors_from_bytes(bytes: &[u8]) -> Result<LoadedCheckpoint, CheckpointError> {
+/// Loads a TinyLlama safetensors checkpoint from an owned byte buffer.
+/// The `Vec` is moved into one `Arc` and is not copied per tensor.
+pub fn load_safetensors_from_bytes(bytes: Vec<u8>) -> Result<LoadedCheckpoint, CheckpointError> {
     let catalog = tinyllama_catalog();
-    parse_safetensors_with_catalog(bytes, &catalog)
+    parse_safetensors_arc(Arc::from(bytes), &catalog)
 }
 
 /// Loads and validates a TinyLlama safetensors checkpoint from a filesystem path.
@@ -338,7 +400,7 @@ pub fn load_safetensors_checkpoint<P: AsRef<Path>>(
             e
         ))
     })?;
-    load_safetensors_from_bytes(&bytes)
+    load_safetensors_from_bytes(bytes)
 }
 
 #[cfg(test)]
@@ -427,12 +489,80 @@ mod tests {
         let loaded = parse_safetensors_with_catalog(&buffer, &catalog).unwrap();
 
         assert_eq!(loaded.tensor_count(), 1);
+        assert_eq!(loaded.capsule.tensors["test.weight"].shape, vec![2, 2]);
         assert_eq!(loaded.get_shape("test.weight").unwrap(), &vec![2, 2]);
-        let fp32 = loaded.get_fp32("test.weight").unwrap();
+        let fp32 = loaded.decode_fp32("test.weight").unwrap();
         assert_eq!(fp32.len(), 4);
         assert_eq!(fp32[0], 1.5);
         assert_eq!(fp32[1], 2.5);
-        assert_eq!(loaded.get_raw_bf16("test.weight").unwrap(), &bf16_bytes);
+        assert_eq!(loaded.tensor_bytes("test.weight").unwrap(), &bf16_bytes[..]);
+        assert!(matches!(
+            loaded.capsule.tensors["test.weight"].dtype,
+            crate::capsule::WeightDType::Bf16
+        ));
+        assert!(loaded.capsule.tensors["test.weight"].quant.is_none());
+    }
+
+    #[test]
+    fn test_capsule_owns_file_bytes_and_byte_range_points_at_payload() {
+        let floats = vec![1.0f32, -1.0f32, 0.5f32];
+        let bf16_bytes = encode_fp32_to_bf16(&floats);
+        let file_bytes = build_test_safetensors(&[("w", "BF16", &[3], &bf16_bytes)]);
+        let catalog = vec![("w".to_string(), vec![3])];
+        let loaded = parse_safetensors_with_catalog(&file_bytes, &catalog).unwrap();
+
+        assert_eq!(loaded.capsule.owned_payload_len(), file_bytes.len());
+        assert_eq!(loaded.capsule.bytes.as_ref(), file_bytes.as_slice());
+        assert_eq!(
+            loaded.capsule.source_digest,
+            crate::capsule::source_digest(&file_bytes)
+        );
+
+        let range = loaded.capsule.tensors["w"].byte_range.clone();
+        assert!(range.start >= 8);
+        assert_eq!(range.end - range.start, bf16_bytes.len());
+        assert_eq!(&loaded.capsule.bytes[range], bf16_bytes.as_slice());
+        assert_eq!(loaded.tensor_bytes("w").unwrap(), bf16_bytes.as_slice());
+        let decoded = loaded.decode_fp32("w").unwrap();
+        assert_eq!(decoded, decode_bf16_to_fp32(&bf16_bytes));
+    }
+
+    #[test]
+    fn test_from_bf16_tensors_one_buffer() {
+        let a = encode_fp32_to_bf16(&[1.0, 2.0]);
+        let b = encode_fp32_to_bf16(&[0.5]);
+        let loaded = LoadedCheckpoint::from_bf16_tensors(vec![
+            ("a".to_string(), vec![2], a.clone()),
+            ("b".to_string(), vec![1], b.clone()),
+        ]);
+
+        assert_eq!(loaded.capsule.owned_payload_len(), a.len() + b.len());
+        assert_eq!(loaded.tensor_bytes("a").unwrap(), a.as_slice());
+        assert_eq!(loaded.tensor_bytes("b").unwrap(), b.as_slice());
+        assert_eq!(loaded.decode_fp32("a").unwrap()[0], 1.0);
+        assert_eq!(loaded.decode_fp32("b").unwrap()[0], 0.5);
+        assert_eq!(
+            loaded.capsule.tensors["a"].logical_strides,
+            crate::capsule::row_major_strides(&[2])
+        );
+        assert!(loaded.capsule.tensors["b"].quant.is_none());
+        assert_eq!(
+            loaded.capsule.source_digest,
+            crate::capsule::source_digest(&loaded.capsule.bytes)
+        );
+        assert_eq!(
+            loaded.capsule.capsule_digest,
+            crate::capsule::capsule_digest(&loaded.capsule.bytes, &loaded.capsule.tensors)
+        );
+
+        let empty = LoadedCheckpoint::new();
+        assert_eq!(empty.tensor_count(), 0);
+        assert_eq!(empty.capsule.owned_payload_len(), 0);
+        assert!(empty.capsule.tensors.is_empty());
+        assert_eq!(
+            empty.capsule.source_digest,
+            crate::capsule::source_digest(&[])
+        );
     }
 
     #[test]
diff --git a/crates/aien-inference-abi/src/lib.rs b/crates/aien-inference-abi/src/lib.rs
index 0dfab092..93da4b22 100644
--- a/crates/aien-inference-abi/src/lib.rs
+++ b/crates/aien-inference-abi/src/lib.rs
@@ -11,9 +11,11 @@ pub mod backend;
 pub mod blackwell_backend;
 pub mod blackwell_batch;
 pub mod blackwell_batch_executor;
+pub mod capsule;
 pub mod checkpoint;
 pub mod mojo_backend;
 pub mod tensor;
+pub mod tensor_abi;
 pub mod tokenizer;
 pub mod transformer_backend;
 pub mod weights;
@@ -26,9 +28,11 @@ pub use blackwell_batch_executor::{
     BlackwellBatchExecutor, BlackwellResidentLayerWeights, BlackwellResidentModel,
     BlackwellResidentModelWeights, BlackwellWorkspace, BlackwellWorkspaceC,
 };
+pub use capsule::*;
 pub use checkpoint::*;
 pub use mojo_backend::*;
 pub use tensor::*;
+pub use tensor_abi::*;
 pub use tokenizer::*;
 pub use transformer_backend::*;
 pub use weights::*;
diff --git a/crates/aien-inference-abi/src/tensor_abi.rs b/crates/aien-inference-abi/src/tensor_abi.rs
new file mode 100644
index 00000000..e9be316a
--- /dev/null
+++ b/crates/aien-inference-abi/src/tensor_abi.rs
@@ -0,0 +1,476 @@
+//! C-compatible typed tensor boundary for capsule storage and accelerator residency.
+
+use crate::capsule::{ModelCapsule, TensorLayout, WeightDType};
+use std::ffi::c_void;
+use std::marker::PhantomData;
+
+pub const MAX_TENSOR_RANK: usize = 4;
+
+/// Numeric values are part of the CUDA C ABI in `cuda/tensor_abi.h`.
+#[repr(u32)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum AbiDType {
+    F32 = 1,
+    Bf16 = 2,
+    Fp16 = 3,
+    Fp8E4M3Fn = 4,
+    Fp8E5M2 = 5,
+    Int8 = 6,
+    Int4 = 7,
+}
+
+impl From<WeightDType> for AbiDType {
+    fn from(dtype: WeightDType) -> Self {
+        match dtype {
+            WeightDType::F32 => Self::F32,
+            WeightDType::Bf16 => Self::Bf16,
+            WeightDType::Fp16 => Self::Fp16,
+            WeightDType::Fp8E4M3Fn => Self::Fp8E4M3Fn,
+            WeightDType::Fp8E5M2 => Self::Fp8E5M2,
+            WeightDType::Int8 => Self::Int8,
+            WeightDType::Int4 => Self::Int4,
+        }
+    }
+}
+
+#[repr(u32)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum AbiLayout {
+    RowMajor = 1,
+    ColumnMajor = 2,
+    Strided = 3,
+}
+
+impl From<TensorLayout> for AbiLayout {
+    fn from(layout: TensorLayout) -> Self {
+        match layout {
+            TensorLayout::RowMajor => Self::RowMajor,
+            TensorLayout::ColumnMajor => Self::ColumnMajor,
+            TensorLayout::Strided => Self::Strided,
+        }
+    }
+}
+
+#[repr(u32)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum AbiResidency {
+    Host = 1,
+    Device = 2,
+}
+
+#[repr(u32)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum AbiQuantScheme {
+    None = 0,
+    Symmetric = 1,
+    Affine = 2,
+}
+
+#[repr(u32)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum AbiPacking {
+    None = 0,
+    Int4LowNibbleFirstSigned = 1,
+    Int4HighNibbleFirstSigned = 2,
+    Int4LowNibbleFirstUnsigned = 3,
+    Int4HighNibbleFirstUnsigned = 4,
+}
+
+#[repr(C)]
+#[derive(Debug, Clone, Copy)]
+pub struct AbiQuantization {
+    pub scheme: AbiQuantScheme,
+    pub axis: i32,
+    pub group_size: u32,
+    pub packing: AbiPacking,
+    pub scales: *const f32,
+    pub scale_count: u64,
+    pub zero_points: *const i32,
+    pub zero_point_count: u64,
+}
+
+impl Default for AbiQuantization {
+    fn default() -> Self {
+        Self {
+            scheme: AbiQuantScheme::None,
+            axis: -1,
+            group_size: 0,
+            packing: AbiPacking::None,
+            scales: std::ptr::null(),
+            scale_count: 0,
+            zero_points: std::ptr::null(),
+            zero_point_count: 0,
+        }
+    }
+}
+
+#[repr(C)]
+#[derive(Debug, Clone, Copy)]
+pub struct TensorDescriptor {
+    pub dtype: AbiDType,
+    pub layout: AbiLayout,
+    pub rank: u32,
+    pub residency: AbiResidency,
+    pub shape: [u64; MAX_TENSOR_RANK],
+    pub strides: [u64; MAX_TENSOR_RANK],
+    pub byte_len: u64,
+    pub quant: AbiQuantization,
+}
+
+#[repr(C)]
+#[derive(Debug, Clone, Copy)]
+pub struct TensorView {
+    pub address: *const c_void,
+    pub descriptor: TensorDescriptor,
+}
+
+/// The device allocation owns `address`, `quant.scales`, and `quant.zero_points`.
+/// The matching CUDA free function must release all three.
+#[repr(C)]
+#[derive(Debug, Clone, Copy)]
+pub struct ResidentTensor {
+    pub address: *mut c_void,
+    pub descriptor: TensorDescriptor,
+}
+
+/// Owns a CUDA allocation described by the same descriptor as its capsule source.
+/// Upload completes before the borrowed host view may be dropped.
+pub struct DeviceTensor {
+    resident: ResidentTensor,
+}
+
+impl DeviceTensor {
+    #[cfg(has_blackwell_cuda)]
+    pub fn upload(host: &BorrowedTensorView<'_>) -> Result<Self, String> {
+        let mut resident = ResidentTensor {
+            address: std::ptr::null_mut(),
+            descriptor: host.as_abi().descriptor,
+        };
+        let stream = unsafe { blackwell_get_stream() };
+        if stream.is_null() {
+            return Err("CUDA stream unavailable".to_string());
+        }
+        let status = unsafe { blackwell_tensor_upload(host.as_abi(), &mut resident, stream) };
+        if status != 0 {
+            return Err(format!("CUDA tensor upload failed: {status}"));
+        }
+        Ok(Self { resident })
+    }
+
+    #[cfg(not(has_blackwell_cuda))]
+    pub fn upload(_host: &BorrowedTensorView<'_>) -> Result<Self, String> {
+        Err("Blackwell CUDA backend unavailable".to_string())
+    }
+
+    pub fn resident(&self) -> &ResidentTensor {
+        &self.resident
+    }
+}
+
+impl Drop for DeviceTensor {
+    fn drop(&mut self) {
+        #[cfg(has_blackwell_cuda)]
+        unsafe {
+            blackwell_tensor_free(&mut self.resident);
+        }
+    }
+}
+
+#[cfg(has_blackwell_cuda)]
+extern "C" {
+    fn blackwell_get_stream() -> *mut c_void;
+    fn blackwell_tensor_upload(
+        host: *const TensorView,
+        device: *mut ResidentTensor,
+        stream: *mut c_void,
+    ) -> i32;
+    fn blackwell_tensor_free(device: *mut ResidentTensor);
+}
+
+/// Keeps the host bytes and quantization arrays alive during an FFI upload.
+pub struct BorrowedTensorView<'a> {
+    view: TensorView,
+    _source: PhantomData<&'a [u8]>,
+}
+
+impl BorrowedTensorView<'_> {
+    pub fn as_abi(&self) -> &TensorView {
+        &self.view
+    }
+}
+
+impl TensorView {
+    pub fn f32_contiguous<'a>(
+        data: &'a [f32],
+        shape: &[usize],
+    ) -> Result<BorrowedTensorView<'a>, String> {
+        let byte_len = data
+            .len()
+            .checked_mul(4)
+            .ok_or("F32 byte length overflow")?;
+        let descriptor = descriptor(
+            AbiDType::F32,
+            AbiLayout::RowMajor,
+            shape,
+            &row_major_strides(shape)?,
+            byte_len,
+            AbiQuantization::default(),
+        )?;
+        Ok(BorrowedTensorView {
+            view: Self {
+                address: data.as_ptr().cast(),
+                descriptor,
+            },
+            _source: PhantomData,
+        })
+    }
+
+    pub fn from_capsule<'a>(
+        capsule: &'a ModelCapsule,
+        name: &str,
+    ) -> Result<BorrowedTensorView<'a>, String> {
+        let tensor = capsule.tensor(name).map_err(|err| err.to_string())?;
+        let bytes = capsule.tensor_bytes(name).map_err(|err| err.to_string())?;
+        let quant = match &tensor.quant {
+            None => AbiQuantization::default(),
+            Some(quant) => AbiQuantization {
+                scheme: match quant.scheme.as_str() {
+                    "symmetric" => AbiQuantScheme::Symmetric,
+                    "affine" => AbiQuantScheme::Affine,
+                    other => return Err(format!("unsupported quantization scheme {other}")),
+                },
+                axis: i32::try_from(quant.axis).map_err(|_| "quantization axis overflow")?,
+                group_size: u32::try_from(quant.group_size).map_err(|_| "group size overflow")?,
+                packing: match quant.packing.as_str() {
+                    "none" => AbiPacking::None,
+                    "int4-low-signed" => AbiPacking::Int4LowNibbleFirstSigned,
+                    "int4-high-signed" => AbiPacking::Int4HighNibbleFirstSigned,
+                    "int4-low-unsigned" => AbiPacking::Int4LowNibbleFirstUnsigned,
+                    "int4-high-unsigned" => AbiPacking::Int4HighNibbleFirstUnsigned,
+                    other => return Err(format!("unsupported packing {other}")),
+                },
+                scales: quant.scales.as_ptr(),
+                scale_count: quant.scales.len() as u64,
+                zero_points: quant.zero_points.as_ptr(),
+                zero_point_count: quant.zero_points.len() as u64,
+            },
+        };
+        let descriptor = descriptor(
+            tensor.dtype.into(),
+            tensor.layout.into(),
+            &tensor.shape,
+            &tensor.logical_strides,
+            bytes.len(),
+            quant,
+        )?;
+        Ok(BorrowedTensorView {
+            view: Self {
+                address: bytes.as_ptr().cast(),
+                descriptor,
+            },
+            _source: PhantomData,
+        })
+    }
+}
+
+fn descriptor(
+    dtype: AbiDType,
+    layout: AbiLayout,
+    shape: &[usize],
+    strides: &[usize],
+    byte_len: usize,
+    quant: AbiQuantization,
+) -> Result<TensorDescriptor, String> {
+    if shape.len() > MAX_TENSOR_RANK || shape.len() != strides.len() {
+        return Err("tensor rank or stride count invalid".to_string());
+    }
+    if shape.is_empty() || shape.contains(&0) {
+        return Err("tensor dimensions must be nonzero".to_string());
+    }
+    let elements = shape
+        .iter()
+        .try_fold(1usize, |count, dim| count.checked_mul(*dim))
+        .ok_or("tensor element count overflow")?;
+    let expected = match dtype {
+        AbiDType::F32 => elements.checked_mul(4),
+        AbiDType::Bf16 | AbiDType::Fp16 => elements.checked_mul(2),
+        AbiDType::Fp8E4M3Fn | AbiDType::Fp8E5M2 | AbiDType::Int8 => Some(elements),
+        AbiDType::Int4 => elements.checked_add(1).map(|count| count / 2),
+    }
+    .ok_or("tensor byte length overflow")?;
+    if layout == AbiLayout::RowMajor && strides != row_major_strides(shape)? {
+        return Err("row-major strides do not match shape".to_string());
+    }
+    if layout == AbiLayout::RowMajor && byte_len != expected {
+        return Err(format!(
+            "tensor byte length {byte_len} does not match {expected}"
+        ));
+    }
+    if dtype == AbiDType::Int4 && quant.packing == AbiPacking::None {
+        return Err("INT4 requires explicit nibble packing".to_string());
+    }
+    if quant.scheme != AbiQuantScheme::None && quant.scale_count == 0 {
+        return Err("quantized tensor needs scales".to_string());
+    }
+    if quant.scheme == AbiQuantScheme::None
+        && (quant.scale_count != 0 || quant.zero_point_count != 0)
+    {
+        return Err("unquantized tensor has quantization arrays".to_string());
+    }
+    if quant.scale_count > 0 && quant.scales.is_null() {
+        return Err("quantization scales missing".to_string());
+    }
+    if quant.zero_point_count > 0 && quant.zero_points.is_null() {
+        return Err("quantization zero points missing".to_string());
+    }
+    let mut abi_shape = [0; MAX_TENSOR_RANK];
+    let mut abi_strides = [0; MAX_TENSOR_RANK];
+    for (index, value) in shape.iter().enumerate() {
+        abi_shape[index] = *value as u64;
+        abi_strides[index] = strides[index] as u64;
+    }
+    Ok(TensorDescriptor {
+        dtype,
+        layout,
+        rank: shape.len() as u32,
+        residency: AbiResidency::Host,
+        shape: abi_shape,
+        strides: abi_strides,
+        byte_len: byte_len as u64,
+        quant,
+    })
+}
+
+fn row_major_strides(shape: &[usize]) -> Result<Vec<usize>, String> {
+    let mut strides = vec![1usize; shape.len()];
+    for index in (0..shape.len().saturating_sub(1)).rev() {
+        strides[index] = strides[index + 1]
+            .checked_mul(shape[index + 1])
+            .ok_or("tensor stride overflow")?;
+    }
+    Ok(strides)
+}
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+    use crate::capsule::{capsule_digest, source_digest, CapsuleTensor, QuantizationDescriptor};
+    use std::collections::HashMap;
+    use std::sync::Arc;
+
+    #[test]
+    fn f32_view_records_shape_stride_and_host_residency() {
+        let data = [1.0f32; 6];
+        let view = TensorView::f32_contiguous(&data, &[2, 3]).unwrap();
+        let descriptor = view.as_abi().descriptor;
+        assert_eq!(descriptor.dtype, AbiDType::F32);
+        assert_eq!(descriptor.residency, AbiResidency::Host);
+        assert_eq!(descriptor.shape[..2], [2, 3]);
+        assert_eq!(descriptor.strides[..2], [3, 1]);
+        assert_eq!(descriptor.byte_len, 24);
+        assert!(TensorView::f32_contiguous(&data, &[3, 3]).is_err());
+    }
+
+    #[test]
+    fn capsule_views_preserve_typed_payload_and_quantization() {
+        let cases = [
+            (WeightDType::Bf16, AbiDType::Bf16, vec![0_u8; 8], None),
+            (WeightDType::Fp16, AbiDType::Fp16, vec![0_u8; 8], None),
+            (
+                WeightDType::Fp8E4M3Fn,
+                AbiDType::Fp8E4M3Fn,
+                vec![0_u8; 4],
+                None,
+            ),
+            (WeightDType::Fp8E5M2, AbiDType::Fp8E5M2, vec![0_u8; 4], None),
+            (
+                WeightDType::Int4,
+                AbiDType::Int4,
+                vec![0_u8; 2],
+                Some(QuantizationDescriptor {
+                    scheme: "symmetric".to_string(),
+                    axis: 0,
+                    group_size: 4,
+                    scales: vec![0.5],
+                    zero_points: vec![],
+                    packing: "int4-low-signed".to_string(),
+                }),
+            ),
+        ];
+        for (dtype, expected_dtype, bytes, quant) in cases {
+            let mut tensors = HashMap::new();
+            tensors.insert(
+                "w".to_string(),
+                CapsuleTensor {
+                    dtype,
+                    layout: TensorLayout::RowMajor,
+                    shape: vec![2, 2],
+                    logical_strides: vec![2, 1],
+                    byte_range: 0..bytes.len(),
+                    quant,
+                },
+            );
+            let capsule = ModelCapsule {
+                source_digest: source_digest(&bytes),
+                capsule_digest: capsule_digest(&bytes, &tensors),
+                bytes: Arc::from(bytes),
+                tensors,
+            };
+            let view = TensorView::from_capsule(&capsule, "w").unwrap();
+            assert_eq!(view.as_abi().descriptor.dtype, expected_dtype);
+            assert_eq!(
+                view.as_abi().descriptor.byte_len as usize,
+                capsule.bytes.len()
+            );
+            assert_eq!(view.as_abi().address as *const u8, capsule.bytes.as_ptr());
+            if dtype == WeightDType::Int4 {
+                assert_eq!(view.as_abi().descriptor.quant.scale_count, 1);
+                assert_eq!(
+                    view.as_abi().descriptor.quant.packing,
+                    AbiPacking::Int4LowNibbleFirstSigned
+                );
+            }
+        }
+    }
+
+    #[test]
+    fn c_abi_layout_matches_cuda_header() {
+        assert_eq!(std::mem::size_of::<AbiQuantization>(), 48);
+        assert_eq!(std::mem::size_of::<TensorDescriptor>(), 136);
+        assert_eq!(std::mem::size_of::<TensorView>(), 144);
+        assert_eq!(std::mem::size_of::<ResidentTensor>(), 144);
+    }
+
+    #[cfg(has_blackwell_cuda)]
+    #[test]
+    fn device_upload_preserves_bf16_descriptor_and_payload_size() {
+        let bytes = vec![0_u8; 8];
+        let mut tensors = HashMap::new();
+        tensors.insert(
+            "w".to_string(),
+            CapsuleTensor {
+                dtype: WeightDType::Bf16,
+                layout: TensorLayout::RowMajor,
+                shape: vec![2, 2],
+                logical_strides: vec![2, 1],
+                byte_range: 0..8,
+                quant: None,
+            },
+        );
+        let capsule = ModelCapsule {
+            source_digest: source_digest(&bytes),
+            capsule_digest: capsule_digest(&bytes, &tensors),
+            bytes: Arc::from(bytes),
+            tensors,
+        };
+        let view = TensorView::from_capsule(&capsule, "w").unwrap();
+        let uploaded = DeviceTensor::upload(&view).unwrap();
+        assert!(!uploaded.resident().address.is_null());
+        assert_eq!(uploaded.resident().descriptor.dtype, AbiDType::Bf16);
+        assert_eq!(
+            uploaded.resident().descriptor.residency,
+            AbiResidency::Device
+        );
+        assert_eq!(uploaded.resident().descriptor.byte_len, 8);
+    }
+}
diff --git a/crates/aien-inference-abi/src/weights.rs b/crates/aien-inference-abi/src/weights.rs
index 7157147d..dc89e601 100644
--- a/crates/aien-inference-abi/src/weights.rs
+++ b/crates/aien-inference-abi/src/weights.rs
@@ -688,112 +688,36 @@ impl TransformerWeights {
     }
 
     /// Loads weights strictly from a pre-validated LoadedCheckpoint without synthetic fallback.
+    /// FP32 tensors are decoded from the checkpoint capsule on demand. They are not stored twice.
     pub fn from_loaded_checkpoint(
         checkpoint: &crate::checkpoint::LoadedCheckpoint,
         config: &ModelConfig,
     ) -> Result<Self, crate::checkpoint::CheckpointError> {
-        let embed_tokens = checkpoint
-            .get_fp32("model.embed_tokens.weight")
-            .ok_or_else(|| {
-                crate::checkpoint::CheckpointError::MissingTensor(
-                    "model.embed_tokens.weight".to_string(),
-                )
-            })?
-            .clone();
+        let decode = |name: &str| -> Result<Vec<f32>, crate::checkpoint::CheckpointError> {
+            checkpoint.decode_fp32(name).map_err(|err| match err {
+                crate::capsule::CapsuleError::MissingTensor(name) => {
+                    crate::checkpoint::CheckpointError::MissingTensor(name)
+                }
+                other => crate::checkpoint::CheckpointError::Capsule(other.to_string()),
+            })
+        };
+
+        let embed_tokens = decode("model.embed_tokens.weight")?;
 
         let mut layers = Vec::with_capacity(config.num_layers);
         for idx in 0..config.num_layers {
             let prefix = format!("model.layers.{}", idx);
 
-            let input_layernorm = checkpoint
-                .get_fp32(&format!("{}.input_layernorm.weight", prefix))
-                .ok_or_else(|| {
-                    crate::checkpoint::CheckpointError::MissingTensor(format!(
-                        "{}.input_layernorm.weight",
-                        prefix
-                    ))
-                })?
-                .clone();
-
-            let q_proj = checkpoint
-                .get_fp32(&format!("{}.self_attn.q_proj.weight", prefix))
-                .ok_or_else(|| {
-                    crate::checkpoint::CheckpointError::MissingTensor(format!(
-                        "{}.self_attn.q_proj.weight",
-                        prefix
-                    ))
-                })?
-                .clone();
-
-            let k_proj = checkpoint
-                .get_fp32(&format!("{}.self_attn.k_proj.weight", prefix))
-                .ok_or_else(|| {
-                    crate::checkpoint::CheckpointError::MissingTensor(format!(
-                        "{}.self_attn.k_proj.weight",
-                        prefix
-                    ))
-                })?
-                .clone();
-
-            let v_proj = checkpoint
-                .get_fp32(&format!("{}.self_attn.v_proj.weight", prefix))
-                .ok_or_else(|| {
-                    crate::checkpoint::CheckpointError::MissingTensor(format!(
-                        "{}.self_attn.v_proj.weight",
-                        prefix
-                    ))
-                })?
-                .clone();
-
-            let o_proj = checkpoint
-                .get_fp32(&format!("{}.self_attn.o_proj.weight", prefix))
-                .ok_or_else(|| {
-                    crate::checkpoint::CheckpointError::MissingTensor(format!(
-                        "{}.self_attn.o_proj.weight",
-                        prefix
-                    ))
-                })?
-                .clone();
-
-            let post_attention_layernorm = checkpoint
-                .get_fp32(&format!("{}.post_attention_layernorm.weight", prefix))
-                .ok_or_else(|| {
-                    crate::checkpoint::CheckpointError::MissingTensor(format!(
-                        "{}.post_attention_layernorm.weight",
-                        prefix
-                    ))
-                })?
-                .clone();
-
-            let gate_proj = checkpoint
-                .get_fp32(&format!("{}.mlp.gate_proj.weight", prefix))
-                .ok_or_else(|| {
-                    crate::checkpoint::CheckpointError::MissingTensor(format!(
-                        "{}.mlp.gate_proj.weight",
-                        prefix
-                    ))
-                })?
-                .clone();
-
-            let up_proj = checkpoint
-                .get_fp32(&format!("{}.mlp.up_proj.weight", prefix))
-                .ok_or_else(|| {
-                    crate::checkpoint::CheckpointError::MissingTensor(format!(
-                        "{}.mlp.up_proj.weight",
-                        prefix
-                    ))
-                })?
-                .clone();
-
-            let down_proj = checkpoint
-                .get_fp32(&format!("{}.mlp.down_proj.weight", prefix))
-                .ok_or_else(|| {
-                    crate::checkpoint::CheckpointError::MissingTensor(format!(
-                        "{}.mlp.down_proj.weight",
-                        prefix
-                    ))
-                })?
-                .clone();
+            let input_layernorm = decode(&format!("{}.input_layernorm.weight", prefix))?;
+            let q_proj = decode(&format!("{}.self_attn.q_proj.weight", prefix))?;
+            let k_proj = decode(&format!("{}.self_attn.k_proj.weight", prefix))?;
+            let v_proj = decode(&format!("{}.self_attn.v_proj.weight", prefix))?;
+            let o_proj = decode(&format!("{}.self_attn.o_proj.weight", prefix))?;
+            let post_attention_layernorm =
+                decode(&format!("{}.post_attention_layernorm.weight", prefix))?;
+            let gate_proj = decode(&format!("{}.mlp.gate_proj.weight", prefix))?;
+            let up_proj = decode(&format!("{}.mlp.up_proj.weight", prefix))?;
+            let down_proj = decode(&format!("{}.mlp.down_proj.weight", prefix))?;
 
             layers.push(TransformerLayerWeights {
                 input_layernorm,
@@ -808,19 +732,8 @@ impl TransformerWeights {
             });
         }
 
-        let final_norm = checkpoint
-            .get_fp32("model.norm.weight")
-            .ok_or_else(|| {
-                crate::checkpoint::CheckpointError::MissingTensor("model.norm.weight".to_string())
-            })?
-            .clone();
-
-        let lm_head = checkpoint
-            .get_fp32("lm_head.weight")
-            .ok_or_else(|| {
-                crate::checkpoint::CheckpointError::MissingTensor("lm_head.weight".to_string())
-            })?
-            .clone();
+        let final_norm = decode("model.norm.weight")?;
+        let lm_head = decode("lm_head.weight")?;
 
         Ok(Self {
             config: config.clone(),
@@ -931,59 +844,43 @@ mod tests {
             )
         );
 
-        // 2. Populated checkpoint loads correctly
-        let mut checkpoint = crate::checkpoint::LoadedCheckpoint::new();
-        checkpoint
-            .fp32_weights
-            .insert("model.embed_tokens.weight".to_string(), vec![0.1; 256 * 64]);
-        checkpoint.fp32_weights.insert(
-            "model.layers.0.input_layernorm.weight".to_string(),
-            vec![1.0; 64],
-        );
-        checkpoint.fp32_weights.insert(
-            "model.layers.0.self_attn.q_proj.weight".to_string(),
-            vec![0.2; 64 * 64],
-        );
-        checkpoint.fp32_weights.insert(
-            "model.layers.0.self_attn.k_proj.weight".to_string(),
-            vec![0.3; 64 * 64],
-        );
-        checkpoint.fp32_weights.insert(
-            "model.layers.0.self_attn.v_proj.weight".to_string(),
-            vec![0.4; 64 * 64],
-        );
-        checkpoint.fp32_weights.insert(
-            "model.layers.0.self_attn.o_proj.weight".to_string(),
-            vec![0.5; 64 * 64],
-        );
-        checkpoint.fp32_weights.insert(
-            "model.layers.0.post_attention_layernorm.weight".to_string(),
-            vec![1.0; 64],
-        );
-        checkpoint.fp32_weights.insert(
-            "model.layers.0.mlp.gate_proj.weight".to_string(),
-            vec![0.6; 64 * 128],
-        );
-        checkpoint.fp32_weights.insert(
-            "model.layers.0.mlp.up_proj.weight".to_string(),
-            vec![0.7; 64 * 128],
-        );
-        checkpoint.fp32_weights.insert(
-            "model.layers.0.mlp.down_proj.weight".to_string(),
-            vec![0.8; 128 * 64],
-        );
-        checkpoint
-            .fp32_weights
-            .insert("model.norm.weight".to_string(), vec![1.0; 64]);
-        checkpoint
-            .fp32_weights
-            .insert("lm_head.weight".to_string(), vec![0.9; 64 * 256]);
+        // 2. Populated checkpoint loads correctly.
+        // Values are exact in bf16 so decode_fp32 round-trips without rounding.
+        let bf16_filled = |name: &str, shape: Vec<usize>, value: f32| {
+            let n: usize = shape.iter().product();
+            let values = vec![value; n];
+            (
+                name.to_string(),
+                shape,
+                crate::checkpoint::encode_fp32_to_bf16(&values),
+            )
+        };
+        let checkpoint = crate::checkpoint::LoadedCheckpoint::from_bf16_tensors(vec![
+            bf16_filled("model.embed_tokens.weight", vec![256, 64], 0.5),
+            bf16_filled("model.layers.0.input_layernorm.weight", vec![64], 1.0),
+            bf16_filled("model.layers.0.self_attn.q_proj.weight", vec![64, 64], 2.0),
+            bf16_filled("model.layers.0.self_attn.k_proj.weight", vec![64, 64], 0.5),
+            bf16_filled("model.layers.0.self_attn.v_proj.weight", vec![64, 64], 1.0),
+            bf16_filled("model.layers.0.self_attn.o_proj.weight", vec![64, 64], 0.5),
+            bf16_filled(
+                "model.layers.0.post_attention_layernorm.weight",
+                vec![64],
+                1.0,
+            ),
+            bf16_filled("model.layers.0.mlp.gate_proj.weight", vec![128, 64], 2.0),
+            bf16_filled("model.layers.0.mlp.up_proj.weight", vec![128, 64], 0.5),
+            bf16_filled("model.layers.0.mlp.down_proj.weight", vec![64, 128], 1.0),
+            bf16_filled("model.norm.weight", vec![64], 1.0),
+            bf16_filled("lm_head.weight", vec![256, 64], 0.5),
+        ]);
 
         let weights = TransformerWeights::from_loaded_checkpoint(&checkpoint, &config).unwrap();
         assert_eq!(weights.embed_tokens.len(), 256 * 64);
+        assert_eq!(weights.embed_tokens[0], 0.5);
         assert_eq!(weights.layers.len(), 1);
-        assert_eq!(weights.layers[0].q_proj[0], 0.2);
+        assert_eq!(weights.layers[0].q_proj[0], 2.0);
         assert_eq!(weights.final_norm.len(), 64);
-        assert_eq!(weights.lm_head[0], 0.9);
+        assert_eq!(weights.final_norm[0], 1.0);
+        assert_eq!(weights.lm_head[0], 0.5);
     }
 }
diff --git a/e2e_tests/Cargo.lock b/e2e_tests/Cargo.lock
index 7de7f0dd..16a647a8 100644
--- a/e2e_tests/Cargo.lock
+++ b/e2e_tests/Cargo.lock
@@ -30,12 +30,15 @@ name = "aien-inference-abi"
 version = "0.1.0"
 dependencies = [
  "aien-kv-cache",
+ "aien-platform",
  "async-trait",
  "libloading",
+ "parking_lot",
  "rayon",
  "reqwest",
  "serde",
  "serde_json",
+ "sha2",
  "tokenizers",
  "tokio",
 ]
@@ -44,11 +47,26 @@ dependencies = [
 name = "aien-kv-cache"
 version = "0.1.0"
 dependencies = [
+ "aien-platform",
+ "aien-platform-linux",
  "libc",
  "parking_lot",
  "serde",
 ]
 
+[[package]]
+name = "aien-platform"
+version = "0.1.0"
+
+[[package]]
+name = "aien-platform-linux"
+version = "0.1.0"
+dependencies = [
+ "aien-platform",
+ "libc",
+ "parking_lot",
+]
+
 [[package]]
 name = "async-trait"
 version = "0.1.92"
@@ -84,6 +102,15 @@ version = "2.13.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"
 
+[[package]]
+name = "block-buffer"
+version = "0.10.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
+dependencies = [
+ "generic-array",
+]
+
 [[package]]
 name = "bumpalo"
 version = "3.20.3"
@@ -168,6 +195,15 @@ version = "1.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48"
 
+[[package]]
+name = "cpufeatures"
+version = "0.2.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280"
+dependencies = [
+ "libc",
+]
+
 [[package]]
 name = "crossbeam-deque"
 version = "0.8.8"
@@ -193,6 +229,16 @@ version = "0.8.23"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6"
 
+[[package]]
+name = "crypto-common"
+version = "0.1.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a"
+dependencies = [
+ "generic-array",
+ "typenum",
+]
+
 [[package]]
 name = "darling"
 version = "0.20.11"
@@ -268,6 +314,16 @@ dependencies = [
  "syn 2.0.119",
 ]
 
+[[package]]
+name = "digest"
+version = "0.10.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
+dependencies = [
+ "block-buffer",
+ "crypto-common",
+]
+
 [[package]]
 name = "displaydoc"
 version = "0.2.7"
@@ -413,6 +469,16 @@ dependencies = [
  "slab",
 ]
 
+[[package]]
+name = "generic-array"
+version = "0.14.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
+dependencies = [
+ "typenum",
+ "version_check",
+]
+
 [[package]]
 name = "getrandom"
 version = "0.2.17"
@@ -1379,6 +1445,17 @@ dependencies = [
  "serde",
 ]
 
+[[package]]
+name = "sha2"
+version = "0.10.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
+dependencies = [
+ "cfg-if",
+ "cpufeatures",
+ "digest",
+]
+
 [[package]]
 name = "shlex"
 version = "2.0.1"
@@ -1718,6 +1795,12 @@ version = "0.2.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
 
+[[package]]
+name = "typenum"
+version = "1.20.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
+
 [[package]]
 name = "unicode-ident"
 version = "1.0.26"
diff --git a/e2e_tests/tests/test_tier1_feature_coverage.rs b/e2e_tests/tests/test_tier1_feature_coverage.rs
index 75058b25..0c684542 100644
--- a/e2e_tests/tests/test_tier1_feature_coverage.rs
+++ b/e2e_tests/tests/test_tier1_feature_coverage.rs
@@ -220,15 +220,28 @@ fn test_f3_01_loaded_checkpoint_contains_fp32_weights() {
         &[("model.norm.weight", &[4], "BF16", &raw_bf16)],
         None,
     );
+    let path = std::env::temp_dir().join(format!(
+        "f3_01_checkpoint_{}_{}.safetensors",
+        std::process::id(),
+        std::time::SystemTime::now()
+            .duration_since(std::time::UNIX_EPOCH)
+            .unwrap()
+            .as_nanos()
+    ));
+    std::fs::write(&path, &bytes).unwrap();
+    let file_len = std::fs::metadata(&path).unwrap().len() as usize;
+    let file_bytes = std::fs::read(&path).unwrap();
     let catalog = vec![("model.norm.weight".to_string(), vec![4])];
-    let loaded = parse_safetensors_with_catalog(&bytes, &catalog).unwrap();
+    let loaded = parse_safetensors_with_catalog(&file_bytes, &catalog).unwrap();
+    let _ = std::fs::remove_file(&path);
 
-    let fp32 = loaded.get_fp32("model.norm.weight").unwrap();
+    let fp32 = loaded.decode_fp32("model.norm.weight").unwrap();
     assert_eq!(fp32.len(), 4);
-    assert!((fp32[0] - 1.5).abs() < 1e-4);
-    assert!((fp32[1] - (-2.5)).abs() < 1e-4);
+    assert!((fp32[0] - 1.5).abs() < 1e-2);
+    assert!((fp32[1] - (-2.5)).abs() < 1e-2);
     assert_eq!(fp32[2], 0.0);
-    assert!((fp32[3] - 42.0).abs() < 1e-4);
+    assert!((fp32[3] - 42.0).abs() < 1e-2);
+    assert_eq!(loaded.capsule.owned_payload_len(), file_len);
 }
 
 #[test]
@@ -242,8 +255,8 @@ fn test_f3_02_loaded_checkpoint_retains_raw_bf16_bytes() {
     let catalog = vec![("model.norm.weight".to_string(), vec![2])];
     let loaded = parse_safetensors_with_catalog(&bytes, &catalog).unwrap();
 
-    let bf16 = loaded.get_raw_bf16("model.norm.weight").unwrap();
-    assert_eq!(bf16, &raw_bf16);
+    let bf16 = loaded.tensor_bytes("model.norm.weight").unwrap();
+    assert_eq!(bf16, raw_bf16.as_slice());
 }
 
 #[test]
@@ -268,17 +281,21 @@ fn test_f3_04_loaded_checkpoint_shapes_record_dimensions() {
 
 #[test]
 fn test_f3_05_memory_isolation_between_fp32_and_bf16() {
-    let mut checkpoint = LoadedCheckpoint::new();
-    checkpoint.fp32_weights.insert("tensor_a".to_string(), vec![1.0, 2.0]);
-    checkpoint.raw_bf16_weights.insert("tensor_a".to_string(), vec![0x80, 0x3F, 0x00, 0x40]);
-
-    if let Some(fp32) = checkpoint.fp32_weights.get_mut("tensor_a") {
-        fp32[0] = 999.0;
-    }
-
-    let bf16 = checkpoint.get_raw_bf16("tensor_a").unwrap();
+    let raw = encode_fp32_to_bf16(&[1.0, 2.0]);
+    let checkpoint = LoadedCheckpoint::from_bf16_tensors(vec![(
+        "tensor_a".to_string(),
+        vec![2],
+        raw.clone(),
+    )]);
+
+    let mut fp32 = checkpoint.decode_fp32("tensor_a").unwrap();
+    fp32[0] = 999.0;
+
+    let bf16 = checkpoint.tensor_bytes("tensor_a").unwrap();
+    assert_eq!(bf16, raw.as_slice());
     assert_eq!(bf16[0], 0x80);
     assert_eq!(bf16[1], 0x3F);
+    assert_eq!(fp32[0], 999.0);
 }
 
 // ============================================================================
diff --git a/e2e_tests/tests/test_tier3_cross_feature.rs b/e2e_tests/tests/test_tier3_cross_feature.rs
index 19e538d5..917192e9 100644
--- a/e2e_tests/tests/test_tier3_cross_feature.rs
+++ b/e2e_tests/tests/test_tier3_cross_feature.rs
@@ -49,19 +49,19 @@ fn test_pair_p01_loader_and_validation() {
 
 #[test]
 fn test_pair_p02_loader_and_dual_storage() {
-    // P2 (F1 + F3): Safetensors loading populates both FP32 and raw BF16 weights
+    // P2 (F1 + F3): Safetensors loading decodes FP32 from stored raw BF16 bytes
     let original = vec![2.5f32, -1.0f32];
     let raw = encode_fp32_to_bf16(&original);
     let bytes = create_safetensors_bytes(&[("test_weight", &[2], "BF16", &raw)], None);
     let catalog = vec![("test_weight".to_string(), vec![2])];
 
     let loaded = parse_safetensors_with_catalog(&bytes, &catalog).unwrap();
-    let fp32 = loaded.get_fp32("test_weight").unwrap();
-    let bf16 = loaded.get_raw_bf16("test_weight").unwrap();
+    let fp32 = loaded.decode_fp32("test_weight").unwrap();
+    let bf16 = loaded.tensor_bytes("test_weight").unwrap();
 
     assert_eq!(fp32.len(), 2);
     assert_eq!(bf16.len(), 4);
-    assert!((fp32[0] - 2.5).abs() < 1e-4);
+    assert!((fp32[0] - 2.5).abs() < 1e-2);
 }
 
 #[test]
@@ -162,18 +162,16 @@ fn test_pair_p10_aligned_math_and_reference_cpu_backend() {
 #[test]
 fn test_pair_p11_dual_storage_and_mojo_c_abi_compatibility() {
     // P11 (F3 + F13): Raw BF16 buffers passed directly to C-ABI pointers
-    let checkpoint = LoadedCheckpoint {
-        fp32_weights: std::collections::HashMap::new(),
-        raw_bf16_weights: {
-            let mut m = std::collections::HashMap::new();
-            m.insert("weight".to_string(), vec![0x80, 0x3F, 0x00, 0x40]);
-            m
-        },
-        shapes: std::collections::HashMap::new(),
-    };
-    let bf16_slice = checkpoint.get_raw_bf16("weight").unwrap();
+    let raw = encode_fp32_to_bf16(&[1.0, 2.0]);
+    let checkpoint = LoadedCheckpoint::from_bf16_tensors(vec![(
+        "weight".to_string(),
+        vec![2],
+        raw,
+    )]);
+    let bf16_slice = checkpoint.tensor_bytes("weight").unwrap();
     let ptr = bf16_slice.as_ptr();
     assert!(!ptr.is_null());
+    assert_eq!(bf16_slice.len(), 4);
 }
 
 #[test]