Skip to main content
torch.jstorch.jstorch.js
Getting StartedPlaygroundContact
Login
torch.jstorch.jstorch.js
Documentation
IntroductionType SafetyTensor IndexingEinsumEinopsAutogradTraining a ModelProfiling & MemoryPyTorch MigrationBest PracticesRuntimesPerformance
IntroductionTraining DashboardsVisualizing TensorsGPU AccelerationInteractive InputsThemingStorybook
torch.js· 2026
LegalTerms of UsePrivacy Policy
  1. docs
  2. React UI
  3. GPU Acceleration

GPU Acceleration

For production-scale machine learning, CPU-based visualization can become a bottleneck. react-ui includes a suite of components prefixed with GPU that render data directly from WebGPU memory.

Diagram of zero-copy rendering: GPU Buffer -> Canvas

Why use GPU components?

Standard visualization tools (like SVG or 2D Canvas) require you to call await tensor.toArray() to move data from the GPU to the CPU before rendering. This "readback stall" can take 10-100ms, effectively killing your frame rate.

GPU components skip this step entirely. They use compute shaders to process the tensor and render it directly to a WebGPU canvas.

Key GPU Components

ComponentCapabilityScale Limit
GPUStreamingChartReal-time line plots100,000+ points
GPUHeatmapHigh-res activation maps4K resolution tensors
GPUPointCloud3D Embedding exploration1,000,000+ points
GPUHistogramWeight distribution monitoringImmediate updates

Example: Large Scale Embeddings

Visualizing a 100,000 point point-cloud would crash most browsers if using DOM elements. With GPUPointCloud, it remains fluid at 60fps.

import { GPUPointCloud } from '@torchjsorg/react-ui';

function EmbeddingView({ embeddings }) {
  return (
    <GPUPointCloud 
      points={embeddings} 
      pointSize={2}
      colorBy="cluster"
    />
  );
}

Performance Comparison

MetricCPU-based (TensorViewer)GPU-based (GPUHeatmap)
LatencyHigh (Readback stall)Low (Zero-copy)
Max TensorsSmall (< 1MB)Unlimited (VRAM limited)
InteractivityStatic / Low FPSSmooth / High FPS

Next Steps

  • Theming - Styling your GPU-powered dashboards.
  • torch.js Performance - General GPU optimization tips.
Previous
Visualizing Tensors
Next
Interactive Inputs