这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@Phoveran
Copy link
Contributor

@Phoveran Phoveran commented Jun 9, 2025

C3A Paper is here.

currently, I fail to run the test by the command make test, and the output is:

image

Thank you for your time and guidance!

@BenjaminBossan
Copy link
Member

Hi, thanks for the PR. I didn't have time to look at it yet or to read the paper, but regarding your question, I assume that you would like to add unit tests and that's where you encounter it. The reason is that you're missing the pytest-cov package in your environment.

@Phoveran
Copy link
Contributor Author

Hi Benjamin,

I've passed the test cases and done make style. Would be kind to review the code? Thank you!

Copy link
Member

@BenjaminBossan BenjaminBossan left a comment

Choose a reason for hiding this comment

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

Thanks a lot for adding C³A to PEFT. The method looks very interesting and promising. I'll try to find some time next week to do a bit of my own testing.

The implementation itself is already nearly perfect, I just added a few smaller comments, please check.

On top of that, before we merge, let's also work:

  1. Add documentation about C³A
  2. Add one example
  3. Extend the tests a bit: Please add a test case to test_decoder_models.py, test_encoder_decoder_models.py, test_feature_extraction_models.py, test_seq_classifier.py, and test_stablediffusion.py. This should be straightforward as it only requires adding a test config similar to what you did in test_custom_models.py. However, due to the shape constraint of C³A, some of these models may not work. In that case, let's just add a comment that says something like "C³A could not be tested because the input and output shapes are ...".

Out of curiosity, is there any relation to FourierFT?

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@Phoveran
Copy link
Contributor Author

Hi Benjamin,

I have added more testing, a doc and an example according to your guidance. Besides, issues you listed should have been addressed. Let me know if you need further changes.

Actually, one of the original goal of this work is to make FourierFT mathematically elegant and efficient. :D

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Member

@BenjaminBossan BenjaminBossan 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 adding the tests, docs, example, and making the requested adjustments. Tests are passing (ignore the MacOS tests which fail for unrelated reasons).

I have a few small comments, but nothing major.

@Phoveran
Copy link
Contributor Author

Hi Benjamin,

Thank you for these comments! I believe I have properly addressed them :D. Please feel free to leave messages for further concerns!

@BenjaminBossan
Copy link
Member

@Phoveran With Python 3.9, there is the following error:

src/peft/tuners/c3a/layer.py:115: in C3ALinear
    init_weights: bool | Literal["gaussian", "kaiming_uniform", "xavier_uniform"],
E   TypeError: unsupported operand type(s) for |: 'type' and '_LiteralGenericAlias'

I think a from __future__ import annotations import should fix it.

Copy link
Member

@BenjaminBossan BenjaminBossan 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 fixing the last issue.

IMO the PR is ready to be merged, but before doing that, I wanted to discuss one matter. In PEFT, we have now added a benchmark for all PEFT method. I added C³A using the default config settings and started a run but then canceled after 2500 steps. The issue was that the loss was stagnating at around 1.3 and the valid accuracy stayed at 0. Other PEFT methods have much better scores. Probably the default settings are not working well. Do you have suggestions for how to adjust the hyper-parameters? Perhaps, it also means we need to update the default values.

(Btw. we have similarly bad scores for FourierFT, maybe you know some better settings for this model as well)

@Phoveran
Copy link
Contributor Author

Thanks for raising the benchmarking issue.

Indeed, we found that the usually used training config does not fit FourierFT nor C3A. The main difference should be the choice on LR. We refer to the Appendix part of these papers FourierFT & C3A for more LR details. In general, you might try 5e-1 for C3A and 3e-3 for FourierFT.

Thank you and please let me know if there's any further issue!

@BenjaminBossan
Copy link
Member

The main difference should be the choice on LR. We refer to the Appendix part of these papers FourierFT & C3A for more LR details. In general, you might try 5e-1 for C3A and 3e-3 for FourierFT.

Thanks for the guidance. Could you please update the C³A docs to mention that a much higher learning rate than usual is needed? Otherwise, many users who try it might bounce because the model doesn't train well.

I ran an experiment locally with lr 0.5 and got much better results. That said, they're still not on par with LoRA (rank 32):

metric LoRA rank 32 C³A w/ lr 0.5
total time 1847 sec 2102 sec
trainable params 9175040 1376256
cuda max reserved memo 22.3 GB 22.0 GB
train loss 0.607 0.659
test accuracy 0.478 0.412

It could be due to the number of parameters, but that's just my hunch.

Anyway, it is not critical for this PR, but I think going forward, it would be nice to provide good experimental settings and defaults so that users can get started as quickly as possible.

@Phoveran
Copy link
Contributor Author

Thanks for the feedback! I have manually wrapped strings and updated the doc. I will work on a proper experimental setting ASAP.

@Phoveran
Copy link
Contributor Author

Phoveran commented Jun 27, 2025

Hi Benjamin,

I have done some experiments and found out one satisfying experimental setting. The setting and results are uploaded. (You might find the meta info part blank since I'm using a machine that is not allowed to connect to the public network and I'm using offline HF.) Besides, more instructions are added.

In my experiment, I found out that C3A excels in accuracy with only nearly half parameters compared with LoRA, and this results in a much smaller adapter file.

@BenjaminBossan
Copy link
Member

Thanks a lot @Phoveran for running those experiments, discovering a good setting, and documenting how users can choose better hyper-parameters. As for the result file, could you please remove it? We will run the experiment on our machines to ensure that all experiments run under comparable conditions.

@BenjaminBossan
Copy link
Member

Could you please merge with/rebase on the latest PEFT main, then the CI should pass and we can merge.

Copy link
Member

@BenjaminBossan BenjaminBossan 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 great work, the PR LGTM. Hopefully it finds a lot of adoption.

@BenjaminBossan BenjaminBossan merged commit e657707 into huggingface:main Jun 30, 2025
21 of 27 checks passed
efraimdahl pushed a commit to efraimdahl/peft that referenced this pull request Jul 12, 2025
Add new PEFT method C³A (Circular Convolution Adaptation).

From "Parameter-Efficient Fine-Tuning via Circular Convolution":
https://arxiv.org/abs/2407.19342
@BenjaminBossan BenjaminBossan mentioned this pull request Aug 29, 2025
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.

3 participants