File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
src/memos/memories/activation Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -210,14 +210,15 @@ def _concat_caches(self, caches: list[DynamicCache]) -> DynamicCache:
210210
211211 merged = DynamicCache ()
212212 num_layers = len (caches [0 ].key_cache )
213+ merged .append_new_layers (num_layers - 1 )
213214
214215 for layer in range (num_layers ):
215216 # gather all K and V for this layer
216- keys = [c .key_cache [layer ] for c in caches ]
217- vals = [c .value_cache [layer ] for c in caches ]
217+ keys = [c .layers [layer ]. keys for c in caches ]
218+ vals = [c .layers [layer ]. values for c in caches ]
218219 # single concat per layer
219- merged .key_cache . append (torch .cat (keys , dim = - 2 ))
220- merged .value_cache . append (torch .cat (vals , dim = - 2 ))
220+ merged .layers [ layer ]. keys = (torch .cat (keys , dim = - 2 ))
221+ merged .layers [ layer ]. values = (torch .cat (vals , dim = - 2 ))
221222
222223 return merged
223224
You can’t perform that action at this time.
0 commit comments