Skip to content

MAINT: Fold GCG into pyrit/executor/promptgen, remove auxiliary_attacks#2197

Open
romanlutz wants to merge 4 commits into
microsoft:mainfrom
romanlutz:romanlutz-gcg-as-workflow-exploration
Open

MAINT: Fold GCG into pyrit/executor/promptgen, remove auxiliary_attacks#2197
romanlutz wants to merge 4 commits into
microsoft:mainfrom
romanlutz:romanlutz-gcg-as-workflow-exploration

Conversation

@romanlutz

Copy link
Copy Markdown
Contributor

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 a PromptGeneratorStrategy (GCGGenerator), the same executor base class as FuzzerGenerator and AnecdoctorGenerator, which live in pyrit/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. The execute_async API and the Azure ML job behavior are unchanged, the large vendored optimizer (attack_manager.py and friends) stays vendored in place, and torch stays an optional (gcg) extra so the base install still imports without it.

Key points for reviewers:

  • Import path change: pyrit.auxiliary_attacks.gcg -> pyrit.executor.promptgen.gcg. GCG is flagged experimental (importing it still emits ExperimentalWarning: "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 explicit import pyrit.executor.promptgen.gcg, never on the base import pyrit.executor.promptgen (keeps the base import torch-free).
  • Docs moved: doc/code/auxiliary_attacks/ -> doc/code/executor/gcg/; myst.yml nav updated and the standalone auxiliary section plus its generated API page removed (GCG folds into pyrit_executor_promptgen.md, matching the fuzzer precedent).
  • No auxiliary_attacks references remain anywhere in the repo (code, tests, docs, config, CI).

Tests and Documentation

  • All GCG tests moved alongside the package: unit -> tests/unit/executor/promptgen/gcg/, integration -> tests/integration/executor/promptgen/gcg/, e2e -> tests/end_to_end/executor/promptgen/gcg/ (notebook test renamed test_notebooks_auxiliary.py -> test_notebooks_gcg.py).
  • GCG unit suite: 45 passed / 9 skipped (the 9 are torch-gated and skip in the base env). Verified the base no-torch import path stays clean.
  • The two notebooks (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 absolute https://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).
  • Regenerated the docs API and ran validate_docs.py (passes: refs resolve, no orphans, no leftover auxiliary API page). Full pre-commit (ruff, ty, validate-docs, nbstripout) is green.

Copilot AI added 4 commits July 14, 2026 14:54
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
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