Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set drop_last to always True #1761

Merged
merged 2 commits into from
Oct 8, 2024
Merged

Set drop_last to always True #1761

merged 2 commits into from
Oct 8, 2024

Conversation

RdoubleA
Copy link
Contributor

@RdoubleA RdoubleA commented Oct 7, 2024

Context

What is the purpose of this PR? Is it to

  • add a new feature
  • fix a bug
  • update tests and/or documentation
  • other (please add here)

Closes #1754. Instead of specifying drop_last with the dataset config (which will break when passed into the dataset builder), just hardcode to True. No configs expose this. We can make it configurable down the line if users request it.

Test plan

CI

Copy link

pytorch-bot bot commented Oct 7, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/torchtune/1761

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

✅ No Failures

As of commit 0b9a3ec with merge base a8a64ec (image):
💚 Looks good so far! There are no failures yet. 💚

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

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 7, 2024
Copy link
Contributor

@ebsmothers ebsmothers left a comment

Choose a reason for hiding this comment

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

Is this the right fix? Personally I find a top-level config field called drop_last to be pretty unclear. Why not just infer drop_last in the existing if/else for ConcatDataset here? https://github.com/pytorch/torchtune/blob/main/recipes/full_finetune_distributed.py#L487-L496

E.g.

if isinstance(cfg_dataset, ListConfig):
  # same stuff as before
  drop_last = any([single_cfg_dataset.get("drop_last", True) for single_cfg_dataset in cfg_dataset])
else:
  # same stuff as before
  drop_last = cfg_dataset.get("drop_last", True)

@RdoubleA
Copy link
Contributor Author

RdoubleA commented Oct 7, 2024

drop_last being in the dataset config does not make sense, as dataset points to a component and all kwargs should be related to that component/builder. drop_last is not in any of our dataset builders. I think having it top level is less confusing in that sense.

Frankly, we should have a more configurable dataloader or a section in the config for dataloader args, as this is becoming more customized.

@ebsmothers
Copy link
Contributor

OK yeah it is a dataloader config more than a dataset config so I do see your point there. Mainly I just do not want us to wind up with a hodgepodge of a bunch of random top-level configs, and drop_last is too in the weeds for the majority of users to care about (it is pretty much the exact definition of an edge case).

Copy link
Contributor

@joecummings joecummings left a comment

Choose a reason for hiding this comment

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

Rather than trying to conceive of edge cases that users might not even care about, can we just default drop_last to True, document it, and then if users want to have this be configurable, we can add a config.

Either way it's a one line change. For most cases, the last batch should be dropped.

@RdoubleA
Copy link
Contributor Author

RdoubleA commented Oct 8, 2024

Agreed

@RdoubleA RdoubleA changed the title Move drop_last to top-level config Set drop_last to always True Oct 8, 2024
@RdoubleA RdoubleA merged commit 27b0fcc into pytorch:main Oct 8, 2024
17 checks passed
@RdoubleA RdoubleA deleted the drop_last branch October 8, 2024 20:07
mori360 pushed a commit to mori360/torchtune that referenced this pull request Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

drop_last does not work with ConcatDataset
5 participants