Skip to content

Image understanding, generation, and 3D reconstruction · Neural rendering and 3D reconstruction · VIS019 · Architecture

Instant-NGP multiresolution hash encoding

Instant-NGP accelerates fitting neural graphics primitives using trainable multiresolution hash features and small neural networks. Its encoding can serve radiance fields, signed-distance functions and other signals;

Explained here Component demo, not a trained model CodeSplash's run and the reference's record

In CodeSplash

Documented in the Academy only. There's no Set up button.

Availability
Explained here
Code example
Component demo, not a trained model
Who ran it
CodeSplash's run and the reference's record
CodeSplash's run
The reference's example ran in Python and R here, and they agree.
The reference's record
Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.

Purpose

Instant-NGP accelerates fitting neural graphics primitives using trainable multiresolution hash features and small neural networks. Its encoding can serve radiance fields, signed-distance functions and other signals; speed also depends strongly on the optimized GPU implementation, not only the mathematical representation.

Question / hypotheses

Can multiresolution hash features fit the target spatial signal accurately under a measured time and memory budget? This is a modeling/evaluation question, not a formal null-hypothesis test.

Architecture / computational structure

At each spatial resolution, neighboring grid vertices index a learned feature table through a hash or direct addressing scheme. Interpolated features across levels are concatenated and passed to a compact MLP. Different signals use suitable output heads and losses.

Assumptions

Coordinates need a declared bounded normalization. Hash collisions are shared parameter constraints, not numerical corruption, but excessive collisions can limit detail. Scene reconstruction inherits camera/view coverage assumptions; published speed figures do not transfer automatically to unoptimized CPU code.

Formula / computational definition

z(x)=⨁l=1L∑v∈Nl(x)wlv(x) θl[hl(v)]z(x)=\bigoplus_{l=1}^L\sum_{v\in\mathcal N_l(x)}w_{lv}(x)\,\theta_l[h_l(v)], where interpolation weights ww sum to one within a level, hlh_l maps vertices to table entries and θl\theta_l stores learned features. A decoder fϕ(z(x))f_\phi(z(x)) predicts the signal.

Parameters and notation

Notation: Here x is a normalized position, l a resolution level, N_l(x) neighboring grid vertices, h_l a table-index function and theta_l trainable feature entries. The direct sum concatenates levels; phi denotes decoder weights, separate from table entries.

Learned or estimated: Hash-table feature vectors at every level and decoder MLP parameters; for radiance fields, density/color heads are also fitted.

Hyperparameters and effects: Levels, minimum/maximum grid resolution, table capacity, features per entry, interpolation, decoder width and ray-sampling configuration. Smaller tables use less memory but create more collisions; more levels increase multiscale capacity and bandwidth.

Fitting, fine-tuning, and adaptation

Fit tables and decoder jointly for the selected scene/signal. For refinement, continue with lower rates while retaining old-view samples. Reusing a table after changing coordinate frames is generally invalid without remapping; freeze only meaningful compatible blocks. Validate held-out views or signal samples and monitor source-region degradation.

How to use and calibrate

Hold out complete camera views and, for transfer claims, complete scenes; report calibration, coordinate units and capture overlap. Report quality versus wall-clock training, memory and rendering/query cost on specified hardware. Ablate table size and levels, examine fine-detail artifacts and compare against a nonhashed representation with similar capacity.

Example application

Fit a compact radiance-field representation of a captured static scene rapidly on suitable hardware. This is a proposed use case, not a claim of validated performance on supplied real data.

Interpretation / pitfalls

Watch out

Scene fitting may achieve high training-view fidelity with incorrect geometry. Rendering quality, camera accuracy and geometric validity need separate checks. A correct component calculation does not validate the full architecture, checkpoint or deployment pipeline.

Python and R code examples

Scope: Two-level 2D hash-grid interpolation with deliberately tiny tables; this demonstrates encoding and collisions, not the optimized 3D Instant-NGP implementation. Use the shared setup. Dependencies: NumPy / base R. Validation: Python executed; R unexecuted.

Full-model route: Python: official instant-ngp bindings/build or a verified hash-grid implementation. R: bridge for the optimized system. The native examples interpolate two small 2D hash grids; they do not reproduce CUDA throughput or the full 3D renderer.

Python and R

The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.

Python

Component demo, not a trained model — Two-level 2D hash-grid interpolation with deliberately tiny tables; this demonstrates encoding and collisions, not the optimized 3D Instant-NGP implementation. Use the shared setup.

Shared setup for this chapter
import numpy as np
from itertools import permutations
def softmax(x):
    x=np.asarray(x,dtype=float)
    e=np.exp(x-x.max(axis=-1,keepdims=True))
    return e/e.sum(axis=-1,keepdims=True)
def bilinear(a,y,x):
    y=float(np.clip(y,0,a.shape[0]-1)); x=float(np.clip(x,0,a.shape[1]-1))
    y0=int(np.floor(y)); x0=int(np.floor(x))
    y1=min(y0+1,a.shape[0]-1); x1=min(x0+1,a.shape[1]-1)
    dy=y-y0; dx=x-x0
    return (1-dy)*((1-dx)*a[y0,x0]+dx*a[y0,x1])+dy*((1-dx)*a[y1,x0]+dx*a[y1,x1])
point=np.array([.35,.6]); table=np.arange(16,dtype=float).reshape(8,2)/16
features=[]
for resolution in [2,4]:
    u=point*resolution; lo=np.floor(u).astype(int); frac=u-lo; z=np.zeros(2); weights=[]
    for a,b in [(0,0),(1,0),(0,1),(1,1)]:
        vertex=lo+np.array([a,b]); idx=int((vertex[0]*3 ^ vertex[1]*5)%8)
        w=(frac[0] if a else 1-frac[0])*(frac[1] if b else 1-frac[1])
        z+=w*table[idx]; weights.append(w)
    assert np.isclose(sum(weights),1); features.extend(z)
assert len(features)==4
print('concatenated hash features:',features)
R

Component demo, not a trained model — Two-level 2D hash-grid interpolation with deliberately tiny tables; this demonstrates encoding and collisions, not the optimized 3D Instant-NGP implementation. Use the shared setup.

Shared setup for this chapter
softmax <- function(x) {
  if(is.null(dim(x))) {e<-exp(x-max(x)); return(e/sum(e))}
  t(apply(x,1,function(v) {e<-exp(v-max(v)); e/sum(e)}))
}
bilinear <- function(a,y,x) {
  y<-min(max(y,0),nrow(a)-1); x<-min(max(x,0),ncol(a)-1)
  y0<-floor(y); x0<-floor(x); y1<-min(y0+1,nrow(a)-1); x1<-min(x0+1,ncol(a)-1)
  dy<-y-y0; dx<-x-x0
  (1-dy)*((1-dx)*a[y0+1,x0+1]+dx*a[y0+1,x1+1])+dy*((1-dx)*a[y1+1,x0+1]+dx*a[y1+1,x1+1])
}
point<-c(.35,.6); table<-matrix(0:15,8,byrow=TRUE)/16; features<-numeric()
for(resolution in c(2,4)) {
 u<-point*resolution; lo<-floor(u); frac<-u-lo; z<-c(0,0); weights<-numeric()
 for(a in 0:1) for(b in 0:1) {
  vertex<-lo+c(a,b); idx<-bitwXor(as.integer(vertex[1]*3),as.integer(vertex[2]*5))%%8+1
  w<-(if(a==1) frac[1] else 1-frac[1])*(if(b==1) frac[2] else 1-frac[2])
  z<-z+w*table[idx,]; weights<-c(weights,w)
 }; stopifnot(abs(sum(weights)-1)<1e-12); features<-c(features,z)
}
stopifnot(length(features)==4); print(list(concatenated_hash_features=features))

Sources

From the CodeSplash reference, entry VIS019.