Skip to content

Commit

Permalink
Fix a bug in unfreeze (#660)
Browse files Browse the repository at this point in the history
*Description of changes:*
When we unfreeze the LM model, we don't need to clean up the cache if
the number of train nodes is 0.

By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.

Co-authored-by: Ubuntu <[email protected]>
  • Loading branch information
2 people authored and jalencato committed Nov 20, 2023
1 parent 97d36c7 commit ec7eaac
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions python/graphstorm/model/lm_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,10 +516,11 @@ def freeze(self, _):
def unfreeze(self):
""" Disable Bert caching
"""
self.use_cache = False
# We should clear up the LM cache here. When someone calls unfreeze,
# we expect that the LM model will be fine-tuned.
self.lm_emb_cache.clear_cache()
if self.num_train > 0:
self.use_cache = False
# We should clear up the LM cache here. When someone calls unfreeze,
# we expect that the LM model will be fine-tuned.
self.lm_emb_cache.clear_cache()

def require_cache_embed(self):
""" Whether to cache the embeddings for inference.
Expand Down Expand Up @@ -726,10 +727,11 @@ def freeze(self, _):
def unfreeze(self):
""" Disable Bert caching
"""
self.use_cache = False
# We should clear up the LM cache here. When someone calls unfreeze,
# we expect that the LM model will be fine-tuned.
self.lm_emb_cache.clear_cache()
if self.num_train > 0:
self.use_cache = False
# We should clear up the LM cache here. When someone calls unfreeze,
# we expect that the LM model will be fine-tuned.
self.lm_emb_cache.clear_cache()

def require_cache_embed(self):
""" Whether to cache the embeddings for inference.
Expand Down

0 comments on commit ec7eaac

Please sign in to comment.