Fix weight tying (#51665)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
Harry Mellor
2026-08-20 10:31:55 +00:00
committed by GitHub
parent 6e85feb1b7
commit f0c14b4f77
70 changed files with 526 additions and 238 deletions
+13
View File
@@ -95,10 +95,23 @@ def with_retry(
log_msg: str,
max_retries: int = 2,
retry_delay: int = 2,
fatal_errors: tuple[type[Exception], ...] = (),
) -> _R:
"""Call `func`, retrying transient failures.
Args:
func: The call to make.
log_msg: Prefix for the message logged when a call fails.
max_retries: How many times to call `func` before giving up.
retry_delay: Seconds to wait after the first failure, doubled each time.
fatal_errors: Exceptions that are a definitive answer rather than a
transient failure. These are raised immediately, without logging.
"""
for attempt in range(max_retries):
try:
return func()
except fatal_errors:
raise
except Exception as e:
if attempt == max_retries - 1:
logger.error("%s: %s", log_msg, e)