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

Enable parallel OpenAI calls #645

Merged
merged 5 commits into from
May 2, 2024
Merged

Conversation

jmartin-tech
Copy link
Collaborator

@jmartin-tech jmartin-tech commented May 1, 2024

Fix #493

Conceptually since rest generator client objects should not retains state, this provides a pattern where rest generator client objects can be instantiated only when required and avoiding the need to pickle the client object when passing a generator to another process.

  • refactor for just in time rest client for OpenAI
  • ensure read and write of _config.transient.reportfile are in parent process only
  • consolidate multiprocessing execution in probes/base.py

Verification testing preformed with:

python -m garak p dan.DanInTheWild -m openai -n gpt-4-turbo-preview -g 1 --parallel_attempts 20

Additional testing may be appropriate to validate changes to base and gcg probe flows are not impacted.

Signed-off-by: Jeffrey Martin <jemartin@nvidia.com>
* ensure read and write of `reportfile` are in parent only
* consolidate multiprocessing execution in `probes/base.py`

Signed-off-by: Jeffrey Martin <jemartin@nvidia.com>
Signed-off-by: Jeffrey Martin <jemartin@nvidia.com>
Copy link
Collaborator

@erickgalinkin erickgalinkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@erickgalinkin
Copy link
Collaborator

I did not test, only performed code review. But nothing here seems to remove or alter functionality in a breaking way.

Signed-off-by: Jeffrey Martin <jemartin@nvidia.com>
@jmartin-tech
Copy link
Collaborator Author

Extended refactor to provide example of using a base class that can share OpenAI compatible generation.

Copy link
Owner

@leondz leondz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm - would just appreciate one doc update

garak/generators/openai.py Outdated Show resolved Hide resolved
garak/probes/base.py Show resolved Hide resolved
garak/probes/dan.py Show resolved Hide resolved
garak/probes/gcg.py Show resolved Hide resolved
Signed-off-by: Jeffrey Martin <jemartin@nvidia.com>
@leondz leondz merged commit 3a9a305 into leondz:main May 2, 2024
4 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators May 2, 2024
@jmartin-tech jmartin-tech deleted the fix/parallel-openai branch May 2, 2024 18:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

openai 1.x generator doesn't work nice with parallel_attempts
3 participants