Skip to content
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

Fix interruptGenerate causing the engine to get stuck when using synchronous completion calls #596

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mitchellw
Copy link

Hey, first time contributor to Web-LLM, so let me know if there's anything else you need from me. Just fixing a bug that was causing us issues!

I noticed that asyncGenerate is not private, so I didn't want to necessarily change other parts beyond what I had tested to work, but I think we could/should probably get rid of the acquisition of the lock and reseting of the interruptSignal in there too.

Issue / Motivation

Previously if you are using synchronous completion or chatCompletion calls, then when you call interruptGenerate, the engine will be forever stuck. This was not the case when using streaming (asyncGenerate) as far as I can tell.

Fix

Reset the interruptSignal after acquiring the lock in completion and chatCompletion.

It was doing this in effect within asyncGenerate, and kind of in generate, but the completion code would never call generate if interruptGenerate was ever called in the past because it would be stuck true.

Also do it in a way that allows users to still call interruptGenerate during a context switch of acquiring the model lock, which I think was a potential race condition.

…chatCompletion. It was doing this in effect within asyncGenerate, and kind of in generate, but the completion code would never call generate if interruptGenerate was ever called in the past because it would be stuck true. Also do it in a way that allows users to still call interruptGenerate during a context switch of acquiring the model lock.
@mitchellw mitchellw changed the title Fix interruptGenerate to cause the engine to get stuck when using synchronous completion calls Fix interruptGenerate causing the engine to get stuck when using synchronous completion calls Oct 8, 2024
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.

1 participant