Enforce soft_probe_prompt_cap in GCGCached probe#1665
Open
precognitivem0nk wants to merge 2 commits intoNVIDIA:mainfrom
Open
Enforce soft_probe_prompt_cap in GCGCached probe#1665precognitivem0nk wants to merge 2 commits intoNVIDIA:mainfrom
precognitivem0nk wants to merge 2 commits intoNVIDIA:mainfrom
Conversation
Signed-off-by: precognitivem0nk <rextedgorman@gmail.com>
Contributor
|
DCO Assistant Lite bot All contributors have signed the DCO ✍️ ✅ |
Author
|
I have read the DCO Document and I hereby sign the DCO |
leondz
reviewed
Apr 7, 2026
Collaborator
leondz
left a comment
There was a problem hiding this comment.
minor tweaks, but generally good, thanks
Comment on lines
+9
to
+16
| _config.run.soft_probe_prompt_cap = 10 | ||
| try: | ||
| from garak.probes.suffix import GCGCached | ||
|
|
||
| probe = GCGCached() | ||
| assert ( | ||
| len(probe.prompts) <= 10 | ||
| ), f"GCGCached has {len(probe.prompts)} prompts, expected at most 10" |
Collaborator
There was a problem hiding this comment.
the 10 is used in the three places, recommend making it a var
Collaborator
|
Author
|
recheck |
Author
|
I have read the CLA Document and I hereby sign the CLA |
precognitivem0nk
added a commit
to precognitivem0nk/garak
that referenced
this pull request
Apr 21, 2026
Address leondz's review comment on NVIDIA#1665: the literal 10 was duplicated across three places in the test (the cap setter, the length assertion, and the assertion message). Factor it out into a local variable named cap. No behavior change. Signed-off-by: precognitivem0nk <rextedgorman@gmail.com>
Address leondz's review comment on NVIDIA#1665: the literal 10 was duplicated across three places in the test (the cap setter, the length assertion, and the assertion message). Factor it out into a local variable named cap. No behavior change. Signed-off-by: precognitivem0nk <rextedgorman@gmail.com>
570f2b5 to
450ca0d
Compare
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
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.
Fixes #1562
GCGCached builds its full prompt list at class definition time (13 suffixes × 2 base prompts = 26 prompts) and never consults
run.soft_probe_prompt_cap. This means setting a cap has no effect on how many prompts GCGCached issues.This PR adds an
__init__method that callsself._prune_data(self.soft_probe_prompt_cap)aftersuper().__init__(), following the same pattern used byDanInTheWildindan.py. When the cap is set lower than the total prompt count, prompts are randomly sampled down to the cap.Verified locally: with
soft_probe_prompt_cap = 10, GCGCached now produces 10 prompts instead of 26. Added a test intests/probes/test_probes_suffix.pyto confirm the behavior.