Caliper

Caliper

Machine learning visualization framework

A native app for interpretability. Observe models directly from the GPU in real time.

Source available · macOS on Metal · Windows on Vulkan and CUDA

C++MPSCUDAMetal VulkanImGuiImPlot ImPlot3D
The Caliper inspector attached to Qwen3.5-0.8B: the parameter tree, the Trace pane reading every layer through the Jacobian lens while the model writes, Model 3D with every tensor at its true shape, and the inference output
01 · Native backends

Native backends

The descriptortensor.h · 17–27
17typedef struct CaliperTensor {18    uint32_t          struct_size;19    void*             data;            /* device or host pointer */20    CaliperDType      dtype;21    int32_t           ndim;            /* <= 8 */22    int64_t           shape[8];23    int64_t           strides[8];      /* in elements */24    CaliperDeviceKind device;25    int32_t           device_index;26    void*             stream;          /* cudaStream_t / MTLCommandQueue* / NULL */27} CaliperTensor;
The call, from an appletgpt_scope.cpp · 451, 455–456, 1388
451return caliper::adapters::stream_to_tensor(dev_t, bridge.caps());⋯455if (id != 0) { bridge.update_texture(id, &*ct); return id; }456id = bridge.texture_from_tensor_mapped(&*ct, cmap, vmin, vmax, 0);⋯1388ImGui::Image(caliper::Bridge::imtex(st->head_tex), ImVec2(side, side));
macOS · Metal

MPS unified memory path

MPS tensor data is colormapped or blitted on the GPU before ImGui draws it.

The Metal renderer is the macOS default. The bridge validates layout and device information before using the buffer; unsupported inputs are rejected instead of reinterpreted.

APPLE SILICON PACKAGE SOC CPU encodes command buffers NEURAL ENGINE DISPLAY ENGINE scans the frame out GPU torch's kernels, Caliper's pass SYSTEM LEVEL CACHE MEMORY CONTROLLERS LPDDR LPDDR DRAM PAGES TENSOR torch's MTLBuffer, 64 MiB written by torch's kernels read by Caliper's pass TEXTURE MTLTexture, 64 MiB written by Caliper's pass sampled by ImGui's draw FRAME the drawable written by ImGui's draw read by the display engine COMMANDS written by the CPU EXAMPLE 4096 × 4096 f32 GPU READS 64 MiB GPU WRITES 64 MiB COPIES 0 CPU TOUCHES 0 bytes
Frame trace · 60 Hz0.00 msOrder from the code · durations schematic
×8 0 3 3.5 6 8 10 12 14 16 18 20 ms VSYNC TRAINING THREAD CPU · gpt_scope train_job FRAME THREAD CPU · Caliper host TORCH'S QUEUE GPU · MTLCommandQueue CALIPER'S QUEUE GPU · MTLCommandQueue DISPLAY scan-out present forward: torch queues the kernels gpt_scope.cpp:1006 auto logits = model->forward(xb);forward backward: torch queues the kernels gpt_scope.cpp:1009 loss.backward();backward blocks until the GPU is done: grad norms copied to the CPU gpt_scope.cpp:1018 auto gn = acc.sqrt().to(torch::kCPU).contiguous();waits: grad norms optimizer step: torch queues the kernels gpt_scope.cpp:1021 opt.step(); blocks until the GPU is done: the loss read back gpt_scope.cpp:1023 const float l = loss.item<float>();waits: loss next step: forward gpt_scope.cpp:1006 auto logits = model->forward(xb);forward next step: backward gpt_scope.cpp:1009 loss.backward();backward next step: blocks until the GPU is done gpt_scope.cpp:1018 auto gn = acc.sqrt().to(torch::kCPU).contiguous();waits: grad norms new_frame: the next drawable and the frame's command buffer metal_renderer.mm:703 drawable_ = [layer_ nextDrawable]; // may be nil under load metal_renderer.mm:711 frame_cmd_ = [queue_ commandBuffer]; the applet's draw_ui builds its widgets gpt_scope.cpp:1302 ImGui::Text("selected: layer %d, head %d — attention (rows attend to cols)",applet UI to_tensor: the MPS storage's MTLBuffer becomes the descriptor's data torch.hpp:152 out.data = t.storage().mutable_data(); // the MTLBuffer bridge pointer torch.hpp:153 out.device = CALIPER_DEV_METAL;tensor stream_to_tensor: commit torch's pending kernels and take its queue torch.hpp:216 void* queue = detail::mps_commit_and_get_queue(); torch.hpp:87 torch::mps::commit(); // enqueue-not-drain, atomic with the peekcommit update_texture: the descriptor's pointer is cast to id<MTLBuffer> metal_renderer.mm:812 id<MTLBuffer> src = (__bridge id<MTLBuffer>)t.data; gpt_scope.cpp:455 if (id != 0) { bridge.update_texture(id, &*ct); return id; }cast order_after_producer: signal v queued on torch's queue, a wait for v encoded metal_renderer.mm:1658 [sig encodeSignalEvent:ev value:v]; metal_renderer.mm:1659 [sig commit];order the colormap pass encoded and committed, with no CPU wait metal_renderer.mm:1703 [enc dispatchThreadgroups:groups threadsPerThreadgroup:tg]; metal_renderer.mm:1696 [enc setBuffer:src offset:(NSUInteger)src_offset atIndex:0];encode the applet draws the texture with ImGui::Image gpt_scope.cpp:1388 ImGui::Image(caliper::Bridge::imtex(st->head_tex), ImVec2(side, side));applet UI render: ImGui's draw encoded, the drawable presented, the frame committed metal_renderer.mm:728 ImGui_ImplMetal_RenderDrawData(ImGui::GetDrawData(), metal_renderer.mm:731 [frame_cmd_ presentDrawable:drawable_]; next frame: new_frame metal_renderer.mm:703 drawable_ = [layer_ nextDrawable]; // may be nil under load metal_renderer.mm:711 frame_cmd_ = [queue_ commandBuffer]; next frame: the applet's draw_ui gpt_scope.cpp:1302 ImGui::Text("selected: layer %d, head %d — attention (rows attend to cols)",applet UI torch's kernels committed before the handoff: forward, start of backwardtorch's kernels signal v: runs once everything committed before it has finished metal_renderer.mm:1658 [sig encodeSignalEvent:ev value:v]; torch's kernels: rest of backward, grad normstorch's kernels torch's kernels: optimizer step torch's kernels: next steptorch's kernels the colormap command buffer waits for event v, on the GPU metal_renderer.mm:1660 [cb encodeWaitForEvent:ev value:v]; cmap_f32 reads the tensor's MTLBuffer and writes the texture metal_renderer.mm:73 float v = src[gid.y * p.sy + gid.x * p.sx]; metal_renderer.mm:83 dst.write(c, gid); ImGui's draw samples the texture into the drawable metal_renderer.mm:728 ImGui_ImplMetal_RenderDrawData(ImGui::GetDrawData(), the previous frame on screenprevious frame this frame on screen from the vsync after its present metal_renderer.mm:731 [frame_cmd_ presentDrawable:drawable_];this frame MEMORY illustrative values TENSORtorch's MTLBuffer, f32 TEXTUREMTLTexture, colormapped ON SCREENthe drawable: texture, surface, histogram cmap_f32 ImGui draw
Tensor to descriptortorch.hpp · 148–156
148if (t.is_mps()) {149    // No offset channel in CaliperTensor and the bridge casts this pointer150    // straight to id<MTLBuffer>; a nonzero offset would mis-address texels.151    if (t.storage_offset() != 0) return std::nullopt;152    out.data = t.storage().mutable_data();   // the MTLBuffer bridge pointer153    out.device = CALIPER_DEV_METAL;154    out.device_index = static_cast<int32_t>(t.device().index());155    return out;156}
The buffer, not a copymetal_renderer.mm · 806–821
806bool tex_update_from_device(uint64_t tex, const CaliperTensor& t,807                            const uint32_t* lut256,808                            float vmin, float vmax) override {809    id<MTLTexture> dst = lookup(tex);810    if (dst == nil) return false;811    if (t.device != CALIPER_DEV_METAL || t.data == nullptr) return false;812    id<MTLBuffer> src = (__bridge id<MTLBuffer>)t.data;813    if (src == nil) return false;814815    if (t.dtype == CALIPER_DT_F32 && lut256 != nullptr)816        return colormap_compute_from(tex, dst, src, 0, t, lut256, vmin, vmax,817                                     /*imported=*/false);818    if (t.dtype == CALIPER_DT_U8)819        return blit_u8_from(tex, dst, src, 0, t, /*imported=*/false);820    return false;821}
One pass, after torch's queuemetal_renderer.mm · 1655–1660, 1692–1704
1655id<MTLCommandBuffer> sig = [producer commandBuffer];1656if (ev != nil && sig != nil) {1657    const uint64_t v = ++event_values_[tex];1658    [sig encodeSignalEvent:ev value:v];1659    [sig commit];1660    [cb encodeWaitForEvent:ev value:v];⋯1692id<MTLCommandBuffer> cb = [queue_ commandBuffer];1693if (t.stream != nullptr) order_after_producer(tex, cb, t.stream);1694id<MTLComputeCommandEncoder> enc = [cb computeCommandEncoder];1695[enc setComputePipelineState:cmap_pipeline_];1696[enc setBuffer:src offset:(NSUInteger)src_offset atIndex:0];1697[enc setBuffer:lutbuf offset:0 atIndex:1];1698[enc setBytes:&p length:sizeof(p) atIndex:2];1699[enc setTexture:dst atIndex:0];17001701MTLSize tg = MTLSizeMake(16, 16, 1);1702MTLSize groups = MTLSizeMake((p.w + 15) / 16, (p.h + 15) / 16, 1);1703[enc dispatchThreadgroups:groups threadsPerThreadgroup:tg];1704[enc endEncoding];
The kernelmetal_renderer.mm · 66–84
66kernel void cmap_f32(device const float*  src  [[buffer(0)]],67                     device const uint*   lut  [[buffer(1)]],68                     constant CmapParams& p    [[buffer(2)]],69                     texture2d<float, access::write> dst [[texture(0)]],70                     uint2 gid [[thread_position_in_grid]])71{72    if (gid.x >= p.w || gid.y >= p.h) return;73    float v = src[gid.y * p.sy + gid.x * p.sx];74    float denom = p.vmax - p.vmin;75    float t = denom != 0.0f ? (v - p.vmin) / denom : 0.0f;76    t = clamp(t, 0.0f, 1.0f);77    uint idx = (uint)(t * 255.0f + 0.5f);78    uint packed = lut[idx];79    float4 c = float4(float(packed        & 0xffu),80                      float((packed >> 8)  & 0xffu),81                      float((packed >> 16) & 0xffu),82                      float((packed >> 24) & 0xffu)) / 255.0f;83    dst.write(c, gid);84}
Windows · Vulkan + CUDA

CUDA device-local interop

The tensor is read where it lies in VRAM: a CUDA kernel on torch's stream writes the texture directly, with no copy and no system-RAM staging.

Vulkan exports each texture's image for CUDA import. The kernel writes the image no frame is sampling, then the two swap, so the frame thread does not wait on the update and training keeps its pace. Shared timeline semaphores order it on the GPU. Where the kernel cannot run, one VRAM copy and a Vulkan pass take over.

HOST CPU records and submits PCIE ROOT SYSTEM RAM where a CPU tensor is staged before its upload PCIE commands only GPU BOARD GDDR GDDR GPU STREAMING MULTIPROCESSORS torch's kernels, the colormap kernel, ImGui's draw L2 CACHE MEMORY CONTROLLERS VRAM PAGES TENSOR torch's CUDA allocator written by torch's kernels read in place by the kernel BACK VKIMAGE exported by Vulkan and imported by CUDA: the same pages; the kernel writes it FRONT VKIMAGE sampled by ImGui's draw swaps with the back image SWAPCHAIN written by ImGui's draw then presented SEMAPHORE timeline value: CUDA signals, the frame waits EXAMPLE 4096 × 4096 f32 OVER PCIE 0 bytes COPY IN VRAM 0, 64 MiB on the fallback GPU WRITES 64 MiB HOST-STAGED, OVER PCIE 64 MiB each way
Frame trace · 60 Hz0.00 msOrder from the code · durations schematic
×13 ×9 ×3 0 3 3.5 5 5.5 6 6.5 8 10 12 14 16 18 20 ms VSYNC TRAINING THREAD CPU · gpt_scope train_job FRAME THREAD CPU · Caliper host TORCH'S STREAM GPU · CUDA stream CALIPER'S QUEUE GPU · VkQueue DISPLAY swapchain present forward: torch queues the kernels gpt_scope.cpp:1006 auto logits = model->forward(xb); backward: torch queues the kernels gpt_scope.cpp:1009 loss.backward();backward blocks until the GPU is done: grad norms copied to the CPU gpt_scope.cpp:1018 auto gn = acc.sqrt().to(torch::kCPU).contiguous();waits: grad norms optimizer step: torch queues the kernels gpt_scope.cpp:1021 opt.step(); blocks until the GPU is done: the loss read back gpt_scope.cpp:1023 const float l = loss.item<float>(); next step: forward gpt_scope.cpp:1006 auto logits = model->forward(xb); next step: backward gpt_scope.cpp:1009 loss.backward(); next step: blocks until the GPU is done gpt_scope.cpp:1018 auto gn = acc.sqrt().to(torch::kCPU).contiguous();waits: grad norms new_frame: ImGui's Vulkan frame begins vulkan_renderer.cpp:351 ImGui_ImplVulkan_NewFrame(); the applet's draw_ui builds its widgets gpt_scope.cpp:1302 ImGui::Text("selected: layer %d, head %d — attention (rows attend to cols)", to_tensor: the CUDA tensor's device address becomes the descriptor's data torch.hpp:162 out.data = t.data_ptr(); torch.hpp:163 out.device = CALIPER_DEV_CUDA;tensor stream_to_tensor: torch's current CUDA stream goes in the descriptor torch.hpp:228 out->stream = (void*)at::cuda::getCurrentCUDAStream( gpt_scope.cpp:451 return caliper::adapters::stream_to_tensor(dev_t, bridge.caps()); update_texture: shape, strides and alignment checked, so the kernel can only read this tensor's memory vulkan_renderer.cpp:3784 if (t.shape[0] != dst.h || t.shape[1] != dst.w || stride_x <= 0 || stride_y <= 0) gpt_scope.cpp:455 if (id != 0) { bridge.update_texture(id, &*ct); return id; } the colormap kernel enqueued on torch's stream, after a wait only if a frame may still be sampling the back image vulkan_renderer.cpp:3832 if (da->cuLaunchKernel(is_cmap ? direct_cmap_ : direct_blit_, vulkan_renderer.cpp:3816 if (last_sampler != 0 &&kernel the semaphore signal, base+1, enqueued on torch's stream vulkan_renderer.cpp:3841 if (cu->cuSignalExternalSemaphoresAsync(&io.cuda_sem, &sp, 1, stream) vulkan_renderer.cpp:3840 sp.params.fence.value = base + 1; the two images trade places; the id the applet holds does not change vulkan_renderer.cpp:3853 if (!in_place) swap_images(dst); vulkan_renderer.cpp:3880 std::swap(t.image, b.image);swap the applet draws the texture with ImGui::Image gpt_scope.cpp:1388 ImGui::Image(caliper::Bridge::imtex(st->head_tex), ImVec2(side, side));applet UI frame_render: acquire a swapchain image, send draws to the front image, wait for its frame's fence vulkan_renderer.cpp:2340 VkResult err = vkAcquireNextImageKHR(device_, wd_.Swapchain, UINT64_MAX, vulkan_renderer.cpp:2346 resolve_swapped_textures(dd); ImGui's draw recorded into the frame's command buffer vulkan_renderer.cpp:2362 ImGui_ImplVulkan_RenderDrawData(dd, fd->CommandBuffer); vkQueueSubmit: wait for the image and for base+1 vulkan_renderer.cpp:2395 if (vkQueueSubmit(queue_, 1, &si, fd->Fence) == VK_SUCCESS) { vulkan_renderer.cpp:2376 for (const auto& pw : pending_frame_waits_) { vkQueuePresentKHR: queued behind render-complete vulkan_renderer.cpp:2410 VkResult err = vkQueuePresentKHR(queue_, &pi); next frame: new_frame vulkan_renderer.cpp:351 ImGui_ImplVulkan_NewFrame(); next frame: the applet's draw_ui gpt_scope.cpp:1302 ImGui::Text("selected: layer %d, head %d — attention (rows attend to cols)", torch's kernels launched before the handoff: forward, start of backwardtorch's kernels the kernel reads the tensor in place and writes the back VkImage, with no copy cmap_direct.cu:30 const float v = *(const float*)(src + y * stride_y + x * stride_x); cmap_direct.cu:43 surf2Dwrite(lut.v[idx], dst, x * 4, y);colormap the timeline semaphore reaches base+1 vulkan_renderer.cpp:3841 if (cu->cuSignalExternalSemaphoresAsync(&io.cuda_sem, &sp, 1, stream) torch's kernels: rest of backward, grad normstorch's kernels torch's kernels: optimizer step torch's kernels: next steptorch's kernels ImGui's draw samples the VkImage into the swapchain image vulkan_renderer.cpp:2362 ImGui_ImplVulkan_RenderDrawData(dd, fd->CommandBuffer); the previous frame on screenprevious frame this frame on screen from the vsync after its present vulkan_renderer.cpp:2410 VkResult err = vkQueuePresentKHR(queue_, &pi);this frame MEMORY illustrative values TENSORtorch's CUDA memory, f32 BACK IMAGEunsampled kernel write FRONT IMAGEswap for ImGui sampling ON SCREENswapchain: texture, surface, histogram kernel swap draw
Tensor to descriptortorch.hpp · 157–166
157if (t.is_cuda()) {158    // Unlike MPS there is no buffer-object cast: data_ptr() IS the device159    // address (storage offset already applied), and the Vulkan backend160    // copies from it in-VRAM (ZEROCOPY.md). Contiguity was enforced above;161    // views with a nonzero storage offset are therefore fine here.162    out.data = t.data_ptr();163    out.device = CALIPER_DEV_CUDA;164    out.device_index = static_cast<int32_t>(t.device().index());165    return out;166}
Vulkan allocates the image, exportablevulkan_renderer.cpp · 638–640, 645–651
638VkExternalMemoryImageCreateInfo emi{VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO};639emi.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT;640if (exportable) ici.pNext = &emi;⋯645VkMemoryDedicatedAllocateInfo ded{VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO};646ded.image = t.image;647VkExportMemoryAllocateInfo xmai{VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO};648xmai.pNext = &ded;649xmai.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT;650VkMemoryAllocateInfo mai{VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO};651if (exportable) mai.pNext = &xmai;
CUDA imports it as a surfacevulkan_renderer.cpp · 3723–3728, 3730–3734, 3745–3749
3723VkMemoryGetWin32HandleInfoKHR gi{VK_STRUCTURE_TYPE_MEMORY_GET_WIN32_HANDLE_INFO_KHR};3724gi.memory = t.memory;3725gi.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT;3726HANDLE h = nullptr;3727if (vkGetMemoryWin32HandleKHR(device_, &gi, &h) != VK_SUCCESS) return false;3728d.win32_handle = h;⋯3730cudadrv::ExternalMemoryHandleDesc hd{};3731hd.type = cudadrv::kExtMemHandleTypeOpaqueWin32;3732hd.handle.win32.handle = h;3733hd.size = d.mem_size;3734hd.flags = cudadrv::kExtMemDedicated;⋯3745if (cu->cuImportExternalMemory(&d.ext, &hd) != cudadrv::CUDA_SUCCESS ||3746    da->cuExternalMemoryGetMappedMipmappedArray(&d.mip, d.ext, &md) != cudadrv::CUDA_SUCCESS ||3747    da->cuMipmappedArrayGetLevel(&level, d.mip, 0) != cudadrv::CUDA_SUCCESS ||3748    (rd.res.array.hArray = level,3749     da->cuSurfObjectCreate(&d.surf, &rd)) != cudadrv::CUDA_SUCCESS) {
Each updatevulkan_renderer.cpp · 3827–3843, 3853
3827const void* src_arg = (const void*)(uintptr_t)src;3828int w = dst.w, h = dst.h;3829void* cmap_params[] = {&src_arg, &target.direct.surf, &w, &h, &stride_x, &stride_y,3830                       &vmin, &vmax, const_cast<uint32_t*>(lut256)};3831void* blit_params[] = {&src_arg, &target.direct.surf, &w, &h, &stride_x, &stride_y};3832if (da->cuLaunchKernel(is_cmap ? direct_cmap_ : direct_blit_,3833                       ((unsigned)w + 15) / 16, ((unsigned)h + 15) / 16, 1,3834                       16, 16, 1, 0, stream,3835                       is_cmap ? cmap_params : blit_params, nullptr)3836        != cudadrv::CUDA_SUCCESS)3837    return dev_bail("direct: kernel launch failed");38383839cudadrv::ExternalSemaphoreSignalParams sp{};3840sp.params.fence.value = base + 1;3841if (cu->cuSignalExternalSemaphoresAsync(&io.cuda_sem, &sp, 1, stream)3842        != cudadrv::CUDA_SUCCESS)3843    return dev_bail("direct: semaphore signal failed");⋯3853if (!in_place) swap_images(dst);
The kernelcmap_direct.cu · 21–44
21extern "C" __global__ void caliper_cmap_f32(const char* src,22                                            cudaSurfaceObject_t dst,23                                            int w, int h,24                                            long long stride_x, long long stride_y,25                                            float vmin, float vmax,26                                            Lut256 lut) {27    const int x = blockIdx.x * blockDim.x + threadIdx.x;28    const int y = blockIdx.y * blockDim.y + threadIdx.y;29    if (x >= w || y >= h) return;30    const float v = *(const float*)(src + y * stride_y + x * stride_x);31    int idx = 0;32    if (v == v) {33        const float denom = vmax - vmin;34        float t = (denom != 0.0f) ? (v - vmin) / denom : 0.0f;35        if (t < 0.0f) t = 0.0f;36        else if (t > 1.0f) t = 1.0f;37        // A NaN t (infinite vmin/vmax) lands on index 0, as x64's cast and38        // clamp do in the reference; CUDA's cast already gives 0.39        idx = (int)(t * 255.0f + 0.5f);40        if (idx < 0) idx = 0;41        else if (idx > 255) idx = 255;42    }43    surf2Dwrite(lut.v[idx], dst, x * 4, y);44}
02 · Development

Development

Python

Caliper LIB

The caliper Python package. Version 0.1.0, for Python 3.12 on macOS with Apple Silicon, built from source.

Available
show, points, series, histogram
Send a tensor to a heatmap, a scatter, a curve or a histogram. The call returns at once; the copy runs on the tensor's own GPU stream.
watch(model)
Shows each module's activations, and optionally its gradients, through forward and gradient hooks.
session()
Opens the shared-memory session the Caliper app attaches to with F4, Attach to process.
window(), run(train)
Opens a Caliper window inside the script's own process; run trains on a worker thread so the window stays responsive.
offscreen()
Renders without a window and reads back pixels, values and counters, so tests can check what a view shows.
caliper.live
Lists the running sessions and starts a viewer for one, for tools that attach on their own.
Watch PyTorch training live →
macOS · PyTorch

Python streaming

import caliper for step in range(steps):    x, y = make_batch(64, device)    loss = F.cross_entropy(model(x), y)    opt.zero_grad(set_to_none=True)    loss.backward()    opt.step()     caliper.show(model.fc1.weight, "fc1.weight", cmap="rdbu")     # (64, 784) heatmap    caliper.show(acts["conv1"], "conv1.act")                       # (64, 8, 28, 28) -> mosaic    caliper.points(acts["hidden"] @ proj, y, "embedding", classes=4)    caliper.series(loss.detach(), "loss")    caliper.histogram(model.fc1.weight, "fc1.weight.hist")
Illustrative data
TRAINING PROCESS Python, torch on MPS SHARED MEMORY POSIX segments, mode 0600 VIEWER PROCESS Caliper app or caliper-viewer caliper.show(W) 60 Hz rate limit, then the watcher check SnapshotRing a free slot of three, or the snapshot drops torch MPS stream slot.copy_(W) torch.aminmax(W, out=stats) torch.mps.Event record(), then a publisher thread polls query() every 2 ms step 1,216 · loss 0.074 /session-ctl view rows, the viewer's heartbeat /session-v1 header: published, claimed slot 0 being written stats slot 1 published stats slot 2 claimed stats being written: the GPU copy is filling it published: the newest snapshot, drawn next claimed: the viewer is reading it for a frame free: the next copy can land here none free: the new snapshot is dropped, never waited for one MTLBuffer per process over the same pages ShmSource heartbeat, newest completed slot caliper_core_live_apply colormap pass reads the slot in place ImGui frame seq 152 fc1.weight fc1.weight.hist embedding loss GPU copy publish heartbeat watched? read
C++

Caliper SDK

Interfaces
caliper::Applet
The class an applet derives from: the host calls on_init once, on_frame every frame and on_cleanup when the applet closes.
caliper::Device
Reports the GPU the app is running on (Metal, CUDA or the CPU), so the applet trains on the same device.
caliper::Bridge
Turns a GPU tensor into a texture the interface can draw, colormapped on the GPU without a copy to the CPU.
caliper::Jobs
Runs work such as training on a background thread, with progress shown in the app and a cancel the applet checks.
caliper::Metrics
Records each run's scalars and hyperparameters, so loss curves and run comparisons outlast the session.
caliper::Data
Runs SQL over the app's built-in analytical store and returns Arrow tables; datasets can be registered and shared between applets.
caliper::Artifacts
Stores checkpoints and exports by their content, so identical files are kept once and each records where it came from.
Torch objects on each platform →
LibTorch · Metal or CUDA

C++ Example

examples/sine_scope/sine_scope.cppsource
1// device.v1 -> torch device: METAL means MPS on Apple, CUDA on Windows/Linux.auto d = caliper::Device::query(*st->host);torch::Device dev =    (d.kind == CALIPER_DEV_CUDA && torch::cuda::is_available())        ? torch::Device(torch::kCUDA)    : (d.kind == CALIPER_DEV_METAL) ? torch::Device(torch::kMPS)                                    : torch::Device(torch::kCPU); 2// … training on dev; then, on the frame thread: // The weight matrix as pixels — gen-gated rebuild, frame thread only.if (st->bridge && gen != 0 && gen != st->tex_gen &&    disp_w.defined()) {    if (st->w_tex) st->bridge.release_texture(st->w_tex);3    auto ct = caliper::adapters::to_tensor(disp_w);4    st->w_tex = ct ? st->bridge.texture_from_tensor_mapped(                         &*ct, CALIPER_CMAP_RDBU, -w_max, w_max)                   : 0;    st->tex_gen = gen;}if (st->w_tex) {    ImGui::TextDisabled("fc1 weights (32x1 as 8x4 blocks, RdBu)");5    ImGui::Image(caliper::Bridge::imtex(st->w_tex), ImVec2(128, 256));} else if (!st->bridge) {    ImGui::TextDisabled("tensor_bridge.v1 absent: no weight heatmap");} else {    ImGui::TextDisabled("fc1 weights appear once training starts");}
  1. 1
    Pick the GPU. caliper::Device::query reports Metal or CUDA, and the applet trains on the matching torch device: torch::kMPS on macOS, torch::kCUDA on Windows.
  2. 2
    Train. Ordinary libtorch on that device: a small network fitted to 256 noisy samples of sin(x), run as a background job whose progress shows in the app.
  3. 3
    Describe the tensor. caliper::adapters::to_tensor wraps the weight tensor's GPU memory as a CaliperTensor. Nothing is copied.
  4. 4
    Make a texture. texture_from_tensor_mapped colormaps the tensor on the GPU (RdBu, −w_max to w_max).
  5. 5
    Draw it. ImGui::Image with Bridge::imtex puts the texture in the applet's panel: the heatmap below.
The C++ example running in Caliper on an Apple M5 Max: training at 59 percent, the model's curve running through noisy samples of sin(x), the loss falling, and the first layer's weights as a red and blue heatmap.
The C++ example in Caliper, halfway through training.
CMake · macOS and Windows

Build from source

CMake 3.25 or later and a C++17 compiler. macOS needs Xcode command line tools and Apple Silicon; Windows needs Visual Studio 2022 and CUDA 12.8.

macOS
Metal, default · MPS tensors on the GPU
Windows
Vulkan, default · CUDA tensors through external memory
Fallback
None until the WebGPU fallback through Dawn lands
# Clone, with its submodules
$ git clone --recursive https://github.com/AhmedKhan-GH/caliper
$ cd caliper

# Configure and build; the applets download LibTorch
$ cmake --preset release
$ cmake --build --preset release

# Run
$ ./cmake-build-release/caliper
03 · Future Features

Future Features

Caliper CLI

Create, build, run and capture applets from a terminal, a script or a CI job.

$ caliper new finetune$ caliper build finetune$ caliper run finetune$ caliper capture loss -o loss.png

Caliper API

An HTTP interface to the running app, so code in any language can run applets, send them data and fetch what they show.

# CALIPER is the running app's address$ curl -X POST \    $CALIPER/applets/finetune/run$ curl -X POST $CALIPER/streams/loss \    -d '{"step": 1200, "value": 0.41}'$ curl -o loss.png $CALIPER/views/loss.png

Caliper MCP

Tools that hand your coding agent Caliper's SDK, its documentation and the running app, so it can write a panel for your project, build it and check the result on screen.

$ claude mcp add caliper -- caliper-mcp$ codex mcp add caliper -- caliper-mcp$ claude> Plot the loss of each layer.  new("finetune")  build("finetune")  run("finetune")  capture("loss")
04 · Future Products

Future Products

Caliper Bench

Live measurements and telemetry streaming into Caliper, beside the models trained on them, across the physical sciences and engineering.

Example

A robot arm streams its seven joint angles over ROS 2, 500 times a second. Caliper plots them live beside the angles your control policy predicted, so you see the moment the two diverge.

Illustrative data
SIDE VIEW joint 4 JOINT 4 measured −1.99 rad predicted −1.81 rad difference 0.18 rad Joints 2 and 6 follow the policy. Joint 4 falls behind, so every link past it leaves the predicted pose. JOINT 4 ANGLE rad −2.5−2.0 joint 4 falls behind 0 s1 s2 s3 s4 s5 s ARMFranka Research 3RATE500 HzMEASURED/joint_statesPREDICTED/policy/joint_targets

Caliper Cloud

A paid plan that runs Caliper on our dedicated GPU nodes, for models larger than your own hardware can hold.

Example

Kimi K3.1 Pro, 2.8 trillion parameters, runs on one of our 8-GPU nodes. You open it in Caliper on your laptop and read its 93 layers in the Trace pane as you would a local model; the node sends back the readings, not the activations.

KIMI K3.1 PRO2.8T parameters · 104B active per token · 1.56 TB of weights · 93 layers ONE NODE HGX B300 · 8 Blackwell Ultra GPUs · tensor parallel 8 NVLink 5 1.8 TB/s per GPU readings, 15 KB per token MEMORY LOAD 8 × 288 GB = 2.30 TB weights 1.56 TB KV cache, one 1M-token sequence 142 GB 17.7 GB copied on each GPU at tensor parallel 8 free 601 GB each GPU holds 195 GB of weights of 288 GB the 69 KDA layers also hold a state per sequence, 108.5M values in a precision not published YOUR LAPTOP Trace pane · Kimi K3.1 Pro The capital of France is L19 the 0.05 L37 French 0.14 L56 Paris 0.36 L74 Paris 0.70 L93 Paris 0.93 illustrative readings weights KV cache free HBM GPU die, two per package 1.56 TB of weights, MXFP4 routed experts and everything else bf16, split eight ways by tensor parallelism. Each B300 has 288 GB of HBM3e in eight 12-Hi stacks of 36 GB. Readings are 15 KB per token in binary, 25.8 KB as today's JSON.

Caliper Platform

A place to exchange widgets and applets, and to source pre-made professional tools.

Example

A lab publishes the spectrogram widget from its own applet. You add its source to your project with caliper add spectrogram; a licensed tool installs into Caliper with caliper install attention.

RELEASE ON YOUR DISK added IN THE APP $ caliper add spectrogram spectrogram 1.4.2 kind widget, source sha256 9f3a…c41e signed by the lab licence MIT listed in caliper-registry finetune/ CMakeLists.txt + 2 lines finetune.cpp finetune.caliper.toml widgets/spectrogram/ CMakeLists.txt spectrogram.h spectrogram.cpp widget.toml + add_subdirectory(widgets/spectrogram) + target_link_libraries(finetune + PRIVATE spectrogram) spectrogram 8 kHz 0 0 s 2 s a chirp, illustrative $ caliper install attention attention 2.0.0 kind applet, built sha256 4b07…e912 signed by Sternbild licence commercial, 1 seat listed in caliper-registry ~/Library/Application Support/Caliper/ applets/ libsine_scope.dylib sine_scope.caliper.toml libattention.dylib attention.caliper.toml attention.licence on Windows: %APPDATA%\Caliper\applets\ and a .dll 1 reads attention.caliper.toml 2 checks ABI epoch, host version, services 3 checks the licence 4 loads libattention.dylib WIDGET 4 source files APPLET 3 files INSTALLED TO Caliper/applets/ READ BEFORE LOADING manifest, licence

Get started