You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains 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
Possible Bug The assertion for NaN detection in the MultiheadAttention output has been moved to a new location. Ensure that this does not affect the logic of the model, especially if the previous assertion was critical for debugging.
Code Smell The function create_attn_padding_mask has a complex logic that could be simplified. Consider breaking it down into smaller functions for better readability and maintainability.
Why: This suggestion enhances the code's robustness by ensuring that the padding mask matches the input tensor's properties, which is important for maintaining consistency in tensor operations.
8
Add a check for empty masks before performing assertions
Consider adding a check to ensure that attn_mask and key_padding_mask are not empty before proceeding with the assertion to avoid unnecessary computations.
Why: Adding a check for empty masks is a reasonable performance improvement, but it does not address a critical issue. The assertion itself is important for debugging.
6
Best practice
Set float16 based on the availability of a GPU
Ensure that float16 is only set to True when the model is actually running on a GPU to prevent unnecessary precision loss on CPU.
Why: This suggestion improves the model's efficiency by conditionally setting float16, which is a good practice when dealing with hardware capabilities.
7
Possible issue
Add a check to ensure val_dataset is initialized before use
Ensure that self.val_dataset is properly initialized before being used in val_dataloader to avoid potential runtime errors.
return DataLoader(
-+ self.val_dataset,+ self.val_dataset if self.val_dataset is not None else raise ValueError("val_dataset must be initialized"),
Suggestion importance[1-10]: 3
Why: While it's good practice to ensure that val_dataset is initialized, the suggestion does not provide a proper implementation for handling the case when it is not initialized, which could lead to runtime errors.
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.
User description
Summary
PR Type
enhancement, bug fix, tests
Description
Changes walkthrough 📝
6 files
dataset.py
Update validation data loader
sasrec/data/dataset.py
val_dataset
instead oftest_dataset
.sasrec.py
Add float16 support for model training
sasrec/models/sasrec.py
float16
parameter for model optimization.float16
.train.py
Optimize training configuration
sasrec/train.py
utils.py
Add utility function for CPU core count
sasrec/utils/utils.py
cpu_count
function to get the number of CPU cores.Makefile
Update Makefile for training command
sasrec/Makefile
train
target to Makefile for easier execution.pyproject.toml
Update project dependencies
sasrec/pyproject.toml
3 files
transformer_embedding.py
Fix embedding layer issues
sasrec/models/modules/transformer_embedding.py
id_embeddings
.transformer_encoder_block.py
Enhance NaN detection in attention block
sasrec/models/modules/transformer_encoder_block.py
test_utils.py
Fix padding mask creation in tests
sasrec/tests/test_utils/test_utils.py
1 files
README.md
Improve documentation with detailed model info
sasrec/README.md