Papers
Topics
Authors
Recent
Search
2000 character limit reached

OctreeNCA: Scalable Medical Segmentation

Updated 8 July 2026
  • OctreeNCA is a segmentation architecture that extends Neural Cellular Automata with a multiscale octree to process large medical images and videos in a single pass.
  • The fused CUDA inference kernel achieves significant memory efficiency, using 90% less VRAM than UNet and enabling segmentation of 184.9 MP images and minute-long videos.
  • The design trades slight accuracy limits on small structures for remarkable VRAM reduction, speed gains, and potential for extensions such as learned pooling or attention mechanisms.

OctreeNCA is a segmentation architecture for very large medical images and videos that extends the Neural Cellular Automaton (NCA) with a multiscale octree and a fused CUDA inference kernel. Its stated purpose is to preserve full spatial or temporal context by inferring large inputs at once rather than through patch-wise or frame-wise decomposition, while avoiding the VRAM scaling behavior of UNets and Vision Transformers. In the reported configuration, OctreeNCA performs single-pass segmentation of 184.9 Megapixel pathology images and 76.2-second surgical videos on a single NVIDIA RTX 4090 24 GiB, with evaluation-time VRAM occupancy described as 90% less than a UNet (Lemke et al., 9 Aug 2025).

1. Problem setting and design rationale

The motivating problem is segmentation of large inputs such as prostate MRIs, pathology slices, and videos of surgery. The central constraint is GPU VRAM: if a model is asked to segment a large image volume or a long video sequence in a single pass, architectures such as UNets or Vision Transformers scale poorly in memory and often force patch-wise or frame-wise inference. The paper frames that compromise as detrimental to both global consistency and inference speed.

OctreeNCA starts from a different premise. A standard NCA is lightweight and, by construction, size-invariant, so it does not require a fixed input resolution. However, the same locality that makes an NCA scalable also limits it: with only local communication rules, it lacks global knowledge. OctreeNCA addresses that limitation by generalizing the neighborhood definition with an octree data structure, so that long-range context can be traversed efficiently at coarse scales and then propagated back to fine scales.

A recurring misconception is that size-invariance alone is sufficient for globally coherent inference. In the formulation summarized here, that is explicitly not the case: the base NCA is size-invariant, but still local-only. The octree is introduced precisely to add a mechanism for global context without abandoning the NCA update paradigm (Lemke et al., 9 Aug 2025).

2. Standard NCA formulation

At each pixel or voxel ii, the model maintains a state vector si(t)Rcs_i^{(t)}\in\mathbb{R}^c, with c=16c=16. The first channels are the input image and the remaining channels are hidden state. The local neighborhood is the 3×33\times 3 grid in 2D or the 3×3×33\times 3\times 3 grid in 3D.

Perception is implemented by a learnable convolution applied per-channel:

pi(t)=convk(s(t))[i].p_i^{(t)} = \mathrm{conv}_k\bigl(s^{(t)}\bigr)[i].

The update rule concatenates the current cell state and its perception, then applies a two-layer MLP with a ReLU nonlinearity in between, producing an additive update ui(t)Rcu_i^{(t)}\in\mathbb{R}^c. The paper gives the full update as

ηi(t)Bernoulli(0.5){0,1}c\eta_i^{(t)} \sim \mathrm{Bernoulli}(0.5)\in\{0,1\}^c

si(t+1)=si(t)+ηi(t)(W2  ReLU(W1[si(t);pi(t)])),s_i^{(t+1)} = s_i^{(t)} + \eta_i^{(t)}\odot \Bigl(W_2\;\mathrm{ReLU}\bigl(W_1\,[\,s_i^{(t)};\,p_i^{(t)}\,]\bigr)\Bigr),

with W1R64×(c+c)W_1\in\mathbb{R}^{64\times(c+c)} and si(t)Rcs_i^{(t)}\in\mathbb{R}^c0. The asynchronous masking is described as a fire-rate mechanism: each element of the update is zeroed out independently with probability si(t)Rcs_i^{(t)}\in\mathbb{R}^c1.

This formulation preserves the canonical NCA property that the same local rule is applied over a grid of arbitrary size. The architectural intervention in OctreeNCA is therefore not a replacement of the update dynamics, but a restructuring of how those dynamics are deployed across scales.

3. Octree generalization and multiscale information flow

The octree is fixed to si(t)Rcs_i^{(t)}\in\mathbb{R}^c2 levels. Level si(t)Rcs_i^{(t)}\in\mathbb{R}^c3 is the full-resolution input, and level si(t)Rcs_i^{(t)}\in\mathbb{R}^c4 is a coarsening of the original image by a factor of si(t)Rcs_i^{(t)}\in\mathbb{R}^c5 in each spatial dimension. Formally, if si(t)Rcs_i^{(t)}\in\mathbb{R}^c6 is the original image of size si(t)Rcs_i^{(t)}\in\mathbb{R}^c7, then

si(t)Rcs_i^{(t)}\in\mathbb{R}^c8

Each level si(t)Rcs_i^{(t)}\in\mathbb{R}^c9 has a separate NCA with its own weights and a state grid c=16c=160. Global context is built by starting at the coarsest level, where the grid is small enough that a modest number of local NCA updates can diffuse information over very long effective distances. Hidden channels from that coarse level are then upsampled by nearest-neighbor with factor c=16c=161 and inserted into the next finer level, whose color channels are set from the image pyramid.

The forward-pass logic is given procedurally. First the octree of images is built. Then the top-level state c=16c=162 is initialized by concatenating c=16c=163 with zero hidden channels. For each level from c=16c=164 down to c=16c=165, the model runs c=16c=166 NCA steps; if c=16c=167, the hidden part of c=16c=168 is upsampled and concatenated with c=16c=169 to initialize 3×33\times 30. The final segmentation is read from a segmentation channel in 3×33\times 31.

This suggests that OctreeNCA treats “neighborhood” in an effective rather than purely geometric sense. The per-level NCA still uses local kernels, but because coarse levels aggregate larger receptive fields, information can be transported globally before fine-scale refinement. The paper describes this as a generalized neighborhood definition that enables efficient traversal of global knowledge (Lemke et al., 9 Aug 2025).

4. CUDA realization and memory complexity

A central technical contribution is the CUDA implementation of NCA inference. The paper argues that standard deep learning frameworks are optimized for large multilayer networks and therefore do not fully exploit the advantages of NCAs. In a traditional PyTorch NCA implementation, intermediate tensors are allocated for padded inputs, convolution outputs, MLP activations, Bernoulli masks, ReLU outputs, and related temporaries. The reported empirical peak is approximately 3×33\times 32 channels times 3×33\times 33 pixels.

The OctreeNCA CUDA kernel fuses all per-cell operations—convolution, affine layers, ReLU, masking, and addition—into a single kernel. The only global memories are the input state and output state, each with 3×33\times 34 channels in the reported configuration. The 3×33\times 35-channel hidden activations of the MLP live in thread-local registers rather than global VRAM. The empirical peak is therefore 3×33\times 36 channels times 3×33\times 37 pixels.

The corresponding asymptotic memory factors are stated as follows:

  • OctreeNCA, CUDA optimized: 3×33\times 38
  • Naïve NCA: 3×33\times 39
  • UNet with 3×3×33\times 3\times 30 resolutions and base channels 3×3×33\times 3\times 31: 3×3×33\times 3\times 32

The paper characterizes this as roughly a 3×3×33\times 3\times 33 larger factor for the UNet than for the optimized OctreeNCA. In practical terms, this memory behavior underlies the claim that OctreeNCA can segment 184 Megapixel pathology slices or 1-minute surgical videos at once, and that it occupies 90% less VRAM than a UNet during evaluation (Lemke et al., 9 Aug 2025).

5. Training regime and empirical results

The reported hyper-parameters are shared across tasks: fire-rate 3×3×33\times 3\times 34, 3×3×33\times 3\times 35 state channels, hidden MLP size 3×3×33\times 3\times 36, and kernel size 3×3×33\times 3\times 37 or 3×3×33\times 3\times 38 for 3D. Optimization uses Adam with 3×3×33\times 3\times 39, pi(t)=convk(s(t))[i].p_i^{(t)} = \mathrm{conv}_k\bigl(s^{(t)}\bigr)[i].0, and initial learning rate pi(t)=convk(s(t))[i].p_i^{(t)} = \mathrm{conv}_k\bigl(s^{(t)}\bigr)[i].1, followed by exponential decay pi(t)=convk(s(t))[i].p_i^{(t)} = \mathrm{conv}_k\bigl(s^{(t)}\bigr)[i].2 each step. An exponential moving average of weights is maintained according to pi(t)=convk(s(t))[i].p_i^{(t)} = \mathrm{conv}_k\bigl(s^{(t)}\bigr)[i].3, and evaluation uses pi(t)=convk(s(t))[i].p_i^{(t)} = \mathrm{conv}_k\bigl(s^{(t)}\bigr)[i].4. The loss is a combined cross-entropy and Dice objective,

pi(t)=convk(s(t))[i].p_i^{(t)} = \mathrm{conv}_k\bigl(s^{(t)}\bigr)[i].5

Training data handling depends on modality. For radiology inputs of size pi(t)=convk(s(t))[i].p_i^{(t)} = \mathrm{conv}_k\bigl(s^{(t)}\bigr)[i].6 and surgical inputs of size pi(t)=convk(s(t))[i].p_i^{(t)} = \mathrm{conv}_k\bigl(s^{(t)}\bigr)[i].7, the full volume is too large during training, so random patches are extracted on the two coarsest levels, with examples given as pi(t)=convk(s(t))[i].p_i^{(t)} = \mathrm{conv}_k\bigl(s^{(t)}\bigr)[i].8 or pi(t)=convk(s(t))[i].p_i^{(t)} = \mathrm{conv}_k\bigl(s^{(t)}\bigr)[i].9. For pathology, approximately ui(t)Rcu_i^{(t)}\in\mathbb{R}^c0 images downsampled to ui(t)Rcu_i^{(t)}\in\mathbb{R}^c1 are used, and training is done on ui(t)Rcu_i^{(t)}\in\mathbb{R}^c2 patches containing epithelium.

On a single NVIDIA RTX 4090 24 GiB, the maximum single-pass inference and speed results are:

  • UNet: 8.3 MP pathology, 9.8 MP/s, 3.8 s video, 112 fps
  • Med/M3D-NCA: 28.7 MP pathology, 7.8 MP/s, 11.5 s video, 108 fps
  • OctreeNCA (PyTorch): 28.7 MP pathology, 13.9 MP/s, 11.5 s video, 219 fps
  • OctreeNCA-CUDA: 184.9 MP pathology, 77.4 MP/s, 76.2 s video, 453 fps

The pathology figure corresponds to the paper’s “single-pass 184 MP segmentation” claim. The 76.2-second video figure substantiates the statement that videos of more than one minute can be processed at once.

On a Raspberry Pi 4 with 2 GiB RAM, OctreeNCA is also reported to be feasible. For square images with side lengths ui(t)Rcu_i^{(t)}\in\mathbb{R}^c3, ui(t)Rcu_i^{(t)}\in\mathbb{R}^c4, ui(t)Rcu_i^{(t)}\in\mathbb{R}^c5, and ui(t)Rcu_i^{(t)}\in\mathbb{R}^c6 pixels, OctreeNCA inference times are ui(t)Rcu_i^{(t)}\in\mathbb{R}^c7 s, ui(t)Rcu_i^{(t)}\in\mathbb{R}^c8 s, ui(t)Rcu_i^{(t)}\in\mathbb{R}^c9 s, and ηi(t)Bernoulli(0.5){0,1}c\eta_i^{(t)} \sim \mathrm{Bernoulli}(0.5)\in\{0,1\}^c0 s, compared with ηi(t)Bernoulli(0.5){0,1}c\eta_i^{(t)} \sim \mathrm{Bernoulli}(0.5)\in\{0,1\}^c1 s, ηi(t)Bernoulli(0.5){0,1}c\eta_i^{(t)} \sim \mathrm{Bernoulli}(0.5)\in\{0,1\}^c2 s, ηi(t)Bernoulli(0.5){0,1}c\eta_i^{(t)} \sim \mathrm{Bernoulli}(0.5)\in\{0,1\}^c3 s, and ηi(t)Bernoulli(0.5){0,1}c\eta_i^{(t)} \sim \mathrm{Bernoulli}(0.5)\in\{0,1\}^c4 s for Med-NCA, and ηi(t)Bernoulli(0.5){0,1}c\eta_i^{(t)} \sim \mathrm{Bernoulli}(0.5)\in\{0,1\}^c5 s, ηi(t)Bernoulli(0.5){0,1}c\eta_i^{(t)} \sim \mathrm{Bernoulli}(0.5)\in\{0,1\}^c6 s, ηi(t)Bernoulli(0.5){0,1}c\eta_i^{(t)} \sim \mathrm{Bernoulli}(0.5)\in\{0,1\}^c7 s, and no reported ηi(t)Bernoulli(0.5){0,1}c\eta_i^{(t)} \sim \mathrm{Bernoulli}(0.5)\in\{0,1\}^c8-pixel result for UNet.

Accuracy and training VRAM usage reveal a different trade-off. On prostate MRI, OctreeNCA uses 2.18 GiB VRAM, has 17,600 parameters, and reaches Dice ηi(t)Bernoulli(0.5){0,1}c\eta_i^{(t)} \sim \mathrm{Bernoulli}(0.5)\in\{0,1\}^c9; M3D-NCA uses 14.34 GiB and reaches si(t+1)=si(t)+ηi(t)(W2  ReLU(W1[si(t);pi(t)])),s_i^{(t+1)} = s_i^{(t)} + \eta_i^{(t)}\odot \Bigl(W_2\;\mathrm{ReLU}\bigl(W_1\,[\,s_i^{(t)};\,p_i^{(t)}\,]\bigr)\Bigr),0; UNet uses 7.79 GiB and reaches si(t+1)=si(t)+ηi(t)(W2  ReLU(W1[si(t);pi(t)])),s_i^{(t+1)} = s_i^{(t)} + \eta_i^{(t)}\odot \Bigl(W_2\;\mathrm{ReLU}\bigl(W_1\,[\,s_i^{(t)};\,p_i^{(t)}\,]\bigr)\Bigr),1; nnUNet uses 7.35 GiB and reaches si(t+1)=si(t)+ηi(t)(W2  ReLU(W1[si(t);pi(t)])),s_i^{(t+1)} = s_i^{(t)} + \eta_i^{(t)}\odot \Bigl(W_2\;\mathrm{ReLU}\bigl(W_1\,[\,s_i^{(t)};\,p_i^{(t)}\,]\bigr)\Bigr),2. On pathology epithelium segmentation, OctreeNCA uses 2.25 GiB, has 15,520 parameters, and reaches Dice si(t+1)=si(t)+ηi(t)(W2  ReLU(W1[si(t);pi(t)])),s_i^{(t+1)} = s_i^{(t)} + \eta_i^{(t)}\odot \Bigl(W_2\;\mathrm{ReLU}\bigl(W_1\,[\,s_i^{(t)};\,p_i^{(t)}\,]\bigr)\Bigr),3; Med-NCA reaches si(t+1)=si(t)+ηi(t)(W2  ReLU(W1[si(t);pi(t)])),s_i^{(t+1)} = s_i^{(t)} + \eta_i^{(t)}\odot \Bigl(W_2\;\mathrm{ReLU}\bigl(W_1\,[\,s_i^{(t)};\,p_i^{(t)}\,]\bigr)\Bigr),4, UNet si(t+1)=si(t)+ηi(t)(W2  ReLU(W1[si(t);pi(t)])),s_i^{(t+1)} = s_i^{(t)} + \eta_i^{(t)}\odot \Bigl(W_2\;\mathrm{ReLU}\bigl(W_1\,[\,s_i^{(t)};\,p_i^{(t)}\,]\bigr)\Bigr),5, EfficientNet si(t+1)=si(t)+ηi(t)(W2  ReLU(W1[si(t);pi(t)])),s_i^{(t+1)} = s_i^{(t)} + \eta_i^{(t)}\odot \Bigl(W_2\;\mathrm{ReLU}\bigl(W_1\,[\,s_i^{(t)};\,p_i^{(t)}\,]\bigr)\Bigr),6, and MobilenetV2 si(t+1)=si(t)+ηi(t)(W2  ReLU(W1[si(t);pi(t)])),s_i^{(t+1)} = s_i^{(t)} + \eta_i^{(t)}\odot \Bigl(W_2\;\mathrm{ReLU}\bigl(W_1\,[\,s_i^{(t)};\,p_i^{(t)}\,]\bigr)\Bigr),7. On cholecystectomy video segmentation, measured as mean Dice across abdominal wall, liver, fat, grasper, and gallbladder, OctreeNCA uses 2.41 GiB, has 16,960 parameters, and reaches si(t+1)=si(t)+ηi(t)(W2  ReLU(W1[si(t);pi(t)])),s_i^{(t+1)} = s_i^{(t)} + \eta_i^{(t)}\odot \Bigl(W_2\;\mathrm{ReLU}\bigl(W_1\,[\,s_i^{(t)};\,p_i^{(t)}\,]\bigr)\Bigr),8; M3D-NCA reaches si(t+1)=si(t)+ηi(t)(W2  ReLU(W1[si(t);pi(t)])),s_i^{(t+1)} = s_i^{(t)} + \eta_i^{(t)}\odot \Bigl(W_2\;\mathrm{ReLU}\bigl(W_1\,[\,s_i^{(t)};\,p_i^{(t)}\,]\bigr)\Bigr),9; UNet W1R64×(c+c)W_1\in\mathbb{R}^{64\times(c+c)}0; ResNet18+U W1R64×(c+c)W_1\in\mathbb{R}^{64\times(c+c)}1; and prompt-based SAM2 W1R64×(c+c)W_1\in\mathbb{R}^{64\times(c+c)}2 (Lemke et al., 9 Aug 2025).

6. Limitations, misconceptions, and possible extensions

The paper lists several benefits directly: true size-invariance, processing of 184 MP images and more than 1-minute videos in one pass on a single 24 GiB GPU, very low VRAM of approximately 2 GiB, parameter count of approximately 16 k, inference speed of 77 MP/s on an RTX 4090, feasibility on a $50 Raspberry Pi, and built-in multi-scale global context through a simple octree of NCAs.

The limitations are equally explicit. Accuracy on small structures, with the grasper given as an example, still lags the best CNNs or promptable models. Per-level NCAs must be recompiled for each W1R64×(c+c)W_1\in\mathbb{R}^{64\times(c+c)}3 combination, although the paper describes this as minor. The absence of explicit normalization is associated with slightly lower top-end accuracy than large CNNs, with nnUNet on MRI given as the example.

These results help clarify another common misunderstanding: low memory usage and single-pass scalability do not imply state-of-the-art accuracy across all benchmarks. In the reported experiments, OctreeNCA is often competitive and sometimes better than UNet baselines under strong memory constraints, but it does not uniformly exceed larger CNN systems or promptable segmentation models. The contribution is therefore not only an accuracy claim; it is an operating-point claim about the trade-off among context, VRAM, speed, and parameter count.

The paper also names several possible extensions: incorporating attention mechanisms or learned pooling in the octree, jointly learning the downsampling and upsampling kernels instead of using fixed average pooling, extending the method to 4D octrees over space and time for very long videos, and combining the model with prompt signals as in SAM for interactive segmentation. A plausible implication is that the octree scaffold is intended as a general multiscale communication mechanism rather than a fixed endpoint, with the present formulation demonstrating that NCA-style dynamics can be scaled to consumer-hardware segmentation regimes that are difficult for more conventional architectures (Lemke et al., 9 Aug 2025).

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to OctreeNCA.