Skip to content

Commit

Permalink
Fix Generation with Sequential Model (#1026)
Browse files Browse the repository at this point in the history
  • Loading branch information
xu-song committed Sep 15, 2023
1 parent 2922bef commit 960ed3d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions megatron/model/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ def exec_func(*inputs):
x = exec_range_func(start_idx, end_idx)(*x)
return x

def clear_cache(self):
"""
Recursively clears the kv cache on all layers
"""
recursive_setattr(self.sequential, "layer_past", None)


def recursive_setattr(m, attr, value, assert_type=None, type_filter=None):
"""
Expand Down

0 comments on commit 960ed3d

Please sign in to comment.