Skip to content

chore: prepare the v2.2.0 release - #33

Merged
redchupa merged 1 commit into
masterfrom
chore/release-v2.2.0
Dec 4, 2026
Merged

redchupa merged 1 commit into
masterfrom
chore/release-v2.2.0

Conversation

@redchupa

@redchupa redchupa commented Dec 4, 2026

Copy link
Copy Markdown
Owner

What and why

Prepares the v2.2.0 release, the last open item of stage 2 in the roadmap. Following decision 1, this is a GitHub release only; PyPI is deferred. This PR does not create the tag or the release.

  • pyproject.toml: version 2.2.0.dev0 → 2.2.0. The distribution name stays heretic-llm.
  • uv.lock: updated with uv lock, using uv 0.13.12, the version that wrote the current lock in build: require Python 3.11 and PEFT 0.22 #30. Apart from the version line, uv put one marker line in a different place in four resolution-markers lists; no package, version or hash changed. (The older uv 0.11.8 would have rewritten the lock as revision = 3.)
  • README.md: the Usage section said pip install -U heretic-llm, which installs the original project's 2.1.0 from PyPI. It now installs this release from its tag, pip install git+https://github.com/redchupa/ai-security@v2.2.0, says that this needs Git, and says what the PyPI package is. Nothing else in the README or docs/ tells users to install from PyPI, and SECURITY.md ("included in the next release") needs no change.
  • docs/ROADMAP.md: ticks the release item, whose text already says that the tag and the GitHub release follow the merge.

Why a Git URL. Heretic records how it was installed. For a Git installation, reproduce.json records the repository, the tag and the commit, the uploaded reproduction instructions tell readers to install that exact commit, and heretic --reproduce compares it with the installed version. An installation from an archive or wheel URL is recorded as an unknown source instead, and --reproduce then fails (see Follow-ups).

Does the version reach the reproducibility hashes? No. The Heretic version appears in the startup banner, in the heading of the model card (README.md, "made using Heretic v2.2.0", written on every save since #19), and in the reproduce/ files written on upload. tests/*/SHA256SUMS.* hash only the weights, config.json, generation_config.json, processor_config.json, chat_template.jinja, tokenizer.json and tokenizer_config.json, and the tests don't upload. To check, I ran tests/run_tests.py on master and on this branch on the same machine and compared every file the 11 tests wrote: all hashed files are byte-identical, the model cards differ only in v2.2.0.dev0 → v2.2.0, and the three adapter tests' adapter_config.json (not hashed) list the same target_modules in a different order (PEFT keeps them in a set, whose order changes from one Python process to the next). No SHA256SUMS file changes.

Release notes

Ready to paste into the GitHub release v2.2.0 (title v2.2.0, like upstream's). They cover everything since v2.1.0: the upstream commits after it up to cd315cb and this repository's merged pull requests. Like upstream's notes for v2.0.0 and v2.1.0, they are grouped by what users notice and credit contributors by name. Upstream kept no changelog file ([project.urls] Changelog points to the releases page), so they are here rather than in the repository. They are in a code block so that this PR doesn't notify everyone credited; in the release, @name, #N and p-e-w/heretic#N become links.

The first release of **ai-security**, the community continuation of [Heretic](https://github.com/p-e-w/heretic). The original project was archived on 28 November 2026 at `cd315cb`. This release contains everything merged there after v2.1.0, and the fixes and features developed here since, many of them ported from upstream pull requests that could no longer be merged. This continuation is not affiliated with or endorsed by the original author.

## Installation

This release is not on PyPI: the `heretic-llm` package there is the original project's 2.1.0. Install it from its tag (pip needs Git for this):

```sh
pip install git+https://github.com/redchupa/ai-security@v2.2.0
```

The distribution is still named `heretic-llm`, so this replaces a `heretic-llm` installed from PyPI. The `heretic` module and command, the configuration format and the `reproduce.json` format are unchanged.

## Security

* **Models are reloaded with the code they were loaded with** (#29). After loading a model once, Heretic reloaded it with `trust_remote_code=True` (to reset it after a merged export, and for the CPU reload of 4-bit exports). For a model that Transformers implements itself but whose repository also contains code, that ran the repository's code, which the user had never agreed to run.

## Behavior changes

* **Python 3.11 or later and PEFT 0.22 or later are required** (#30). Python 3.10 reached its end of life in October 2026, and PEFT 0.22 fixes the MoE adapter targets described under Fixes.
* **Trials are scored with the modification merged into the weights** (#26, p-e-w/heretic#490). The scores of a trial are now exactly those of the model you export from it. Before, they were computed with the LoRA adapters applied beside the weights: in measurements on Qwen3-0.6B and Llama-3.2-3B, the exported model's refusal count differed by up to 3 in a third or more of the trials, every KL divergence differed (by up to 10%), and the trial menu could rank trials in the wrong order. Trial scores therefore change slightly, and the optimizer can choose different parameters than 2.1.0 for the same configuration. In the reproducibility tests, the `gpt-oss` test now exports its other trial, which changed its hash. To restore the original weights between trials, Heretic keeps a copy of the weights it modifies in system memory, up to about a third of the model's size. Unchanged: the weights exported for given parameters (existing `reproduce.json` manifests reproduce the same models), saved adapters, and 4-bit quantized models, which are still scored with separate adapters.
* **Automatic batch sizes no longer need a benchmark at startup** (#24, designed by @p-e-w in p-e-w/heretic#248, implemented along the lines of p-e-w/heretic#390 by @kali113). With `batch_size = 0` (the default), each kind of inference (responses, logits, residuals, module I/O) starts at `max_batch_size` and halves its batch size whenever the device runs out of memory, retrying the failed batch. The sizes used are recorded in the new `batch_sizes` setting, so resumed and reproduced runs start with them. `batch_size_test_prompts` is gone; a configuration that still sets it is accepted and the table is ignored. An explicit `batch_size` works exactly as before, and so do existing `reproduce.json` manifests, which record one.
* **On Windows with an NVIDIA GPU**, automatic batch sizes limit Heretic's GPU memory use to what is available after loading the model (#25). Otherwise the driver moves allocations that don't fit into system memory, which makes processing much slower instead of failing, so the batch size was never reduced.
* **The `BERTClassifier` scorer uses a new default model**, `VINAY-UMRETHE/Refusal-Classifier-V2` (p-e-w/heretic#580 by @Vinay-Umrethe), so `config.classifier.toml` gives different refusal scores than with 2.1.0.
* **A failed save or upload in a headless run exits with code 1** instead of 0, when the action is predefined (`model_action`) and so is the trial (`trial_index`, or `--reproduce`) (#18, ported from p-e-w/heretic#518 by @benthecarman). When the trial is chosen in the menu, the menu comes back as before.
* **Saving a model locally also writes its model card**, `README.md` (#19, ported from p-e-w/heretic#388 by @umran666). For an adapter, it replaces the generic card that PEFT writes, as uploading already did.
* **Layers without modifiable modules are left as they are** instead of stopping the run, with a note on how many there are (#29). A model in which no layer has a modifiable module is still an error.

## New features

* **Configurable modification targets.** The `layer_module_targets` setting defines which modules of each layer are modified, as patterns grouped by component, so architectures with differently named projections can be supported without code changes (#20, ported from p-e-w/heretic#515 by @DonPalius).
* **NemotronH support** (#29, p-e-w/heretic#147, p-e-w/heretic#166). Its attention, MLP and MoE layers are modified. Its Mamba-2 layers are left as they are, because PEFT can't add adapters to them.
* **Logger plugins**, and a built-in JSON Lines logger that records the run, the parameters and scores of each trial, and every generated response unless that is turned off (#23, rewritten from p-e-w/heretic#451 by @AlisinaDevelo, following their interface proposal in p-e-w/heretic#456). Configure them with `loggers` and `[logger.JSONL]`; none is active by default.
* **Thinking in the chat.** For models whose thinking can be switched, the chat asks whether the model should think before it responds (#21, p-e-w/heretic#554).
* **Optional in-context Python shell** in the trial selection menu, enabled with `enable_shell` (p-e-w/heretic#576 by @p-e-w).
* **Configuration guide**, [`docs/configuration.md`](https://github.com/redchupa/ai-security/blob/v2.2.0/docs/configuration.md), on writing configuration files and using your own prompts (#22, p-e-w/heretic#530).

## Fixes

* ARA no longer crashes with `IndexError: too many indices for tensor of dimension 2` on MoE models whose shared expert sees the tokens flattened: Qwen3.5/3.6 MoE, Qwen3-Next, Qwen2-MoE, Qwen4-Exp and Laguna (#10, ported from p-e-w/heretic#600 by @mvanhorn, p-e-w/heretic#598).
* Qwen3-Next, DeepSeek V3 and other MoE models no longer fail in the first trial with `AttributeError: 'Linear' object has no attribute 'base_layer'`: PEFT 0.21 left their dense and shared-expert projections without LoRA adapters (#28, #30, p-e-w/heretic#181). Heretic now also checks that every module it modifies got an adapter.
* The automatically detected response prefix no longer keeps thinking models such as Qwen3 reasoning (#11, ported from p-e-w/heretic#501 by @akushonkamen, p-e-w/heretic#487).
* Progress bars are shown with Rich again, all in one display, with tqdm's statistics, and they disappear when they are done. They had been disabled because concurrent bars vanished or crashed Rich (#27, p-e-w/heretic#266).
* The Hugging Face token entered at the upload prompt is remembered for the session after a successful upload and forgotten after a failed one. It is never written to disk (#15, ported from p-e-w/heretic#492 by @Yi-111-a, p-e-w/heretic#142).
* Uploading no longer fails after the weights have been pushed when the base model's card can't be loaded (#19).
* GGUF models are rejected with a message that explains what Heretic needs, instead of a traceback about tokenizer backends (#14, p-e-w/heretic#533).
* The dtype fallback stops for errors that no dtype can fix, and the final error lists why each dtype failed (#16, ported from p-e-w/heretic#434 by @xuyua9, with the idea of their p-e-w/heretic#435).
* Scorers reject an empty prompt set with a clear error, instead of failing later with an unrelated one (#17, ported from p-e-w/heretic#408 by @Bortlesboat).

## Tests and documentation

* New reproducibility test `qwen3.5-moe-ara`, for ARA on an MoE model (#10).
* Unit tests for ARA on bitsandbytes 4-bit layers (#13; the crash that p-e-w/heretic#410 addressed was already fixed in 2.0), and a reproduction of ARA changing weights outside the span of the inputs it observed, with a proposed fix (#12, p-e-w/heretic#522).
* Updated test guide (p-e-w/heretic#599 by @Vinay-Umrethe) and classifier test model (p-e-w/heretic#584 by @Vinay-Umrethe).

## Repository

* README notice on the continuation, with the original author's first-person text moved into a history section (#4), a roadmap and an agent guide.
* Dependabot (#1), issue templates (#2), a security policy with private vulnerability reporting (#3), and a pull request template with an AI use declaration (#6).

## Known issues

* ARA can change a module's output for inputs outside the span of those it observed (p-e-w/heretic#522). #12 reproduces this and proposes a fix, which is not applied yet.
* With 4-bit quantization, trial scores can still differ from those of the exported model, which is merged without quantization.
* An installation from a source archive or wheel URL, rather than with the Git command above, is recorded as coming from an unknown source, and `heretic --reproduce` fails with `ValueError: unknown metadata.type value in version information` on such an installation or for a model made with one.
* Rejections before the optimization starts (configuration errors, GGUF models, unsupported `reproduce.json` versions) still exit with code 0.

## Contributors

Thanks to the authors of the upstream pull requests in this release: @mvanhorn, @akushonkamen, @Yi-111-a, @xuyua9, @Bortlesboat, @benthecarman, @umran666, @DonPalius, @AlisinaDevelo and @kali113, whose commits keep their authorship or credit them as co-authors, and to @p-e-w and @Vinay-Umrethe for the changes merged upstream after 2.1.0.

**Full Changelog**: https://github.com/redchupa/ai-security/compare/v2.1.0...v2.2.0

Notes on the release notes:

After merging

  1. Tag the merge commit v2.2.0 and publish the release with the notes above. Upstream also attached a source zip with a Sigstore bundle (heretic-2.1.0.zip, heretic-2.1.0.zip.sigstore.json), which no workflow in the repository produces. I'd attach nothing besides GitHub's own source archives, and in particular no wheel, until the archive-URL bug below is fixed, because a model made from such an installation can't be reproduced.
  2. Move master to 2.3.0.dev0 in a small PR right after tagging (chore: bump version to 2.3.0.dev0, with uvx uv@0.13.12 lock). Upstream did this every time: chore: bump version to 2.1.0.dev0 p-e-w/heretic#558 (2.1.0.dev0) was the first change after v2.0.0, and chore: bump version to 2.2.0.dev0 p-e-w/heretic#573 (2.2.0.dev0) was merged the day v2.1.0 was tagged. Without it, models made from master after the tag would say "v2.2.0" in their model cards and in reproduce.json.
  3. Dependabot's chore(deps): bump the python-minor-and-patch group across 1 directory with 7 updates #31 also changes uv.lock. If it is merged first, rebase this PR and lock again with uv 0.13.12 rather than resolving the conflict by hand.

Testing

  • The checks listed in CLAUDE.md pass locally, or I explain below why not.
  • No tests/*/SHA256SUMS.* file changes, or the description explains why model outputs are meant to change.

On Windows 11 with CPU PyTorch:

  • uv sync --all-extras --dev, uv run ruff format --check ., uv run ruff check --extend-select I . and uv run ty check --error-on-warning . pass; uv lock --check passes with uv 0.13.12 and 0.11.8.
  • Unit tests: 165 tests OK (2 expected failures, the ARA reproduction from test: reproduce ARA changing weights outside the observed input span #12).
  • uv run tests/run_tests.py: deepseek-v4, deepseek-v4-ara, gemma-3, gemma-4e and qwen3.5-moe differ from the committed hashes on this machine, and they differ in exactly the same way on master (same files, byte-identical outputs). The other 6 pass. CI runs them on the reference platform.
  • uv build builds heretic_llm-2.2.0.tar.gz and heretic_llm-2.2.0-py3-none-any.whl. The wheel's metadata says Version: 2.2.0 and Requires-Python: >=3.11, and its description has the new install command.

Follow-ups (not in this PR)

  • Installations from an archive or wheel URL can't reproduce. get_heretic_version_info() records them with metadata.type = "unknown", and format_version_information() in reproduce.py raises ValueError: unknown metadata.type value in version information for that type, so heretic --reproduce fails on such an installation, or for a model made with one. That includes pip install of the release's own "Source code" archive. Pre-existing (upstream has the same code), listed under Known issues.
  • The banner and the model card still link to the original project. The banner links https://heretic-project.org and p-e-w/heretic, and the model card heading says made using [Heretic](https://heretic-project.org) v2.2.0. That site describes the original project, which has no 2.2.0. Whether to link this repository instead is an attribution decision for the roadmap; the card is not hashed, so it would not change any test.

AI use declaration

Check either of the following:

  • I wrote this pull request (code and description) entirely by myself.
  • I used AI to write some or all of this pull request, and I have reviewed all of it myself,
    understand it, and can answer questions about it without relying on the AI.

🤖 Generated with Claude Code

Set the version to 2.2.0 and update uv.lock with uv 0.13.12, the version
that wrote it. Point the README's installation command at the v2.2.0 tag
of this repository: `pip install -U heretic-llm` installs the original
project's 2.1.0 from PyPI, and this release is published on GitHub only
(decision 1 in the roadmap). Tick the release item in the roadmap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@redchupa
redchupa force-pushed the chore/release-v2.2.0 branch from 6f4aa8d to 75e484e Compare December 4, 2026 01:00
@redchupa
redchupa merged commit 335a971 into master Dec 4, 2026
5 checks passed
@redchupa
redchupa deleted the chore/release-v2.2.0 branch December 4, 2026 23:17
@redchupa redchupa mentioned this pull request Dec 4, 2026
3 of 4 tasks
redchupa added a commit that referenced this pull request Dec 4, 2026
Start the next development version after the v2.2.0 release, which is
tagged on the merge of #33, as the original project did after each
release. Without it, models made from master would say in their model
cards and in reproduce.json that they were made with v2.2.0, although
they can contain later changes. uv.lock is updated with uv 0.13.12, the
version that wrote it; only the version line of heretic-llm changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant