-
Notifications
You must be signed in to change notification settings - Fork 563
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
End-to-end support for concurrent async models #2066
Open
philandstuff
wants to merge
7
commits into
main
Choose a base branch
from
support-concurrent-predictions-in-child
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Commits on Nov 25, 2024
-
cog build: validate python version is new enough to support concurrency
We require python >=3.11 to support asyncio.TaskGroup
Configuration menu - View commit details
-
Copy full SHA for b89abad - Browse repository at this point
Copy the full SHA b89abadView commit details
Commits on Nov 26, 2024
-
End-to-end support for concurrent async models
This builds on the work in #2057 and wires it up end-to-end. We can now support async models with a max concurrency configured, and submit multiple predictions concurrently to them. We only support python 3.11 for async models; this is so that we can use asyncio.TaskGroup to keep track of multiple predictions in flight and ensure they all complete when shutting down. The cog http server was already async, but at one point it called wait() on a concurrent.futures.Future() which blocked the event loop and therefore prevented concurrent prediction requests (when not using prefer-async, which is how the tests run). I have updated this code to wait on asyncio.wrap_future(fut) instead which does not block the event loop. As part of this I have updated the training endpoints to also be asynchronous. We now have three places in the code which keep track of how many predictions are in flight: PredictionRunner, Worker and _ChildWorker all do their own bookkeeping. I'm not sure this is the best design but it works. The code is now an uneasy mix of threaded and asyncio code. This is evident in the usage of threading.Lock, which wouldn't be needed if we were 100% async (and I'm not sure if it's actually needed currently; I just added it to be safe).
Configuration menu - View commit details
-
Copy full SHA for 572fb3f - Browse repository at this point
Copy the full SHA 572fb3fView commit details -
Fix typing of CogConcurrencyConfig
The use of `Optional` allowed `None` as a valid value. This has been changed to use `NotRequired` which allows the field to be omitted but must always be an integer when present.
Configuration menu - View commit details
-
Copy full SHA for 8460d15 - Browse repository at this point
Copy the full SHA 8460d15View commit details -
Configuration menu - View commit details
-
Copy full SHA for d19b3b7 - Browse repository at this point
Copy the full SHA d19b3b7View commit details -
Re-word internal use of id to tag
Inside the worker we track predictions by tag not exterenal predicition IDs, this commit updates the variable names to reflect this.
Configuration menu - View commit details
-
Copy full SHA for 41adaa9 - Browse repository at this point
Copy the full SHA 41adaa9View commit details -
the `for tag in done_tags:` was resetting the existing `tag` variable and breaking things.
Configuration menu - View commit details
-
Copy full SHA for 897e28e - Browse repository at this point
Copy the full SHA 897e28eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 5f25c22 - Browse repository at this point
Copy the full SHA 5f25c22View commit details
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.