Skip to content

fix: Flash Attention compatibility check for SM_1xx (RTX 5000 series) #1880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/models/model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -844,16 +844,19 @@ namespace ctranslate2 {
" running independently a model in each device");
}

bool is_sm8x = false;
bool is_sm90 = false;
bool supports_flash_attention = false;
if (device == Device::CUDA) {
int device_id = ctranslate2::get_device_index(ctranslate2::Device::CUDA);
auto dprops = ctranslate2::cuda::get_device_properties(device_id);
is_sm8x = dprops.major == 8 && dprops.minor >= 0;
is_sm90 = dprops.major == 9 && dprops.minor == 0;
}
if (use_flash_attention && (device != Device::CUDA || (!is_sm8x && !is_sm90))) {
throw std::invalid_argument("FlashAttention only supports Ampere GPUs or newer.");
float compute_capability = dprops.major + (dprops.minor / 10.0f);

// Minimum compute capability for Flash Attention is Ampere (8.0)
const float min_flash_attn_compute_capability = 8.0f;
supports_flash_attention = compute_capability >= min_flash_attn_compute_capability;
}

if (use_flash_attention && (device != Device::CUDA || !supports_flash_attention)) {
throw std::invalid_argument("FlashAttention only supports Ampere GPUs (compute capability >= 8.0) or newer.");
}
#endif

Expand Down
Loading