Class VerifyCudaGraph
java.lang.Object
smile.llm.engine.VerifyCudaGraph
Optional CUDA graph capture for the multi-token MTP window-verify forward
(
S = numDrafts + 1), independent of DecodeCudaGraph.
Enable with environment variable SMILE_VERIFY_CUDA_GRAPH=1 —
this both wires the new stable-buffer / graph-capturable-kernel path and
enables real capture (captureEnabled()), mirroring
SMILE_DECODE_CUDA_GRAPH's single-flag design. Stage 4 of the
verify-CUDA-graph plan validated the buffer/kernel path in a shadow-run
mode with capture hard-disabled (a now-removed compile-time constant, not a
runtime flag); Stage 5 enables real capture once Stage 4's numerics were
validated against the existing eager path on real hardware (byte-identical
output, no perf regression).
Bucketed by (batch, windowLen, numPages), mirroring
DecodeCudaGraph's (batch, numPages) bucketing plus the
extra windowLen dimension (query length is not implicitly 1 here).
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleancanGraphVerify(int[] startPositions) Returns whether this verify step is eligible for CUDA graph capture/replay.static booleanReturns whether real graph capture may be attempted (Stage 5: same gate asenabled()— a single flag, mirroringSMILE_DECODE_CUDA_GRAPH).static booleanReturns whether the diagnostic eager-vs-graph verify diff is enabled (seeDEBUG_DIFF).static voiddisableCapture(String reason) Permanently disable verify CUDA graphs for this process (after a capture failure).static booleanenabled()Returns whether verify CUDA-graph buffer/kernel wiring is enabled for this process (independent of whether capture itself is enabled).static voidmarkPersistentLogits(boolean persistent) Marks that the current verify step returned logits backed by a captured CUDA graph output buffer (must not be closed by the caller) — mirrorsDecodeCudaGraph.markPersistentLogits(boolean).static intmaxBatch()Largest batch that uses a verify graph (each captured batch size keeps its own activation pool, which at large batches competes with the DeltaNet checkpoint buffers for GPU memory).static booleanReturns whether verify logits outlive the caller's own scope (i.e.static booleanWhether ragged (per-row positions, batch > 1) windows may use the verify graph.static intReturns the number of eager warmup verify steps before graph capture.
-
Method Details
-
enabled
public static boolean enabled()Returns whether verify CUDA-graph buffer/kernel wiring is enabled for this process (independent of whether capture itself is enabled).- Returns:
truewhen env is set, native API is linked, and capture is not disabled.
-
captureEnabled
public static boolean captureEnabled()Returns whether real graph capture may be attempted (Stage 5: same gate asenabled()— a single flag, mirroringSMILE_DECODE_CUDA_GRAPH).- Returns:
truewhen verify CUDA graphs are enabled and capture has not been disabled after a prior failure.
-
raggedEnabled
public static boolean raggedEnabled()Whether ragged (per-row positions, batch > 1) windows may use the verify graph. On by default with the verify graph;SMILE_VERIFY_CUDA_GRAPH_RAGGED=0disables.- Returns:
truewhen ragged batched graphs are enabled.
-
maxBatch
public static int maxBatch()Largest batch that uses a verify graph (each captured batch size keeps its own activation pool, which at large batches competes with the DeltaNet checkpoint buffers for GPU memory). Override withSMILE_VERIFY_CUDA_GRAPH_MAX_BATCH.- Returns:
- maximum batch size eligible for graph capture.
-
canGraphVerify
public static boolean canGraphVerify(int[] startPositions) Returns whether this verify step is eligible for CUDA graph capture/replay.- Parameters:
startPositions- per-row KV window start positions.- Returns:
truewhen every row shares the same start position (a homogeneous cohort; batch > 1 verify-graph is otherwise out of scope today, but the check does not hardcode batch == 1).
-
disableCapture
Permanently disable verify CUDA graphs for this process (after a capture failure).- Parameters:
reason- human-readable failure reason (for callers; not logged here).
-
warmupSteps
public static int warmupSteps()Returns the number of eager warmup verify steps before graph capture.- Returns:
- warmup steps per
(batch, windowLen, numPages)bucket.
-
debugDiff
public static boolean debugDiff()Returns whether the diagnostic eager-vs-graph verify diff is enabled (seeDEBUG_DIFF).- Returns:
truewhenSMILE_VERIFY_CUDA_GRAPH_DEBUG_DIFF=1.
-
markPersistentLogits
public static void markPersistentLogits(boolean persistent) Marks that the current verify step returned logits backed by a captured CUDA graph output buffer (must not be closed by the caller) — mirrorsDecodeCudaGraph.markPersistentLogits(boolean). A sharedAtomicBoolean, not thread-local: TP fan-out sets this from each rank's worker thread, and the join point (after every rank's future completes) reads it back on the calling thread.- Parameters:
persistent-truewhen logits outlive the caller's own scope.
-
persistentLogits
public static boolean persistentLogits()Returns whether verify logits outlive the caller's own scope (i.e. are QwenModel's own reused capture buffer, not a throwaway eager tensor).- Returns:
truewhen the caller must not close the returned tensor.
-