lgatr.primitives.compile
Helpers for using L-GATr primitives with torch.compile().
Functions
|
Warm L-GATr's primitive caches for the model's current device and dtype. |
|
Pre-populate L-GATr's primitive caches for a given device and dtype. |
- lgatr.primitives.compile.warmup_after_apply(model)[source]
Warm L-GATr’s primitive caches for the model’s current device and dtype.
Intended to be called from a
torch.nn.Module._apply()override so the caches are populated whenever the model is moved or cast (.to()/.cuda()/.float()/ etc.).- Parameters:
model (
Module) – Thetorch.nn.Modulewhose primitive caches should be warmed.- Return type:
None
- lgatr.primitives.compile.warmup_caches(device, dtype=torch.float32)[source]
Pre-populate L-GATr’s primitive caches for a given device and dtype.
Without warming, the first call for a new
(device, dtype)pair triggers host-to-device copies that partition the captured graph undertorch.compile()withmode="reduce-overhead". Calling this helper once per(device, dtype)before compiling avoids the partition.- Parameters:
device (
device|str) – Target device, either atorch.deviceor a string like"cuda"or"cpu".dtype (
dtype) – Floating-point dtype matching what the model will run in.
- Return type:
None