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
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

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;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));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.
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.
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}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;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) {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);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}The caliper Python package. Version 0.1.0, for Python 3.12 on macOS with Apple Silicon, built from source.
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")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");}caliper::Device::query reports Metal or CUDA, and the applet trains on the matching torch device: torch::kMPS on macOS, torch::kCUDA on Windows.caliper::adapters::to_tensor wraps the weight tensor's GPU memory as a CaliperTensor. Nothing is copied.texture_from_tensor_mapped colormaps the tensor on the GPU (RdBu, −w_max to w_max).ImGui::Image with Bridge::imtex puts the texture in the applet's panel: the heatmap below.
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.
# 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
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
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
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")
Live measurements and telemetry streaming into Caliper, beside the models trained on them, across the physical sciences and engineering.
ExampleA 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.
A paid plan that runs Caliper on our dedicated GPU nodes, for models larger than your own hardware can hold.
ExampleKimi 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.
A place to exchange widgets and applets, and to source pre-made professional tools.
ExampleA 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.