How to use Accelerate for prompt tuning?

Hello there!

I could use some guidance with soft prompt tuning using the Accelerate library. My main challenge is optimizing only a prompt, and I haven’t been able to figure out how to prepare the prompt and its optimizer with Accelerate.

Let me explain a bit more. I’m working with a language model like GPT, and here’s how I currently initialize the prompt and optimizer:

prompt_embed = torch.randn(1, softPromptLength, modelEmbeddingSize) * 0.01
prompt_embed = prompt_embed.requires_grad_(True)
optimizer = torch.optim.Adam([prompt_embed], lr=0.001)

I’ve tried a few things, such as creating a separate model just for the prompt, but I haven’t had any luck so far. Any ideas or assistance you could provide would be immensely appreciated!