Repository navigation
build: require Python 3.11 and PEFT 0.22 - #30
Merged
Merged
Conversation
Python 3.10 reached its end of life in October 2026. PEFT 0.22 fixes the MoE target conversion that #28 worked around (huggingface/peft#3711, fixed by huggingface/peft#3715), but it requires Python 3.11, so drop Python 3.10 and remove the workaround. - pyproject.toml: requires-python >= 3.11, no 3.10 classifier, peft~=0.22. uv.lock regenerated with uv 0.13.12 (still revision 5): PEFT 0.21.2 -> 0.22.0; the rest only drops what Python 3.10 needed. - CI matrix without 3.10, README says Python 3.11+. - model.py: remove no_peft_target_conversion(). Keep the check that every target got a LoRA adapter, but check the targets as they were before get_peft_model(): PEFT rewrites peft_config.target_modules in place, so the old check never saw a target that PEFT dropped. - test_lora_targets.py: test that the check raises when PEFT drops a target. - Resolve the "when we drop Python 3.10" TODOs with hashlib.file_digest, and use datetime.UTC, which ruff (UP017) asks for now that the target version is 3.11. - ROADMAP: record the decision and tick it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 of 4 tasks
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.
Roadmap, stage 2: adds a "dependencies" item that records the decision to require Python ≥ 3.11 and PEFT ≥ 0.22, and ticks it.
What and why
Python 3.10 reached its end of life in October 2026. PEFT 0.22.0 (2026-11-19) fixes the MoE target conversion that #28 worked around inside Heretic (huggingface/peft#3711, fixed by huggingface/peft#3715: a target is kept as a module when every module it matches is an
nn.Linear), but PEFT 0.22 requires Python ≥ 3.11. This PR drops Python 3.10 and removes the workaround.pyproject.toml:requires-python = ">=3.11", no 3.10 classifier,peft~=0.22.uv.lock: regenerated withuv lock(uv 0.13.12; stillrevision = 5). PEFT moves 0.21.2 → 0.22.0 and nothing else moves: the rest of the diff only removes what Python 3.10 needed (tomli,exceptiongroup,async-timeout,importlib-resources,greenlet, and the 3.10-only versions of numpy, pandas, scipy, scikit-learn, networkx and sqlalchemy).torchandtorchvisionstay unpinned (2.14.1 in the lock, as before). Dependabot's chore(deps): bump the python-minor-and-patch group across 1 directory with 5 updates #8 bumpspeftto 0.21.3 along with four other packages; this PR supersedes itspeftpart.model.py:no_peft_target_conversion()is gone;add_lora_adapters()callsget_peft_model()directly.The check after
get_peft_model()didn't work, so it is fixed here. #28 also added a check that every target got a LoRA adapter. It readpeft_config.target_modulesafterget_peft_model(), but PEFT's conversion rewrites that same set in place (deliberately;convert_peft_config_for_transformerssays "the conversion should be in-place"), so a target that PEFT dropped was also missing from the list being checked. With the workaround that didn't matter, because the conversion never ran; without it, the check is the only guard. It now checks the targets as they were beforeget_peft_model(). Verified with PEFT 0.21.2, which still has the bug: without the workaround, the old check letapply_lora()return with unadapted modules, the new one raisesA new unit test,
test_dropped_target_raises, simulates PEFT dropping a target in place; it fails with #28's check ("Exception not raised") and passes with this one.Two small things that come with dropping 3.10:
# TODO: Replace this with hashlib.file_digest when we drop support for Python 3.10.helpers (utils.get_file_sha256,tests/run_tests.py) now usehashlib.file_digest. Same digests.datetime.UTCinstead oftimezone.utc(3 places,ruff check --fix).datetime.UTC is datetime.timezone.utc, so nothing changes at runtime.Testing
tests/*/SHA256SUMS.*file changes, or the description explains why model outputs are meant to change.Windows 11, Python 3.12.13, torch 2.14.1+cpu, transformers 5.18.0. "Baseline" is master at b51d969 (with #28, so PEFT 0.21.2 with the workaround), run on the same machine.
ruff format --check,ruff check --extend-select I,ty check --error-on-warning, unit tests (165; the 2 expected failures as on master),uv build: pass. The wheel saysRequires-Python: >=3.11andRequires-Dist: peft~=0.22.tests/test_lora_targets.py(from fix: keep the dense and shared-expert projections of MoE models in the LoRA targets #28: small Qwen3-Next, DeepSeek V3 and Llama models built from their configurations) passes without the workaround, so PEFT 0.22 keeps the dense and shared-expertdown_projtargets. With PEFT 0.21.2 and no workaround, the Qwen3-Next and DeepSeek V3 tests fail, now with the error above.get_merged_model()'s 4-bit path callsadd_lora_adapters()a second time, with the sameLoraConfig, which PEFT's conversion has already processed. Simulated with the same small Qwen3-Next and DeepSeek V3 models (the "reloaded" base model built from the same seed instead of quantizing): every target gets an adapter again, and the merged weights are identical to merging the adapters directly.nemotron_h.uv run tests/run_tests.py), baseline vs. this branch: every weight file (model.safetensors,adapter_model.safetensors) of all 11 tests is byte-identical. Against the committed hashes, both runs fail the same 5 tests on this machine (deepseek-v4, deepseek-v4-ara, gemma-3, gemma-4e, qwen3.5-moe), so those are differences of this machine, not of this change. The only file that differs between the two runs isadapter_config.jsonof the three adapter exports:peft_version0.21.2 → 0.22.0, PEFT's newastra_config: null, and the order oftarget_modules, which PEFT writes from a set (it differs from run to run anyway). NoSHA256SUMSfile changes.tiny-random/qwen3-next-moe(the model fix: keep the dense and shared-expert projections of MoE models in the LoRA targets #28 fixed) with the settings oftests/qwen3.5-moe(Abliteration, merged) andtests/qwen3.5-moe-ara(ARA, adapter). This is the check that matters for the conversion: none of the reproducibility test models is in PEFT's conversion table, so they never ran it. Both complete. Every file of the Abliteration export is byte-identical to the baseline's (5 of its 442 tensors differ from the original model: the attention output projections of layers 1–3 and the shared expert'sdown_projof layers 2 and 3), and so are the ARA adapter weights. The ARAadapter_config.jsondiffers inpeft_version, the newastra_config: null, the order oftarget_modules, and"target_parameters": []instead ofnull, which PEFT's conversion sets when it runs and leaves the targets as they are.delta.mul_(scaling)instead ofdelta * scaling, the same arithmetic). Since fix: score trials with the adapters merged into the weights #26, every trial is scored with the adapters merged, so the identical results above cover that too.AI use declaration
understand it, and can answer questions about it without relying on the AI.
🤖 Generated with Claude Code