Temporarily enable or disable Flash Attention 3
Source:R/attention.R, R/inference.R
flash_attn3_toggle.RdThis function provides a simple save/restore pattern to control whether Flash Attention 3 is used during attention computation.
Temporarily enable or disable Flash Attention 3 during inference.
Value
A function that, when called, restores the previous setting.
Function. Restoration function to call when done.
Examples
if (FALSE) { # \dontrun{
# Temporarily disable Flash Attention 3
restore <- flash_attn3_toggle(FALSE)
# ... run inference ...
restore() # Restore previous setting
# Or use with on.exit() for automatic restoration
old <- flash_attn3_toggle(FALSE)
on.exit(old(), add = TRUE)
# ... code that uses attention ...
} # }
if (FALSE) { # \dontrun{
# Temporarily disable FA3
restore <- flash_attn3_toggle(FALSE)
# ... run inference ...
restore() # Restore previous setting
} # }