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 grammar logits processor #268

Merged
merged 2 commits into from
Feb 27, 2024
Merged

Conversation

SwadicalRag
Copy link
Contributor

@SwadicalRag SwadicalRag commented Feb 23, 2024

This pull request addresses:

  1. The function signature of GrammarLogitsProcessor does not match with the current implementation of _apply_logits_processors in sampler.py
  2. The use of Ray to filter logits results in a significant slowdown on my local machine. Given performance is the priority, and I haven't seen any drawbacks to doing so, I have removed the grammar module's dependency on Ray.

@AlpinDale AlpinDale self-assigned this Feb 23, 2024
@AlpinDale
Copy link
Member

Thanks for the PR! The RayRemote logits processor was added for multi-gpu scenarios where Ray is involved. Have you tested the PR with Ray enabled?

@SwadicalRag
Copy link
Contributor Author

SwadicalRag commented Feb 23, 2024

Yes I have. I run a 2x 3090 system, and the performance was halved or worse with ray. That being said, I was hammering the server exclusively with grammar constrained requests.

Without grammar on a 7b model, I get well over 100 Tok/s. With grammar and ray, only 20-30 Tok/s. With ray removed 60 Tok/s.

The overall bottleneck is the latency in waiting for lark to return valid tokens. I suspect there are latency issues with ray doing multiple copies of tensors/objects and synchronizing across threads too.

@AlpinDale AlpinDale merged commit 0527131 into PygmalionAI:main Feb 27, 2024
2 checks passed
@SwadicalRag SwadicalRag deleted the logits-patch-1 branch February 28, 2024 23:33
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