Skip to content

Fix minibatch splitting in char-RNN classification tutorial - #3975

Open
ability-spec wants to merge 1 commit into
pytorch:mainfrom
ability-spec:fix/char-rnn-minibatch-splitting
Open

ability-spec wants to merge 1 commit into
pytorch:mainfrom
ability-spec:fix/char-rnn-minibatch-splitting

Conversation

@ability-spec

@ability-spec ability-spec commented Oct 6, 2026 •

Copy link
Copy Markdown

The char-RNN classification tutorial uses floor division to calculate the number of minibatches. With fewer examples than n_batch_size, training crashes with:
ValueError: number sections must be larger than 0.

Non-divisible datasets can also produce batches larger than requested.

This change uses ceiling division, preserving balanced batches while supporting small nonempty datasets and respecting the requested batch size.

Validation

  • CPU boundary checks: original 3/9 passed; patched 9/9 passed.
  • Complete tutorial script finished 27 epochs and evaluation on a small synthetic names dataset.
  • Repository lintrunner and git diff --check passed.
  • Full documentation build and original dataset training were not run.

Checklist

  • Only one issue is addressed in this pull request.
  • No unrelated changes are included.

@pytorch-bot

pytorch-bot Bot commented Oct 6, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/tutorials/3975

Note: Links to docs will display an error until the docs builds have been completed.

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla

meta-cla Bot commented Oct 6, 2026

Copy link
Copy Markdown

Hi @ability-spec!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla

meta-cla Bot commented Oct 6, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla Bot added the cla signed label Oct 6, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant