File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -91,6 +91,8 @@ def activate(self):
9191 self .to_state (RunningState )
9292
9393 def evict (self ):
94+ # clean up meta before evict
95+ self .seq .cleanup ()
9496 self .to_state (WaitingState )
9597
9698
Original file line number Diff line number Diff line change @@ -87,6 +87,10 @@ def set_step(self, step: int):
8787 if len (self .all_routed_experts ) > step :
8888 self .all_routed_experts .resize (step )
8989
90+ def cleanup (self ):
91+ """Setup history meta after sequence stopped or cancelled."""
92+ pass
93+
9094
9195class ARSequenceStrategy (SequenceStrategy ):
9296
Original file line number Diff line number Diff line change @@ -166,6 +166,13 @@ def set_step(self, step: int):
166166 if len (self .all_routed_experts ) > step :
167167 self .all_routed_experts .resize (step )
168168
169+ def cleanup (self ):
170+ """Setup history meta after sequence stopped or cancelled."""
171+ # truncate history cache to valid ids
172+ self .history_cache .resize (self .num_valid_ids )
173+ self ._num_history_ids = self .num_valid_ids - 1
174+ self ._num_token_ids = 1
175+
169176
170177class ARSpecSequenceStrategy (ARSequenceStrategy ):
171178
You can’t perform that action at this time.
0 commit comments