Skip to content

fix: ping peft >= 0.18.0, < 0.19.0 for torchao compatability issues#630

Merged
davidberenstein1957 merged 2 commits intomainfrom
fix/torchao-peft-compat
Apr 16, 2026
Merged

fix: ping peft >= 0.18.0, < 0.19.0 for torchao compatability issues#630
davidberenstein1957 merged 2 commits intomainfrom
fix/torchao-peft-compat

Conversation

@davidberenstein1957
Copy link
Copy Markdown
Member

Summary

  • peft>=0.18.1 added a strict is_torchao_available() check that raises ImportError (not returns False) when torchao<0.16.0 is installed
  • This broke any LoRA loading through peft (e.g. the Hyper algorithm on stable_diffusion_v1_4) — failing CI job: feat(evaluation): add VLMMetrics #545
  • Removes the <0.16.0 upper cap and raises the floor to >=0.16.0

Root cause

Call chain: Hyper._applymodel.load_lora_weights → peft dispatch_torchaois_torchao_available()ImportError: Found version 0.15.0, but only versions above 0.16.0 are supported

The original cap was added for a torchao+torch_compile+diffusers interaction. That issue is CPU/torch_compile-specific and does not affect the base test suite. torchao 0.17.0 Python API is compatible with torch>=2.8.0 (our CI uses torch 2.9.1).

Test Plan

  • CI test (3.11, base) passes — specifically TestHyper_stable_diffusion_v1_4-cpu
  • TestTorchao_sd_tiny_random-cpu and TestTorchao_flux_tiny_random-cpu still pass

@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented Apr 15, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

Comment thread pyproject.toml Outdated
@davidberenstein1957 davidberenstein1957 force-pushed the fix/torchao-peft-compat branch 2 times, most recently from b133bca to 3fdd1a1 Compare April 16, 2026 09:38
Copy link
Copy Markdown
Member

@begumcig begumcig left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @davidberenstein1957

I think we currently don’t support torchao > 0.16. When we tested newer versions, our nightlies started failing (@gsprochette would know better about this than me), so we still need to properly investigate compatibility. Also even if we supported the newer torchao, pinning it >=0.16.0 would break the torch versions we support, because they are also tightly coupled.

From my perspective, the next steps would be:

  • Investigate whether we can support torchao > 0.16.
  • Introduce a new extra (aligned with our dependency separation strategy in Pruna), e.g. recovery, that includes the required versions for peft, trl, termcolor, and torchao. We should also guard all module-level imports of these packages across the codebase (tests and recovery).

Since the nightlies are currently failing and we need a quick fix, I think we can temporarily pin peft to:

peft >= 0.18.0, < 0.19.0

In the PR description, you mentioned that the issue comes from peft>=0.18.1, but after checking the source code, it looks like the breaking change was actually introduced in 0.19.0:
https://github.com/huggingface/peft/blob/6d5a6f4f2f902dbf13d21d2661d57c3c05df1dae/src/peft/import_utils.py#L131
Please correct me if I’m mistaken here.

But anyway, I think overall, pinning peft to a version range above 0.18.0 and below the first version that introduces the torchao incompatibility should be a reasonable short-term fix, until we can properly support newer torchao versions. What do you think?

@davidberenstein1957
Copy link
Copy Markdown
Member Author

Hi @begumcig,

I have not investigated the nightlies. @gsprochette is still on holiday, right? Let's, for now, go for the easy fix and pin peft to peft >= 0.18.0, < 0.19.0.

@davidberenstein1957 davidberenstein1957 changed the title fix: raise torchao floor to >=0.16.0 for peft compatibility fix: ping peft >= 0.18.0, < 0.19.0 for torchao compatability issues Apr 16, 2026
Copy link
Copy Markdown
Member

@begumcig begumcig left a comment

Choose a reason for hiding this comment

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

Looks super good to me !! Thank you so much David

@davidberenstein1957 davidberenstein1957 merged commit 966e143 into main Apr 16, 2026
8 checks passed
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