Skip to content

Fix incorrect retry count check in LazyLLMDataset.__getitem__ #3845

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 12, 2025

Conversation

IamLihua
Copy link
Contributor

@IamLihua IamLihua commented Apr 11, 2025

PR type

  • Bug Fix
  • New Feature
  • Document Updates
  • More Models or Datasets Support

PR information

Problem

In LazyLLMDataset.__getitem__, the loop variable i is modified inside the retry logic, which can lead to incorrect behavior when checking if the maximum retry attempts (n_try_fetch) have been reached.

For example:

If i = 0, it gets reassigned to idx, but later the condition i == self.n_try_fetch - 1 may incorrectly evaluate because i is no longer the original loop counter.

This could cause the method to either:

  • Fail too early (if idx happens to match n_try_fetch - 1).

  • Fail too late (if i is reassigned to a smaller value).

Solution

Introduce a separate variable n_try to track the actual retry count, ensuring the correct number of attempts is enforced.

This makes the retry logic more robust and predictable.

In LazyLLMDataset.__getitem__, the loop variable i is modified inside the retry logic, which can lead to incorrect behavior when checking if the maximum retry attempts (n_try_fetch) have been reached.
Fix incorrect retry count check in LazyLLMDataset.__getitem__
@Jintao-Huang
Copy link
Collaborator

thanks! ❤️

@Jintao-Huang Jintao-Huang merged commit 0f07783 into modelscope:main Apr 12, 2025
2 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.

2 participants