Refactor/strict bool for use flash attn#179
Merged
ncfrey merged 5 commits intoprescient-design:mainfrom Aug 5, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the use_flash_attn parameter from a tri-state boolean (bool | None) to a strict boolean (bool) across the codebase. The change eliminates the implicit auto-detection logic where None meant "auto-detect based on device" and replaces it with explicit defaults and warning messages when flash attention is requested but unavailable.
Key changes:
- Updated
use_flash_attnparameter frombool | Nonetoboolwith appropriate defaults - Replaced implicit auto-detection logic with explicit warning and override behavior
- Set different defaults for production code (
True) vs mock implementations (False)
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/lobster/model/_ume.py |
Changed use_flash_attn parameter to strict bool with default True, added warning when flash attention is requested but CUDA unavailable |
tests/lobster/model/test__ume.py |
Updated test to reflect new default value of True for use_flash_attn |
src/lobster/evaluation/dgeb_runner.py |
Changed parameter to strict bool with default True, removed conditional logic in main function |
src/lobster/evaluation/dgeb_mock_runner.py |
Changed parameter to strict bool with default False for mock implementation |
src/lobster/evaluation/dgeb_mock_adapter.py |
Updated mock adapter to use strict bool with default False |
src/lobster/evaluation/dgeb_adapter.py |
Refactored flash attention detection logic to use strict bool with default True |
ncfrey
approved these changes
Aug 4, 2025
tests/lobster/model/test__ume.py
Outdated
| load_func=UME.load_from_checkpoint, | ||
| device=None, | ||
| use_flash_attn=None, | ||
| use_flash_attn=True, |
Contributor
There was a problem hiding this comment.
we might want to change this to False to run on CPU runners
Contributor
Author
There was a problem hiding this comment.
Got it, just pushed a new commit switching to use_flash_attn=False for this test!
Contributor
|
@young-su-ko looks good! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Replaced all instances of the tri-state Boolean
use_flash_attn: bool | None = Noneto be strictly abool. Addresses #170.model/_ume.pyuse_flash_attn = Noneimplied that the user had no preference, and flash attention would be enabled automatically ifdevice == "cuda".use_flash_attn: bool = Trueuse_flash_attnisTruebut flash attention is not available (device != "cuda"), a warning is logged anduse_flash_attnis overridden toFalse.tests/model/test__ume.pytest_from_pretrainedto reflect thatuse_flash_attn = Trueis now the default.evaluation/dgeb_*.pydgeb_adapter.pyanddgeb_runner.py, the default is nowuse_flash_attn = TrueFalseand a warning is logged._check_flash_attention_availablemethod fromUMEAdapterDGEBto check whether flash attention can be enabled (compared to justdevice != "cuda")dgeb_mock_adapter.pyanddgeb_mock_runner.py, the default is set toFalseas flash attention is explicitly unused in the mock implementation.Type of Change