1
0

block_manager_v1.py 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. """A block manager that manages token blocks."""
  2. from abc import ABC, abstractmethod
  3. from itertools import count, takewhile
  4. from os.path import commonprefix
  5. from typing import Dict, List, Optional, Set
  6. from loguru import logger
  7. from aphrodite.common.block import BlockTable, PhysicalTokenBlock
  8. from aphrodite.processing.evictor import EvictionPolicy, Evictor, make_evictor
  9. from aphrodite.processing.interfaces import AllocStatus, BlockSpaceManager
  10. from aphrodite.common.sequence import Sequence, SequenceGroup, SequenceStatus
  11. from aphrodite.common.utils import Device
  12. class BlockAllocatorBase(ABC):
  13. """Manages free physical token blocks for a device.
  14. The allocator maintains a list of free blocks and allocates a block when
  15. requested. When a block is freed, its reference count is decremented. If
  16. the reference count becomes zero, the block is added back to the free list.
  17. """
  18. @abstractmethod
  19. def __init__(self,
  20. device: Device,
  21. block_size: int,
  22. num_blocks: int,
  23. eviction_policy: EvictionPolicy = EvictionPolicy.LRU):
  24. pass
  25. @abstractmethod
  26. def allocate(self,
  27. block_hash: Optional[int] = None,
  28. num_hashed_tokens: int = 0) -> PhysicalTokenBlock:
  29. pass
  30. @abstractmethod
  31. def free(self, block: PhysicalTokenBlock) -> None:
  32. pass
  33. @abstractmethod
  34. def get_num_free_blocks(self) -> int:
  35. pass
  36. @abstractmethod
  37. def contains_block(self, block_hash: int) -> bool:
  38. pass
  39. @abstractmethod
  40. def update_hash(self, block_hash: int, block: PhysicalTokenBlock):
  41. pass
  42. class CachedBlockAllocator(BlockAllocatorBase):
  43. """Manages free physical token blocks for a device.
  44. The allocator maintains a list of free blocks and allocates a block when
  45. requested. When a block is freed, its reference count is decremented. If
  46. the reference count becomes zero, the block is added back to the free list.
  47. """
  48. def __init__(self,
  49. device: Device,
  50. block_size: int,
  51. num_blocks: int,
  52. eviction_policy: EvictionPolicy = EvictionPolicy.LRU) -> None:
  53. self.device = device
  54. self.block_size = block_size
  55. self.num_blocks = num_blocks
  56. self.current_num_blocks = 0
  57. self.cached_blocks: Dict[int, PhysicalTokenBlock] = {}
  58. self.evictor: Evictor = make_evictor(eviction_policy)
  59. self.default_hash_ctr = count()
  60. def allocate_block(self, block_hash: int,
  61. num_hashed_tokens: int) -> PhysicalTokenBlock:
  62. if self.current_num_blocks == self.num_blocks:
  63. block = self.evictor.evict()
  64. block.block_hash = block_hash
  65. block.num_hashed_tokens = num_hashed_tokens
  66. return block
  67. block = PhysicalTokenBlock(device=self.device,
  68. block_number=self.current_num_blocks,
  69. block_size=self.block_size,
  70. block_hash=block_hash,
  71. num_hashed_tokens=num_hashed_tokens)
  72. self.current_num_blocks += 1
  73. return block
  74. def allocate(self,
  75. block_hash: Optional[int] = None,
  76. num_hashed_tokens: int = 0) -> PhysicalTokenBlock:
  77. if block_hash is None:
  78. block_hash = next(self.default_hash_ctr)
  79. if block_hash in self.evictor:
  80. assert block_hash not in self.cached_blocks
  81. block = self.evictor.remove(block_hash)
  82. assert block.ref_count == 0
  83. self.cached_blocks[block_hash] = block
  84. block.ref_count += 1
  85. assert block.block_hash == block_hash
  86. return block
  87. if block_hash not in self.cached_blocks:
  88. self.cached_blocks[block_hash] = self.allocate_block(
  89. block_hash, num_hashed_tokens)
  90. block = self.cached_blocks[block_hash]
  91. assert block.block_hash == block_hash
  92. block.ref_count += 1
  93. return block
  94. def free(self, block: PhysicalTokenBlock) -> None:
  95. if block.ref_count == 0:
  96. raise ValueError(f"Double free! {block} is already freed.")
  97. block.ref_count -= 1
  98. if block.ref_count == 0:
  99. assert block.block_hash not in self.evictor
  100. self.evictor.add(block)
  101. # Remove the block from the cached_blocks
  102. del self.cached_blocks[block.block_hash]
  103. def get_num_free_blocks(self) -> int:
  104. return (self.num_blocks - self.current_num_blocks +
  105. self.evictor.num_blocks)
  106. def contains_block(self, block_hash: int) -> bool:
  107. return block_hash in self.cached_blocks or block_hash in self.evictor
  108. def update_hash(self, block_hash: int, block: PhysicalTokenBlock):
  109. # Update the hash of block and the cached_blocks dictionary.
  110. assert not self.contains_block(block_hash)
  111. old_hash = block.block_hash
  112. block.block_hash = block_hash
  113. del self.cached_blocks[old_hash]
  114. self.cached_blocks[block_hash] = block
  115. class UncachedBlockAllocator(BlockAllocatorBase):
  116. """Manages free physical token blocks for a device.
  117. The allocator maintains a list of free blocks and allocates a block when
  118. requested. When a block is freed, its reference count is decremented. If
  119. the reference count becomes zero, the block is added back to the free list.
  120. """
  121. def __init__(
  122. self,
  123. device: Device,
  124. block_size: int,
  125. num_blocks: int,
  126. ) -> None:
  127. self.device = device
  128. self.block_size = block_size
  129. self.num_blocks = num_blocks
  130. # Initialize the free blocks.
  131. self.free_blocks: BlockTable = []
  132. for i in range(num_blocks):
  133. block = PhysicalTokenBlock(device=device,
  134. block_number=i,
  135. block_size=block_size,
  136. block_hash=-1,
  137. num_hashed_tokens=0)
  138. self.free_blocks.append(block)
  139. def allocate(self,
  140. block_hash: Optional[int] = None,
  141. num_hashed_tokens: int = 0) -> PhysicalTokenBlock:
  142. if not self.free_blocks:
  143. raise ValueError("Out of memory! No free blocks are available.")
  144. block = self.free_blocks.pop()
  145. block.ref_count = 1
  146. return block
  147. def free(self, block: PhysicalTokenBlock) -> None:
  148. if block.ref_count == 0:
  149. raise ValueError(f"Double free! {block} is already freed.")
  150. block.ref_count -= 1
  151. if block.ref_count == 0:
  152. self.free_blocks.append(block)
  153. def get_num_free_blocks(self) -> int:
  154. return len(self.free_blocks)
  155. def contains_block(self, block_hash: int) -> bool:
  156. raise NotImplementedError(
  157. "Invalid codepath for uncached block allocator.")
  158. def update_hash(self, block_hash: int, block: PhysicalTokenBlock):
  159. raise NotImplementedError(
  160. "Invalid codepath for uncached block allocator.")
  161. class BlockSpaceManagerV1(BlockSpaceManager):
  162. """Manages the mapping between logical and physical token blocks."""
  163. def __init__(
  164. self,
  165. block_size: int,
  166. num_gpu_blocks: int,
  167. num_cpu_blocks: int,
  168. watermark: float = 0.01,
  169. sliding_window: Optional[int] = None,
  170. enable_caching: bool = False,
  171. ) -> None:
  172. self.block_size = block_size
  173. self.num_total_gpu_blocks = num_gpu_blocks
  174. self.num_total_cpu_blocks = num_cpu_blocks
  175. if enable_caching and sliding_window is not None:
  176. raise NotImplementedError(
  177. "Sliding window is not allowed with Context Shift enabled!")
  178. self.block_sliding_window = None
  179. if sliding_window is not None:
  180. assert sliding_window % block_size == 0, (sliding_window,
  181. block_size)
  182. self.block_sliding_window = sliding_window // block_size
  183. self.watermark = watermark
  184. assert watermark >= 0.0
  185. self.enable_caching = enable_caching
  186. self.watermark_blocks = int(watermark * num_gpu_blocks)
  187. if self.enable_caching:
  188. logger.info("Context Shift is enabled.")
  189. self.gpu_allocator = CachedBlockAllocator(Device.GPU, block_size,
  190. num_gpu_blocks)
  191. self.cpu_allocator = CachedBlockAllocator(Device.CPU, block_size,
  192. num_cpu_blocks)
  193. else:
  194. self.gpu_allocator = UncachedBlockAllocator(
  195. Device.GPU, block_size, num_gpu_blocks)
  196. self.cpu_allocator = UncachedBlockAllocator(
  197. Device.CPU, block_size, num_cpu_blocks)
  198. # Mapping: seq_id -> BlockTable.
  199. self.block_tables: Dict[int, BlockTable] = {}
  200. def can_allocate(self, seq_group: SequenceGroup) -> AllocStatus:
  201. # FIXME: Here we assume that all sequences in the group share
  202. # the same prompt. This may not be true for preempted sequences.
  203. seq = seq_group.get_seqs(status=SequenceStatus.WAITING)[0]
  204. num_required_blocks = len(seq.logical_token_blocks)
  205. if self.block_sliding_window is not None:
  206. num_required_blocks = min(num_required_blocks,
  207. self.block_sliding_window)
  208. num_free_gpu_blocks = self.gpu_allocator.get_num_free_blocks()
  209. # Use watermark to avoid frequent cache eviction.
  210. if (self.num_total_gpu_blocks - num_required_blocks <
  211. self.watermark_blocks):
  212. return AllocStatus.NEVER
  213. if num_free_gpu_blocks - num_required_blocks >= self.watermark_blocks:
  214. return AllocStatus.OK
  215. else:
  216. return AllocStatus.LATER
  217. def allocate(self, seq_group: SequenceGroup) -> None:
  218. # NOTE: Here we assume that all sequences in the group have the same
  219. # prompt.
  220. seq = seq_group.get_seqs(status=SequenceStatus.WAITING)[0]
  221. # Allocate new physical token blocks that will store the prompt tokens.
  222. num_prompt_blocks = len(seq.logical_token_blocks)
  223. block_table: BlockTable = []
  224. for logical_idx in range(num_prompt_blocks):
  225. if (self.block_sliding_window is not None
  226. and logical_idx >= self.block_sliding_window):
  227. block = block_table[logical_idx % self.block_sliding_window]
  228. # Set the reference counts of the token blocks.
  229. block.ref_count = seq_group.num_seqs()
  230. elif self.enable_caching:
  231. block = self.gpu_allocator.allocate(
  232. seq.hash_of_block(logical_idx),
  233. seq.num_hashed_tokens_of_block(logical_idx))
  234. else:
  235. block = self.gpu_allocator.allocate()
  236. # Set the reference counts of the token blocks.
  237. block.ref_count = seq_group.num_seqs()
  238. block_table.append(block)
  239. # Assign the block table for each sequence.
  240. for seq in seq_group.get_seqs(status=SequenceStatus.WAITING):
  241. self.block_tables[seq.seq_id] = block_table.copy()
  242. def can_append_slots(self,
  243. seq_group: SequenceGroup,
  244. num_lookahead_slots: int = 0) -> bool:
  245. assert (num_lookahead_slots == 0
  246. ), "lookahead allocation not supported in BlockSpaceManagerV1"
  247. # Simple heuristic: If there is at least one free block
  248. # for each sequence, we can append.
  249. num_free_gpu_blocks = self.gpu_allocator.get_num_free_blocks()
  250. num_seqs = seq_group.num_seqs(status=SequenceStatus.RUNNING)
  251. return num_seqs <= num_free_gpu_blocks
  252. def _promote_last_block(
  253. self,
  254. seq: Sequence,
  255. last_block: PhysicalTokenBlock,
  256. ) -> PhysicalTokenBlock:
  257. assert self.enable_caching
  258. # Compute a new hash for the block so that it can be shared by other
  259. # Sequences
  260. new_hash = seq.hash_of_block(len(seq.logical_token_blocks) - 1)
  261. # if new_hash is already in the cached table, then free last_block
  262. # and return the cached version
  263. if self.gpu_allocator.contains_block(new_hash):
  264. self.gpu_allocator.free(last_block)
  265. return self.gpu_allocator.allocate(new_hash)
  266. else:
  267. self.gpu_allocator.update_hash(new_hash, last_block)
  268. return last_block
  269. def _is_last_block_full(
  270. self,
  271. seq: Sequence,
  272. ) -> bool:
  273. token_ids_len = seq.data.get_len()
  274. return token_ids_len > 0 and token_ids_len % seq.block_size == 0
  275. def _maybe_promote_last_block(
  276. self,
  277. seq: Sequence,
  278. last_block: PhysicalTokenBlock,
  279. ) -> PhysicalTokenBlock:
  280. if self._is_last_block_full(seq):
  281. return self._promote_last_block(seq, last_block)
  282. else:
  283. return last_block
  284. def _allocate_last_physical_block(
  285. self,
  286. seq: Sequence,
  287. ) -> PhysicalTokenBlock:
  288. # Called before a new block is appended.
  289. # This is in charge of allocating a new physical block (to be appended).
  290. # None if the last block is not full. Otherwise, we set it to the
  291. # content hash.
  292. if not self.enable_caching:
  293. return self.gpu_allocator.allocate()
  294. block_hash: Optional[int] = None
  295. if (self._is_last_block_full(seq)):
  296. block_hash = seq.hash_of_block(len(seq.logical_token_blocks) - 1)
  297. num_hashed_tokens = seq.num_hashed_tokens_of_block(
  298. len(seq.logical_token_blocks) - 1)
  299. # num_hashed_tokens is used to compute future hashes
  300. # (e.g. in the hashing function, it is used to ask the sequence for
  301. # prefix tokens)
  302. new_block = self.gpu_allocator.allocate(block_hash, num_hashed_tokens)
  303. # If the block has is None, then the block is not full.
  304. # If the block is not full, then we expect it to have a refcount of 1.
  305. if block_hash is None:
  306. assert new_block.ref_count == 1
  307. return new_block
  308. def append_slots(
  309. self,
  310. seq: Sequence,
  311. num_lookahead_slots: int = 0,
  312. ) -> Dict[int, List[int]]:
  313. """Allocate a physical slot for a new token."""
  314. logical_blocks = seq.logical_token_blocks
  315. block_table = self.block_tables[seq.seq_id]
  316. # If we need to allocate a new physical block
  317. if len(block_table) < len(logical_blocks):
  318. # Currently this code only supports adding one physical block
  319. assert len(block_table) == len(logical_blocks) - 1
  320. if (self.block_sliding_window
  321. and len(block_table) >= self.block_sliding_window):
  322. # reuse a block
  323. block_table.append(block_table[len(block_table) %
  324. self.block_sliding_window])
  325. else:
  326. # The sequence has a new logical block.
  327. # Allocate a new physical block.
  328. new_block = self._allocate_last_physical_block(seq)
  329. block_table.append(new_block)
  330. return {}
  331. # We want to append the token to the last physical block.
  332. last_block = block_table[-1]
  333. assert last_block.device == Device.GPU
  334. if last_block.ref_count == 1:
  335. # Not shared with other sequences. Appendable.
  336. if self.enable_caching:
  337. # If the last block is now complete, we may reuse an old block
  338. # to save memory.
  339. maybe_new_block = self._maybe_promote_last_block(
  340. seq, last_block)
  341. block_table[-1] = maybe_new_block
  342. return {}
  343. else:
  344. # The last block is shared with other sequences.
  345. # Copy on Write: Allocate a new block and copy the tokens.
  346. new_block = self._allocate_last_physical_block(seq)
  347. block_table[-1] = new_block
  348. self.gpu_allocator.free(last_block)
  349. return {last_block.block_number: [new_block.block_number]}
  350. def fork(self, parent_seq: Sequence, child_seq: Sequence) -> None:
  351. # NOTE: fork does not allocate a new physical block.
  352. # Thus, it is always safe from OOM.
  353. src_block_table = self.block_tables[parent_seq.seq_id]
  354. self.block_tables[child_seq.seq_id] = src_block_table.copy()
  355. # When using a sliding window, blocks will be eventually reused.
  356. # In this case the block tables will contain repeated blocks.
  357. # When forking, we must make sure that each block's `ref_count`
  358. # is only incremented by one, so we deduplicate them by wrapping
  359. # them in a set.
  360. for block in set(src_block_table):
  361. block.ref_count += 1
  362. def _get_physical_blocks(
  363. self, seq_group: SequenceGroup) -> List[PhysicalTokenBlock]:
  364. # NOTE: Here, we assume that the physical blocks are only shared by
  365. # the sequences in the same group.
  366. blocks: Set[PhysicalTokenBlock] = set()
  367. for seq in seq_group.get_seqs():
  368. if seq.is_finished():
  369. continue
  370. blocks.update(self.block_tables[seq.seq_id])
  371. return list(blocks)
  372. def can_swap_in(self,
  373. seq_group: SequenceGroup,
  374. num_lookahead_slots: int = 0) -> bool:
  375. assert (num_lookahead_slots == 0
  376. ), "BlockSpaceManagerV1 does not support lookahead allocation"
  377. blocks = self._get_physical_blocks(seq_group)
  378. num_swapped_seqs = seq_group.num_seqs(status=SequenceStatus.SWAPPED)
  379. num_free_blocks = self.gpu_allocator.get_num_free_blocks()
  380. # NOTE: Conservatively, we assume that every sequence will allocate
  381. # at least one free block right after the swap-in.
  382. # NOTE: This should match the logic in can_append_slot().
  383. num_required_blocks = len(blocks) + num_swapped_seqs
  384. return num_free_blocks - num_required_blocks >= self.watermark_blocks
  385. def swap_in(self,
  386. seq_group: SequenceGroup,
  387. num_lookahead_slots: int = 0) -> Dict[int, int]:
  388. assert (num_lookahead_slots == 0
  389. ), "BlockSpaceManagerV1 does not support lookahead allocation"
  390. # CPU block -> GPU block.
  391. mapping: Dict[PhysicalTokenBlock, PhysicalTokenBlock] = {}
  392. for seq in seq_group.get_seqs(status=SequenceStatus.SWAPPED):
  393. new_block_table: BlockTable = []
  394. block_table = self.block_tables[seq.seq_id]
  395. for cpu_block in block_table:
  396. if cpu_block in mapping:
  397. gpu_block = mapping[cpu_block]
  398. gpu_block.ref_count += 1
  399. else:
  400. gpu_block = self.gpu_allocator.allocate(
  401. cpu_block.block_hash, cpu_block.num_hashed_tokens)
  402. mapping[cpu_block] = gpu_block
  403. new_block_table.append(gpu_block)
  404. # Free the CPU block swapped in to GPU.
  405. self.cpu_allocator.free(cpu_block)
  406. self.block_tables[seq.seq_id] = new_block_table
  407. block_number_mapping = {
  408. cpu_block.block_number: gpu_block.block_number
  409. for cpu_block, gpu_block in mapping.items()
  410. }
  411. return block_number_mapping
  412. def can_swap_out(self, seq_group: SequenceGroup) -> bool:
  413. blocks = self._get_physical_blocks(seq_group)
  414. return len(blocks) <= self.cpu_allocator.get_num_free_blocks()
  415. def swap_out(self, seq_group: SequenceGroup) -> Dict[int, int]:
  416. # GPU block -> CPU block.
  417. mapping: Dict[PhysicalTokenBlock, PhysicalTokenBlock] = {}
  418. for seq in seq_group.get_seqs(status=SequenceStatus.RUNNING):
  419. new_block_table: BlockTable = []
  420. block_table = self.block_tables[seq.seq_id]
  421. for gpu_block in block_table:
  422. if gpu_block in mapping:
  423. cpu_block = mapping[gpu_block]
  424. cpu_block.ref_count += 1
  425. else:
  426. cpu_block = self.cpu_allocator.allocate(
  427. gpu_block.block_hash, gpu_block.num_hashed_tokens)
  428. mapping[gpu_block] = cpu_block
  429. new_block_table.append(cpu_block)
  430. # Free the GPU block swapped out to CPU.
  431. self.gpu_allocator.free(gpu_block)
  432. self.block_tables[seq.seq_id] = new_block_table
  433. block_number_mapping = {
  434. gpu_block.block_number: cpu_block.block_number
  435. for gpu_block, cpu_block in mapping.items()
  436. }
  437. return block_number_mapping
  438. def _free_block_table(self, block_table: BlockTable) -> None:
  439. # when using a sliding window, each seq will only use up
  440. # to `self.block_sliding_window` blocks. When freeing
  441. # the block table, we must make sure to not free blocks more
  442. # than once. If no sliding window is used, there is no block
  443. # reuse in the block table, so we must free all blocks.
  444. blocks_to_free = (block_table[-self.block_sliding_window:]
  445. if self.block_sliding_window is not None else
  446. block_table)
  447. for block in set(blocks_to_free):
  448. if block.device == Device.GPU:
  449. self.gpu_allocator.free(block)
  450. else:
  451. self.cpu_allocator.free(block)
  452. def free(self, seq: Sequence) -> None:
  453. if seq.seq_id not in self.block_tables:
  454. # Already freed or haven't been scheduled yet.
  455. return
  456. block_table = self.block_tables[seq.seq_id]
  457. self._free_block_table(block_table)
  458. del self.block_tables[seq.seq_id]
  459. def reset(self) -> None:
  460. for block_table in self.block_tables.values():
  461. self._free_block_table(block_table)
  462. self.block_tables.clear()
  463. def get_block_table(self, seq: Sequence) -> List[int]:
  464. block_table = self.block_tables[seq.seq_id]
  465. return [block.block_number for block in block_table]
  466. def get_num_free_gpu_blocks(self) -> int:
  467. return self.gpu_allocator.get_num_free_blocks()
  468. def get_num_free_cpu_blocks(self) -> int:
  469. return self.cpu_allocator.get_num_free_blocks()
  470. def access_all_blocks_in_seq(
  471. self,
  472. seq: Sequence,
  473. access_time: float,
  474. ) -> None:
  475. if self.enable_caching:
  476. # Update the last accessed time of all the blocks accessed
  477. # in this step.
  478. block_table = self.block_tables[seq.seq_id]
  479. for block in block_table:
  480. block.last_accessed = access_time
  481. def compute_full_blocks_in_seq(self, seq: Sequence):
  482. if seq.seq_id not in self.block_tables:
  483. return
  484. max_full_block = seq.get_len() // self.block_size - 1
  485. block_table = self.block_tables[seq.seq_id]
  486. if max_full_block == -1:
  487. return
  488. for i in reversed(range(max_full_block)):
  489. if block_table[i].computed:
  490. break
  491. block_table[i].computed = True
  492. def get_all_computed_blocks(self, seq: Sequence) -> List[int]:
  493. if seq.seq_id not in self.block_tables:
  494. return []
  495. block_table = self.block_tables[seq.seq_id]
  496. # NOTE We exclude the last block to avoid the case where the entire
  497. # prompt is cached. This would cause erroneous behavior in model
  498. # runner.
  499. return [
  500. b.block_number
  501. for b in takewhile(lambda b: b.computed, block_table[:-1])
  502. ]
  503. def get_common_computed_block_ids(self, seqs: List[Sequence]) -> List[int]:
  504. """Return the block ids that are common for a given sequence group.
  505. Used in prefill (can skip prefill of some blocks).
  506. """
  507. # Can return non-empty result only with prefix caching enabled.
  508. if not self.enable_caching:
  509. return []
  510. ids_list = [self.get_all_computed_blocks(seq) for seq in seqs]
  511. return commonprefix([ids for ids in ids_list if ids != []])
  512. def mark_blocks_as_computed(self, seq_group: SequenceGroup):
  513. if self.enable_caching:
  514. for seq in seq_group.seqs_dict.values():
  515. self.compute_full_blocks_in_seq(seq)