(
self,
entry: "SequenceDiskCache.Entry",
)
| 12425 | ) |
| 12426 | |
| 12427 | def _read_entry_payload( |
| 12428 | self, |
| 12429 | entry: "SequenceDiskCache.Entry", |
| 12430 | ) -> "SequenceDiskCache.Payload": |
| 12431 | with self._safe_open(entry.path) as tensors: |
| 12432 | tokens = [ |
| 12433 | int(token) |
| 12434 | for token in tensors.get_tensor(self.TENSOR_TOKENS).tolist() |
| 12435 | ] |
| 12436 | state_bytes = np.ascontiguousarray( |
| 12437 | tensors.get_tensor(self.TENSOR_STATE), |
| 12438 | dtype=np.uint8, |
| 12439 | ).copy() |
| 12440 | prompt_logits = ( |
| 12441 | tensors.get_tensor(self.TENSOR_PROMPT_LOGITS) |
| 12442 | if entry.has_prompt_logits |
| 12443 | and self.TENSOR_PROMPT_LOGITS in tensors.keys() |
| 12444 | else None |
| 12445 | ) |
| 12446 | return SequenceDiskCache.Payload( |
| 12447 | tokens=tokens, |
| 12448 | state_bytes=state_bytes, |
| 12449 | prompt_logits=prompt_logits, |
| 12450 | ) |
| 12451 | |
| 12452 | def _write_entry( |
| 12453 | self, |
no test coverage detected