Skip to content

Fix TypeError: tuple indices must be integers or slices, not str issue with collate_fn #1011

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

Merged
merged 9 commits into from
May 22, 2024

Conversation

tambulkar
Copy link
Contributor

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)

Please link to any issues this PR addresses.
#1010

Changelog

What are the changes made in this PR?
Change indexing

Test plan

Please make sure to do each of the following if applicable to your PR. (If you're not sure about any one of these just ask and we will happily help.)

  • run pre-commit hooks and linters (make sure you've first installed via pre-commit install)
  • add unit tests for any new functionality
  • update docstrings for any new or updated methods or classes
  • run unit tests via pytest tests
  • run recipe tests via pytest tests -m integration_test
  • manually run any new or modified recipes with sufficient proof of correctness
    • include relevant commands and any other artifacts in this summary (pastes of loss curves, eval results, etc.)

Copy link

pytorch-bot bot commented May 22, 2024

🔗 Helpful Links

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

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

✅ No Failures

As of commit b3abc95 with merge base dc74267 (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
Copy link

Hi @tambulkar!

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 [email protected]. Thanks!

@RdoubleA
Copy link
Collaborator

RdoubleA commented May 22, 2024

Appreciate you patching this. Actually we should go the other way - we are standardizing on outputting dictionaries for each sample now instead of a tuple of list[int]. TextCompletionDataset should be updated to return a dictionary.

return {"tokens": tokens, "labels": labels}

and the return types need to be updated. That should be all that needs to change.

Since you're already here you can do this or I can make the change, let me know how you want to proceed :)

@tambulkar
Copy link
Contributor Author

I can go ahead and amend this PR - give me a few minutes

@RdoubleA
Copy link
Collaborator

you'll need to update test_text_completion_dataset.py, test_wikitext_dataset.py, and test_cnn_dailymail_dataset.py as well. You can run these tests locally with pytest tests/torchtune/datasets.

@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 May 22, 2024
Copy link
Collaborator

@RdoubleA RdoubleA left a comment

Choose a reason for hiding this comment

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

so glad you caught this early, thanks for jumping on a fix! were you able to launch your run successfully?

@RdoubleA RdoubleA merged commit 174bb15 into pytorch:main May 22, 2024
@RdoubleA
Copy link
Collaborator

Confirmed it runs on my end with the changes by running one of the built-in configs with wikitext

@tambulkar
Copy link
Contributor Author

My run works as well!

weifengpy pushed a commit to weifengpy/torchtune that referenced this pull request Jun 4, 2024
maximegmd pushed a commit to maximegmd/torchtune that referenced this pull request Jul 13, 2024
yinfan98 pushed a commit to yinfan98/sgl-tune-eagle that referenced this pull request May 26, 2025
I observed that
1. When CP is used without other data parallel (`dp_replicate` /
`dp_shard`), it works fine with and without torch.compile
2. When CP is combined with any other data parallel, it only works
without torch.compile. It would fail under compile, with error info like
"_UnboundLocalError: cannot access local variable 'buf899' where it is
not associated with a value_"

So I'm marking CP as "to be fixed".
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.

3 participants