-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Improve default llm retry logic to be more optimized #1701
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… concurrent_requests
dworthen
approved these changes
Feb 13, 2025
AlonsoGuevara
approved these changes
Feb 13, 2025
opensourcemukul
pushed a commit
to opensourcemukul/graphrag
that referenced
this pull request
Sep 13, 2025
Brandsma
pushed a commit
to ThalamusLabs/MMGraphRAG
that referenced
this pull request
Nov 6, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR makes changes to provide a more optimized retry logic for graphrag by default. It also simplifies the configuration by removing config variables that do not provide much value.
Proposed Changes
There are two significant behavioral changes to take note of (can be disabled if users don't wish to use it)
max_retriesin the openai librarymax_retriesin each step of the indexing pipeline based on the input dataset sizeAs default behavior, these changes will cause graphrag's retry-logic to utilize the response back from OpenAI to determine how long to wait until it retries an LLM call (i.e. server-side retry logic), as opposed to retry logic that is based on the client-side only. This is done by calculating optimal values for the
max_retriesparameter when instantiating an openai client. Note that the openai library now has support for theretry-afterheader (providing a more accurate estimate of time to wait between LLM calls)...so if graphrag bases its' retry-logic entirely on the openai library, this approach should allow us to achieve full quota utilization with fewer configuration variables needed by graphrag.For users that don't want to use the dynamic retry logic, it can be disabled and other retry-logic is exposed in the configuration file (
tokens_per_minuteandrequests_per_minute).This dynamic retry logic was tested on two separate AOAI models, with 10K TPM and 400K TPM, to evaluate effectiveness. I also tested across different dataset sizes as well and did not any experience errors due to graphrag reaching the max number of retries for an LLM call.
Checklist
Additional Notes
[Add any additional notes or context that may be helpful for the reviewer(s).]