docs / xpu / math

XPU index
  1. Overview
  1. One model, start to last token
  2. The scheduler: what runs when, beside what
  3. Optimization: what is decided when, and what is remembered
  4. Language models on the device: the cajeta-llm kernels
  5. Gradient boosting on the device: the cajeta-xgboost kernels
  6. Catalog: every cajeta-llm kernel
  7. Catalog: every cajeta-xgboost kernel

Math

  1. Overview

Nucleo

  1. Overview

ML

  1. Overview

LLM

  1. Overview
  2. Configuration
  3. Inside the engine
  4. Measuring, and where it stands
  5. Models and weight formats
  6. Quickstart
  7. Running and serving
  8. The engine API

Math: the tensor layer

cajeta.math is the numeric layer between the device substrate and everything that computes with arrays: the n-dimensional Tensor, the dtype system, dense linear algebra, the FFT, random generation, NumPy interchange, polynomials and statistics, and the small geometry types. It is what the LLM engine’s activations are, what nucleo’s columns alias, and what the ML library’s estimators consume.

What it is

Tensor<T> is a strided view over a shared, reference-counted storage: offset, shape and strides over one buffer, so a slice, a transpose or a reshape is a new view and not a copy. The element type is a typed-width primitive (float32, float64, int32, …) chosen at the type, and DType names it at run time for code that moves between them. Host code reads elements through flatGet and the raw hostBuffer(); device code never sees a Tensor, it sees the KernelBuffer the tensor’s storage was uploaded to, which is the one seam between this layer and XPU.

The packages beneath it: linalg (solve, inverse, QR, SVD, least squares), fft (complex64 transforms), random (a float32 generator), npio (the .npy format, load and save), poly (evaluation; fitting goes through least squares), stats (moments, histograms), and Ray, Rotation, Transform, Camera, Color for graphics and robotics code.

How the layers above use it

  • The LLM engine keeps its activations as Tensor<float32> on the host side of every step and uploads the packed forms to device buffers; a decode step touches no Tensor at all once the model is resident. The walkthrough shows where the boundary sits.
  • Nucleo aliases a Column’s buffer as a Tensor with no copy (Column.asTensor), which is how a dataframe column becomes an estimator’s design matrix in one line.
  • ML is written over Tensor<float64> for the classical half and Tensor<float32> for the neural half; the precision boundary is crossed once, at the estimator adapter.

Where it stands

The benchmarks measure element access, elementwise and reduction kernels, matmul, the linear algebra at 512 and 2048, the FFT, random draws, .npy interchange and the geometry types against NumPy and SciPy, Eigen, FFTW, ndarray and gonum. Several pages say what the library lacks today and state the nearest honest measurement: no tensor cast, no polynomial fit, no skew or kurtosis, float32-only random and FFT, a translation-rotation-scale Transform rather than a 4×4.

Reference

The stdlib pages, one per class: Tensor, DType, LinAlg, Fft, Generator, Npy, Poly, Stats, Ray, Rotation, Transform, Camera, Color.

Source: docs/xpu/math/README.md · 2 min read · 409 words