(rontolisp) docs
← Macros

torch:no-grad

(torch:no-grad body...)

Runs the body with gradient recording disabled: the torch operations inside compute their values as usual but record nothing on the autograd tape, so the results are constant leaves (torch:requires-grad-p answers nil) and no history is retained. This is how a training loop's parameter update -- and inference in general -- stays off the tape; the per-tensor spelling is torch:detach.

Mechanically it dynamically rebinds the internal torch::*grad-enabled* variable to nil around the body, so recording resumes when the form exits.