Skip to content

fix: skip backoff after the final model download attempt - #856

Merged
tbung merged 2 commits into
qdrant:mainfrom
elysiopires:codex/fix-final-download-backoff
Nov 27, 2026
Merged

tbung merged 2 commits into
qdrant:mainfrom
elysiopires:codex/fix-final-download-backoff

Conversation

@elysiopires

Copy link
Copy Markdown
Contributor

When every model download fails, the default three-attempt loop sleeps for 3, 9 and 27 seconds. The final 27-second sleep occurs with zero retries left and only delays the eventual ValueError.

Back off only when another attempt remains. This keeps the same download attempts and fallback behavior, with sleeps of 3 and 9 seconds between the default three attempts. A single failed attempt no longer sleeps before raising.

Fixes #855

Validation:

  • Four new regression cases fail before the fix and pass afterward. They cover one/three attempts, with and without URL fallback, and assert both attempt counts and sleep calls.
  • uv run --no-default-groups --group test pytest tests/test_download_retries.py tests/test_model_management.py tests/test_common.py -q: 15 passed.
  • Ruff passes for the new test file; formatting passes for both changed files.
  • Ruff reports seven existing findings in model_management.py. The unchanged file from HEAD produces the same seven findings, so this PR leaves that cleanup out of scope.
  • Downloads and sleeps are mocked in the regression tests; no model weights or external services are required.

AI assistance: OpenAI Codex generated the change and regression tests. Validation was run locally.

@elysiopires
elysiopires requested a review from joein as a code owner October 29, 2026 18:38
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

download_model now logs and sleeps for a retry only when another attempt remains. New parametrized tests check failed downloads with one or three retries, with and without URL fallback. They verify download and fallback calls, sleep delays, and the final ValueError.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Merge Risk: Minimal · up to 61ebb

Failed model downloads no longer wait after the last attempt, so the final error appears sooner. Retry count, fallback and error behavior stay the same. The change is small, covered by regression tests and easy to revert.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title states the main change: the download retry logic no longer sleeps after the final model download attempt. It matches the raw summary, the PR description, and the objectives, and it follows t…
Description check Passed The description explains the problem: the default three-attempt loop sleeps 27 seconds after the last attempt. It states the fix, which backs off only when another attempt remains. It also lists the v…
Linked Issues check Passed Issue #855 requires ModelManagement.download_model() to sleep only when another retry remains. The whole-PR diff against the merge base changes one line in fastembed/common/model_management.py: th…
Out of Scope Changes check Passed The whole-PR diff against the merge base changes only the retry sleep condition in ModelManagement.download_model. The summary reports that tests/test_model_management.py adds parametrized regress…
Full details: Title check

Explanation

The title states the main change: the download retry logic no longer sleeps after the final model download attempt. It matches the raw summary, the PR description, and the objectives, and it follows the conventional fix: prefix format. The title is 56 characters, which is concise.

Full details: Description check

Explanation

The description explains the problem: the default three-attempt loop sleeps 27 seconds after the last attempt. It states the fix, which backs off only when another attempt remains. It also lists the validation steps and links issue #855. It relates directly to the changeset in model_management.py and the new regression tests.

Full details: Linked Issues check

Explanation

Issue #855 requires ModelManagement.download_model() to sleep only when another retry remains. The whole-PR diff against the merge base changes one line in fastembed/common/model_management.py: the retry branch else: becomes elif retries > 0:. The final failed attempt therefore skips the logging and sleep. The previous assessment verified that the regression test covers retries=1 and retries=3, with and without URL fallback, and expects sleep calls of [] or [3.0, 9.0]. The local_files_only branch is unchanged, so offline behavior and the final ValueError path are preserved. The sleep values and attempt count are not changed by this diff. Limitation: this review read only the one-line hunk and did not re-read the surrounding loop to confirm the decrement order. The PR description names tests/test_download_retries.py, but the head file list does not contain it. The regression tests appear in tests/test_model_management.py per the summary. This naming mismatch does not affect the coding requirement.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff against the merge base changes only the retry sleep condition in ModelManagement.download_model. The summary reports that tests/test_model_management.py adds parametrized regression coverage for the same retry and sleep behavior. Both changes connect directly to Issue #855. No unrelated production or test changes appear. The Ruff findings in model_management.py are reported as pre-existing and are not part of this diff.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ff746534-305b-49b2-8529-f08f07ce8cf6
Commits

Reviewing files that changed from the base of the PR and between 88a68dc and 61ebb72.

Files selected for processing: 1

  • tests/test_model_management.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@tbung
tbung merged commit 12fa1a4 into qdrant:main Nov 27, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Model download sleeps after its final failed attempt

2 participants