MAINT: Fold GCG into pyrit/executor/promptgen, remove auxiliary_attacks#2197
Open
romanlutz wants to merge 4 commits into
Open
MAINT: Fold GCG into pyrit/executor/promptgen, remove auxiliary_attacks#2197romanlutz wants to merge 4 commits into
romanlutz wants to merge 4 commits into
Conversation
GCGGenerator is already a PromptGeneratorStrategy (a peer of fuzzer and anecdoctor), so GCG belongs in the standard executor/promptgen tree rather than in its own quarantined auxiliary_attacks subtree. - Relocate the GCG package: pyrit/auxiliary_attacks/gcg/ -> pyrit/executor/promptgen/gcg/, rewriting all internal imports. - Delete the auxiliary_attacks package and its import-time ExperimentalWarning. - Keep torch strictly optional: the moved package retains its lazy PEP 562 __init__ and is deliberately not re-exported from promptgen/__init__.py, so base (no-torch) installs still import pyrit.executor.promptgen cleanly. - Move and retarget tests to tests/**/executor/promptgen/gcg/; drop the obsolete experimental-warning test; rename the notebook test to test_notebooks_gcg.py. - Move docs to doc/code/executor/gcg/ (0_gcg + 1_gcg_azure_ml), update myst.yml nav to nest them under executor, and drop the generated auxiliary_attacks API page (GCG folds into pyrit_executor_promptgen like fuzzer). - Update the AML entry point to python -m pyrit.executor.promptgen.gcg.experiments.run, the Dockerfile path, and all tooling configs (pyproject ty/ruff, MANIFEST.in, pre-commit, devcontainer). Hard removal of the old import path (no deprecation shim): the package was already flagged experimental. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4c446ad2-7050-4b03-bd88-dfe83ec69434
The AML notebook linked into the package source tree with relative paths (../../../../pyrit/...). Those 404 once the notebook is rendered on the docs website, which does not ship the pyrit/ package tree alongside the docs. Switch both links (the Dockerfile and the run.py -m entry point) to absolute https://github.com/microsoft/PyRIT/blob/main/... URLs, matching how the rest of doc/ links to source files. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4c446ad2-7050-4b03-bd88-dfe83ec69434
The GCG package moved out of pyrit/auxiliary_attacks/ (which emitted an ExperimentalWarning on import) into pyrit/executor/promptgen/gcg/. GCG is still experimental -- its API should be free to change without a deprecation cycle -- so re-emit the ExperimentalWarning from the new package __init__. The warning fires only on an explicit `import pyrit.executor.promptgen.gcg` (or `from ... import`), not on `import pyrit.executor.promptgen`, so the torch-free base import stays silent. Restores the warning unit test at the new path. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4c446ad2-7050-4b03-bd88-dfe83ec69434
GCG is now a PromptGeneratorStrategy in the standard framework, not an auxiliary attack; the docstring's descriptive phrasing was the last textual vestige of the removed pyrit/auxiliary_attacks subtree. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4c446ad2-7050-4b03-bd88-dfe83ec69434
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.
Description
pyrit/auxiliary_attacks/existed solely to quarantine GCG (Greedy Coordinate Gradient), and GCG was the only thing under it. But GCG's modern public API is already aPromptGeneratorStrategy(GCGGenerator), the same executor base class asFuzzerGeneratorandAnecdoctorGenerator, which live inpyrit/executor/promptgen/. So GCG was already framework-native in design; only its physical location made it "special." This PR relocates it to where it belongs and removes the one-off subtree.Approach: pure relocation, no behavior change. This is a mechanical
git mv+ import-path rewrite + repo-wide reference sweep. Theexecute_asyncAPI and the Azure ML job behavior are unchanged, the large vendored optimizer (attack_manager.pyand friends) stays vendored in place, and torch stays an optional (gcg) extra so the base install still imports without it.Key points for reviewers:
pyrit.auxiliary_attacks.gcg->pyrit.executor.promptgen.gcg. GCG is flagged experimental (importing it still emitsExperimentalWarning: "APIs may change in any release without a deprecation cycle"), so this is a hard move with no deprecation shim, consistent with that policy. The warning is re-emitted from the new location and fires only on explicitimport pyrit.executor.promptgen.gcg, never on the baseimport pyrit.executor.promptgen(keeps the base import torch-free).doc/code/auxiliary_attacks/->doc/code/executor/gcg/;myst.ymlnav updated and the standalone auxiliary section plus its generated API page removed (GCG folds intopyrit_executor_promptgen.md, matching the fuzzer precedent).auxiliary_attacksreferences remain anywhere in the repo (code, tests, docs, config, CI).Tests and Documentation
tests/unit/executor/promptgen/gcg/, integration ->tests/integration/executor/promptgen/gcg/, e2e ->tests/end_to_end/executor/promptgen/gcg/(notebook test renamedtest_notebooks_auxiliary.py->test_notebooks_gcg.py).0_gcg,1_gcg_azure_ml) were relocated and re-synced with JupyText (jupytext --to notebook --update). Source links in the AML notebook now use absolutehttps://github.com/microsoft/PyRIT/blob/main/...URLs so they don't 404 once rendered on the docs website (which doesn't ship the package tree).validate_docs.py(passes: refs resolve, no orphans, no leftover auxiliary API page). Full pre-commit (ruff, ty, validate-docs, nbstripout) is green.