Merged
Conversation
added 2 commits
June 12, 2025 21:42
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refines the attention and padding configuration for FA2 (flash vs SDPA attention) and adds helper scripts for comparing embedding consistency across modes.
- Enhanced type safety with
Literalforattention_layerandpaddinginFlexBertConfig - Unified padding/attention-mask logic in
Ume.__init__and newUme.load_from_checkpoint - Added example and test scripts to validate SDPA vs flash-attention embedding consistency
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/lobster/model/modern_bert/_config.py | Added Literal type hints for attention_layer and padding parameters |
| src/lobster/model/_ume.py | Refactored padding/mask logic; introduced load_from_checkpoint method |
| src/lobster/model/README.md | Documented UME model and its dynamic checkpoint loader |
| slurm/scripts/test_fa2_ume.sh | New SLURM submission script for SDPA vs flash‐attention test |
| pyproject.toml | Pinned triton<=3.1.0; excluded examples from linting |
| examples/test_sdpa_unpadded_attention_mask.py | New test script to inspect attention masks |
| examples/test_embed_fa2.py | Simple embedding example for flash-attention |
| examples/compare_flash_attention_embeddings.py | Comprehensive script comparing embeddings across modes |
Comments suppressed due to low confidence (4)
src/lobster/model/_ume.py:158
- [nitpick] Configuration logic for padding and masks is duplicated between
__init__andload_from_checkpoint. Consider extracting this into a shared helper to adhere to DRY principles.
if ckpt_path is not None:
src/lobster/model/_ume.py:791
- Restricting
deviceto exactly "cpu" or "cuda" excludes valid strings like "cuda:0" or custom devices. Consider accepting atorch.deviceobject or allowing any string that starts with "cuda" for greater flexibility.
if device not in ["cpu", "cuda"]:
src/lobster/model/_ume.py:752
- The new
load_from_checkpointmethod isn’t covered by existing unit tests. Adding targeted tests for CPU vs GPU loading, verifyingpaddinganduse_sdpa_attn_masksettings, would help prevent regressions.
def load_from_checkpoint(
src/lobster/model/README.md:3
- [nitpick] The link reference to
_ume.pymay not resolve correctly in rendered markdown. Consider linking to theUmeclass documentation or using a direct path to the file.
## [Universal Molecular Encoder](_ume.py)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
karinazad
reviewed
Jun 17, 2025
Collaborator
There was a problem hiding this comment.
let's rename test_ to something else so it's not accidentally picked up by pytest
karinazad
reviewed
Jun 17, 2025
karinazad
reviewed
Jun 17, 2025
karinazad
reviewed
Jun 17, 2025
| """ | ||
| # Determine device | ||
| if device is not None: | ||
| if device not in ["cpu", "cuda"]: |
Collaborator
There was a problem hiding this comment.
device could be something like "cuda:0" ?
karinazad
approved these changes
Jun 17, 2025
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.
No description provided.