facebookresearch / audiocraft

Audiocraft is a library for audio processing and generation with deep learning. It features the state-of-the-art EnCodec audio compressor / tokenizer, along with MusicGen, a simple and controllable music generation LM with textual and melodic conditioning.
MIT License
20.34k stars 2.05k forks source link

deterministic generation no longer possible - regression #111

Open rsxdalv opened 1 year ago

rsxdalv commented 1 year ago

pypi audiocraft 0.0.1 can easily generate deterministic results when setting the pytorch seed. the current repo version c9179f8 (audiocraft-0.0.2a2) cannot do it anymore. After about 3-4 seconds the results suddenly bug out and become non-deterministic. I checked the torch.initial_seed() and it remains intact, and I wasn't immediately able to see a problem with the new changes since 0.0.1.

Maybe someone can point it out?

hypereikon commented 1 year ago

been playing since the release and never felt that setting a torch generator did anything, i changed a few lines to be able to call the generator from generate() and now i can set the seed on each generation by passing a torch.Generator(device='cuda').manual_seed(seed). just had to edit a few lines on musicgen.py and lm.py https://github.com/hypereikon/audiocraft/tree/main/audiocraft/models

rsxdalv commented 1 year ago

@hypereikon Thank you, I tried it but it still acts essentially the same as the seeded version.

You can see the waveforms here: image image2

And these are the generation params:

 {
_audiocraft_version:  "0.0.2a2",
prompt:  "very slow piano",
text:  "very slow piano",
melody:  null,
model:  "small",
duration:  10,
topk:  250,
topp:  0,
temperature:  1,
cfg_coef:  3,
seed:  "123"
}

This is essentially the same result I got before, where the first ~2.5 seconds are stable but after that it diverges on every generation.