Skip to content

Commit

Permalink
retry tokenizer backoff
Browse files Browse the repository at this point in the history
  • Loading branch information
dlwh committed Jan 7, 2025
1 parent 3747d99 commit 6e2a924
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/levanter/store/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -1237,10 +1237,22 @@ async def _copy_one_array(dest_array: JaggedArrayStore, source_array: JaggedArra
source_offsets = source_array.offsets[1 : source_num_rows + 1][ts.d[:].translate_to[0]]
source_offsets = _virtual_offset(source_offsets, data_offset)

async with ts.Transaction() as txn:
dest_offsets = dest_array.offsets
out_end = row_offset + 1 + source_num_rows
offset_future = dest_offsets.with_transaction(txn)[row_offset + 1 : out_end].write(source_offsets)
delay = 1
while True:
try:
async with ts.Transaction() as txn:
dest_offsets = dest_array.offsets
out_end = row_offset + 1 + source_num_rows
offset_future = dest_offsets.with_transaction(txn)[row_offset + 1 : out_end].write(
source_offsets
)

break
except ValueError as e:
if "Please reduce your request rate." in str(e):
logger.info("Rate limit exceeded. Retrying.")
await asyncio.sleep(delay)
delay *= 2

futures.append(offset_future)

Expand Down

0 comments on commit 6e2a924

Please sign in to comment.