accum-batches can't be used with autoencoder
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Domain
- machine-learning
Research direction
Start in the AutoencoderTrainingWrapper class and trace the manual-optimization path used when model_type is "autoencoder". Compare it with Trainer(accumulate_grad_batches=32) and verify that the configured batch count is applied to both discriminator and generator updates without raising the reported exception. Done means autoencoder training accepts accum-batches and performs the expected accumulated optimizer steps.
Written by the indexing model from the issue text.
Description
When we set "model_type": "autoencoder" in the configuration of the model, the argument accum-batches can't be used because automatic_optimization is disabled.
MisconfigurationException: Automatic gradient accumulation is not supported for manual optimization. Remove `Trainer(accumulate_grad_batches=32)` or switch to automatic optimization.
To fix the issue, I have written the code to accumulate the batch in the AutoencoderTrainingWrapper class.
if use_disc:
loss, losses = self.losses_disc(loss_info)
log_dict["train/disc_lr"] = opt_disc.param_groups[0]["lr"]
# Gradient accumulation
if self.gradient_accumulation is not None:
loss = loss / self.gradient_accumulation
self.manual_backward(loss)
if self.clip_grad_norm > 0.0:
torch.nn.utils.clip_grad_norm_(
self.discriminator.parameters(), self.clip_grad_norm
)
# accumulate gradients of N batches
if (batch_idx + 1) % self.gradient_accumulation == 0:
opt_disc.step()
if sched_disc is not None:
# sched step every step
sched_disc.step()
opt_disc.zero_grad()
# Train the generator
else:
loss, losses = self.losses_gen(loss_info)
if self.use_ema:
self.autoencoder_ema.update()
log_dict["train/loss"] = loss.detach().item()
log_dict["train/latent_std"] = latents.std().detach().item()
log_dict["train/data_std"] = data_std.detach().item()
log_dict["train/gen_lr"] = opt_gen.param_groups[0]["lr"]
# Gradient accumulation
if self.gradient_accumulation is not None:
loss = loss / self.gradient_accumulation
self.manual_backward(loss)
if self.clip_grad_norm > 0.0:
torch.nn.utils.clip_grad_norm_(
self.autoencoder.parameters(), self.clip_grad_norm
)
# accumulate gradients of N batches
if (batch_idx + 1) % self.gradient_accumulation == 0:
opt_gen.step()
if sched_gen is not None:
# scheduler step every step
sched_gen.step()
opt_gen.zero_grad()
- Dominant language
- Python
- Stars
- 3.9k
- Forks
- 488
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Stability-AI/stable-audio-tools
-
Possible incorrect use of `and` with multiple context managersPossibly taken @rodriguescarson claimed this 119 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Stability-AI/stable-audio-tools#238 · 2 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
run_gradio.py fails out of the box on Apple Silicon (MPS): float64 crash, slice TypeError, missing ui depsMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 4/5 3-5 days Newbie friendliness 72/100
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
All issues in Stability-AI/stable-audio-tools
Similar issues
-
area/profiles comp/cli P3 type/feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
NousResearch/hermes-agent#146372 ·
Maintainers usually reply within 1 day
-
[BUG] OpenAI-compatible embedding model alias breaks embedder constructionPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
[oblt-aw][autodoc] Document obs-aw-automerge contract and fix automerge doc inconsistenciesPossibly taken @github-actions claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
GeoSeries scale and skew tests fail with pytest 9.2.0Possibly taken @jiayuasu claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
admission-deferred priority: medium status: ready work-class: scoped
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
melodic-software/claude-code-plugins#10887 · 4 comments ·
Maintainers usually reply within 1 day