Skip to content

bugfix: reduce latent optimisation permutation explosion#1181

Merged
jmartin-tech merged 5 commits intoNVIDIA:mainfrom
leondz:update/latentinjection_perms
Apr 29, 2025
Merged

bugfix: reduce latent optimisation permutation explosion#1181
jmartin-tech merged 5 commits intoNVIDIA:mainfrom
leondz:update/latentinjection_perms

Conversation

@leondz
Copy link
Collaborator

@leondz leondz commented Apr 25, 2025

requires #1152
resolves #1161

create snippets by sampling & using a set to avoid dupes, instead of sampling from all perms

Verification

List the steps needed to make sure this thing works

  • garak -m test -p latentinjection.LatentWhoisSnippet,latentinjection.LatentWhoisSnippetFull
  • garak -m test -p latentinjection.LatentInjectionFactSnippetEiffel,latentinjection.LatentInjectionFactSnippetLegal

@leondz leondz changed the title Update/latentinjection perms bugfix: reduce latentoptimisation permutation explosion Apr 25, 2025
@leondz leondz marked this pull request as ready for review April 25, 2025 11:36
@leondz leondz requested a review from erickgalinkin April 25, 2025 11:37
@leondz leondz mentioned this pull request Apr 26, 2025
4 tasks
@jmartin-tech jmartin-tech force-pushed the update/latentinjection_perms branch from 892ef0b to e7b2fcf Compare April 28, 2025 17:21
Copy link
Collaborator

@jmartin-tech jmartin-tech left a comment

Choose a reason for hiding this comment

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

Testing with single generation reports expected counts:

latentinjection.LatentInjectionFactSnippetEiffel                            base.TriggerListDetector: PASS  ok on  256/ 256
latentinjection.LatentInjectionFactSnippetLegal                             base.TriggerListDetector: PASS  ok on  256/ 256
latentinjection.LatentWhoisSnippet                                          base.TriggerListDetector: PASS  ok on  256/ 256
latentinjection.LatentWhoisSnippetFull                                      base.TriggerListDetector: PASS  ok on  640/ 640

self.contexts = (
set()
) # goal: a set of n whois reports, with an injection marker in one of them
max_context_count = min(ceil(sqrt(self.soft_probe_prompt_cap)), 100)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems odd still, what does soft_probe_prompt_cap have to do with number of valid contexts?

Not a blocker, just seems like an odd hidden side-effect for soft_probe_prompt_cap.

@jmartin-tech
Copy link
Collaborator

Noted impact for setting soft_probe_prompt_cap > 16k

latentinjection.LatentWhoisSnippet                                          base.TriggerListDetector: PASS  ok on 4000/4000
latentinjection.LatentWhoisSnippetFull                                      base.TriggerListDetector: PASS  ok on 4000/4000

@jmartin-tech
Copy link
Collaborator

Testing showed some concerns in local model exec, I am not sure this is due to the change here however:

probes.latentinjection.LatentWhois:   7%|███▊                                                 | 12/168 [00:08<01:29,  1.75it/s]This is a friendly reminder - the current text generation call will exceed the model's predefined maximum length (1024). Depending on the model, you may observe exceptions, performance degradation, or nothing at all.
/pytorch/aten/src/ATen/native/cuda/Indexing.cu:1369: indexSelectSmallIndex: block: [3,0,0], thread: [96,0,0] Assertion `srcIndex < srcSelectDimSize` failed.
/pytorch/aten/src/ATen/native/cuda/Indexing.cu:1369: indexSelectSmallIndex: block: [3,0,0], thread: [97,0,0] Assertion `srcIndex < srcSelectDimSize` failed.

Further investigation in progress.

@jmartin-tech
Copy link
Collaborator

Issue is confirmed to exist in released v0.10.3.1 when targeting gpt2:

python -m garak -m huggingface -n gpt2 -p latentinjection.LatentWhois -g 1
garak LLM vulnerability scanner v0.10.3.1 ( https://github.com/NVIDIA/garak ) at 2025-04-29T16:28:14.400861
📜 logging to /home/testing/.local/share/garak/garak.log
🦜 loading generator: Hugging Face 🤗 pipeline: gpt2
Device set to use cuda
📜 reporting to /home/testing/.local/share/garak/garak_runs/garak.a4d3d7a7-8c36-4b16-8247-4f19ac32a4d0.report.jsonl
🕵️  queue of probes: latentinjection.LatentWhois
probes.latentinjection.LatentWhois:  14%|███████▊                                               | 4/28 [00:00<00:04,  4.82it/s]This is a friendly reminder - the current text generation call will exceed the model's predefined maximum length (1024). Depending on the model, you may observe exceptions, performance degradation, or nothing at all.
/pytorch/aten/src/ATen/native/cuda/Indexing.cu:1369: indexSelectSmallIndex: block: [3,0,0], thread: [96,0,0] Assertion `srcIndex < srcSelectDimSize` failed.
/pytorch/aten/src/ATen/native/cuda/Indexing.cu:1369: indexSelectSmallIndex: block: [3,0,0], thread: [97,0,0] Assertion `srcIndex < srcSelectDimSize` failed.

Just noting findings, this will not block merge.

@jmartin-tech jmartin-tech changed the title bugfix: reduce latentoptimisation permutation explosion bugfix: reduce latent optimisation permutation explosion Apr 29, 2025
@jmartin-tech jmartin-tech merged commit 316ded9 into NVIDIA:main Apr 29, 2025
9 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Apr 29, 2025
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.

bug: latentinjection.FactSnippetMixin can give dupe environments

2 participants