Skip to content

Commit 99126dc

Browse files
Merge pull request #29 from openai/fix-concurrency-reset-bug
Fix parallel recovery cap resets and reduce duplicate warnings
2 parents 978e40a + 67c7119 commit 99126dc

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

src/gabriel/utils/openai_utils.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4481,9 +4481,10 @@ def _log_rate_limit_once(detail: Optional[str] = None) -> None:
44814481
msg = (
44824482
"Encountered first rate limit error. Future rate limit errors will be silenced and tracked in periodic updates."
44834483
)
4484-
logger.warning(msg)
44854484
if message_verbose:
44864485
print(msg)
4486+
else:
4487+
logger.warning(msg)
44874488
first_rate_limit_logged = True
44884489
else:
44894490
if detail:
@@ -4497,9 +4498,10 @@ def _log_connection_once(detail: Optional[str] = None) -> None:
44974498
msg = (
44984499
"Encountered first connection error. Future connection errors will be silenced and tracked in periodic updates."
44994500
)
4500-
logger.warning(msg)
45014501
if message_verbose:
45024502
print(msg)
4503+
else:
4504+
logger.warning(msg)
45034505
first_connection_logged = True
45044506
else:
45054507
if detail:
@@ -4518,9 +4520,10 @@ def _halt_ramp_up(reason: str) -> None:
45184520
if concurrency_cap > ramp_cap:
45194521
concurrency_cap = ramp_cap
45204522
msg = f"[parallelization] Halting ramp-up at {ramp_cap} due to {reason}."
4521-
logger.warning(msg)
45224523
if message_verbose:
45234524
print(msg)
4525+
else:
4526+
logger.warning(msg)
45244527

45254528
def _record_timeout_event(now: Optional[float] = None) -> None:
45264529
ts = now if now is not None else time.time()
@@ -4961,7 +4964,6 @@ def maybe_adjust_concurrency() -> None:
49614964
f"{int(round(error_window))}s (rate-limit={recent_rate_limit_errors}, "
49624965
f"connection={recent_connection_errors})."
49634966
)
4964-
logger.warning(reason)
49654967
_halt_ramp_up("error recovery")
49664968
emit_parallelization_status(reason, force=True)
49674969
rate_limit_errors_since_adjust = 0
@@ -4986,7 +4988,7 @@ def maybe_adjust_concurrency() -> None:
49864988
and (now - last_concurrency_scale_up) >= error_window
49874989
):
49884990
growth_headroom_limit = max(1, int(math.floor(ceiling_cap * 0.9)))
4989-
success_threshold = max(60, int(math.ceil(concurrency_cap * 2.5)))
4991+
success_threshold = max(60, int(math.ceil(concurrency_cap * 1.5)))
49904992
if (
49914993
concurrency_cap < growth_headroom_limit
49924994
and successes_since_adjust >= success_threshold
@@ -5427,7 +5429,6 @@ async def _handle_rate_limit_error(error_text: str) -> None:
54275429
dedup_key=("cap-adjustment", type(e).__name__, str(e)),
54285430
)
54295431
logger.debug("Throughput tuning failed; retaining existing cap.", exc_info=True)
5430-
concurrency_cap = new_cap
54315432
if resps and all((isinstance(r, str) and not r.strip()) for r in resps):
54325433
if call_timeout is not None:
54335434
elapsed = time.time() - start

0 commit comments

Comments
 (0)