Learning straight from CAD
A model that reads the CAD surface patches directly, with no mesh at prediction time; with parametric CAD, gradients can reach the design.
Outcome: Describe a NURBS patch: control points, weights and knot vectors; explain one token per patch, and why skipping the mesh matters; follow gradients from predicted drag back to CAD parameters.
Builds on Tokens, Decoders and volume fields, Optimising on a surrogate
Every model in this course that reads the geometry started from a sampled stand-in for it: a grid, a mesh or a point cloud. A design begins as CAD (computer-aided design: the exact geometry model drawn in a design tool), and making that stand-in is often slow, fragile and partly manual. It also cuts the link between the parameters an engineer edits and what the network sees. CAD-native models read the CAD itself.
What CAD stores
A CAD surface is assembled from patches, most often NURBS (non-uniform rational B-splines).
DefinitionNURBS patch
A patch (Piegl and Tiller 1997) defined by a grid of control points , which pull the surface towards them; a weight per control point, which sets how strongly; and two knot vectors, which say how the patch's two parameters and are divided into spans.
The surface of Equation 9-1 is exact at any resolution, and a handful of numbers describes a smooth piece of a nacelle or a car roof.
One token per patch
A patch has a variable number of control points and knots, and a transformer needs tokens of one size. CANTO (Leibovici et al. 2026) turns each patch into one token. The control points with their weights, and each knot vector, are read by their own Perceiver-style pooling, in which a fixed set of learned queries attends to the entries. So patches of any size give the same size of token. The three results are concatenated and passed through an MLP, and self-attention among the patch tokens gives each one the context of the whole part. A query decoder (decoders) then predicts surface pressure and wall shear stress, or volume velocity, at any requested point, without re-encoding the geometry.
The course’s aircraft has no CAD model, so Example 9-3 is a toy: two random patches, a tokenizer that pools by a mean, and a sum in place of a predicted drag. It shows the shapes and the path of the gradient, not CANTO’s results.
import torch
from torch import nn
def mlp(i, o, h=128):
return nn.Sequential(nn.Linear(i, h), nn.SiLU(),
nn.Linear(h, o))
class PatchTokenizer(nn.Module):
def __init__(self, d=128):
super().__init__()
self.pw = mlp(4, d) # control point + weight
self.u, self.v = mlp(1, d), mlp(1, d) # knots
self.out = mlp(3 * d, d)
def forward(self, ctrl, w, ku, kv): # one patch, any size
# Embed each control point with its weight, then pool.
# CANTO pools with learned queries; a mean keeps this short.
pw = torch.cat([ctrl, w[:, None]], -1)1
pw = self.pw(pw).mean(0)2
u = self.u(ku[:, None]).mean(0) # U knot vector3
v = self.v(kv[:, None]).mean(0) # V knot vector
return self.out(torch.cat([pw, u, v])) # one token
# Cubic knot vectors: one span, and two spans.
k4 = torch.tensor([0, 0, 0, 0, 1, 1, 1, 1.0])
k5 = torch.tensor([0, 0, 0, 0, 0.5, 1, 1, 1, 1.0])4
# (control points, weights, U knots, V knots)
patches = [
(torch.rand(16, 3, requires_grad=True),
torch.ones(16), k4, k4),
(torch.rand(20, 3, requires_grad=True),
torch.ones(20), k5, k4),
]
tok = PatchTokenizer()
tokens = torch.stack([tok(*p) for p in patches]) # (P, d)
# The sum stands in for a predicted drag.
tokens.sum().backward()5
# A gradient for every control point of the CAD.
print(tokens.shape, patches[0][0].grad.shape)
- Each control point with its weight: an (n, 4) array for a patch of n control points.
- The mean over the control points pools any number of them into one vector of size
d. - Each knot becomes a 1-vector, so the same small MLP reads knot vectors of any length.
- A cubic patch has (knots − 4) control points per direction:
k4has 8 knots, so 4 × 4 = 16;k5has 9, so 5 × 4 = 20. - The control points were created with
requires_grad=True, so the backward pass reaches them.
Example 9-3 prints torch.Size([2, 128]) torch.Size([16, 3]): one token of 128 numbers per patch, whatever its number of control points, and a gradient for each of the 16 control points of the first patch.
Gradients for the design
Remeshing is a discrete step: a small change of the shape can change which cells exist, so no usable gradient flows through it. Morphing a mesh of fixed topology is differentiable, and is how adjoint CFD tools such as SU2 move the mesh within a design cycle, but it limits how far the shape can change.
With no mesh at prediction time, the chain from control points to predicted drag is differentiable. If the step from design parameters to control points is differentiable too, as in CANTO's parametric test, optimising on a surrogate works on the CAD parameters themselves. In a feature-based commercial CAD model that step is not a given. Training still needs solver fields, computed on meshes.
The authors report that on HiLiftAeroML CANTO's surface-pressure error is about 20 % lower than that of an AB-UPT they trained themselves (relative L2 4.53 % against 5.65 %). On AhmedML they optimised six bounded design parameters for lower drag under volume and lift constraints, and report designs with 4.4 to 20.4 % less drag than the best dataset designs that meet the same constraints. Every optimised design was re-simulated with the dataset's own CFD protocol before the result was claimed, as optimising on a surrogate asks.