ag_defer_forward: Defer forward operations into one graph

View source: R/ag_defer.R

ag_defer_forwardR Documentation

Defer forward operations into one graph

Description

Component 5 of the resident contract, and the groundwork for a fused forward+backward graph. When on, a forward ag_* operation builds its ggml node and returns a pending handle instead of computing immediately; everything queued is computed as a single graph the first time any value is read (the loss, on the training path) or when backward() starts.

Usage

ag_defer_forward(on = TRUE)

Arguments

on

'TRUE' to defer, 'FALSE' to compute per operation, 'NA' to query.

Details

OFF by default: GGMLR_AG_DEFER=1 or TRUE here enables it. The measured gain on a training step is 1.0-1.3x (the forward is dominated by weight upload, which this does not change), so it is enabled for the fused graph work rather than for its own sake.

Value

The previous state, invisibly.


ggmlR documentation built on Oct. 23, 2026, 1:07 a.m.