CUDA Graphs¶
CUDA-graphed wrapper for stateful models.
GraphedStatefulModel ¶
Bases: Module
Wraps a stateful model with CUDA-graphed forward, same interface.
The model must return (output, state) from forward().
The CUDA graph is captured lazily on the first forward call.
When input shapes change (e.g. different batch size at test time),
falls back to eager execution automatically. A capture that fails outright
also falls back to eager — permanently, with a RuntimeWarning naming the
error — after restoring the CUDA state a broken capture leaves behind
(current stream and RNG; see _recover_from_failed_capture).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Module
|
stateful model returning |
required |
num_warmup_iters
|
int
|
warmup iterations before graph capture |
3
|
Source code in tsfast/models/_core/cudagraph.py
reset_graph ¶
Clear captured graph (and any capture failure) for re-capture on next forward call.