question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Update no_trainer scripts to include gather_for_metrics

See original GitHub issue

Feature request

🤗 Accelerate has a wrapper to help with distributed metric calculation (a tough problem!), and the no_trainer scripts should be updated to include it!

An example can be seen here, below is an example diff of what the integration would look like:

-             predictions, references = accelerator.gather((predictions, batch["labels"]))
-             # If we are in a multiprocess environment, the last batch has duplicates
-             if accelerator.num_processes > 1:
-                 if step == len(eval_dataloader) - 1:
-                     predictions = predictions[: len(eval_dataloader.dataset) - samples_seen]
-                     references = references[: len(eval_dataloader.dataset) - samples_seen]
-                 else:
-                     samples_seen += references.shape[0]
+             predictions, references = accelerator.gather_for_metrics((predictions, batch["labels"])) 

The list of available scripts to update include:

  • examples/pytorch/image-classification/run_image_classification_no_trainer.py
  • examples/pytorch/language-modeling/run_clm_no_trainer.py
  • examples/pytorch/language-modeling/run_mlm_no_trainer.py
  • examples/pytorch/multiple-choice/run_swag_no_trainer.py
  • examples/pytorch/question-answering/run_qa_beam_search_no_trainer.py
  • examples/pytorch/question_answering/run_qa_no_trainer.py
  • examples/pytorch/semantic-segmentation/run_semantic_segmentation_no_trainer.py
  • examples/pytorch/speech-pretraining/run_wav2vec2_pretraining_no_trainer.py
  • examples/pytorch/summarization/run_summarization_no_trainer.py

Motivation

This is a great first issue for someone who wants to learn how to use some of the latest bits in Accelerate and get an easy beginner contribution to the library 🤗

Your contribution

If you decide to pick up this issue, feel free to ping myself (@muellerzr), @sgugger, or @pacman100 to review 🤗

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
nandwalritikcommented, Aug 3, 2022

Hi @muellerzr opened PR #18443 for first three examples in the list.

1reaction
kiansierracommented, Aug 4, 2022

Hi @muellerzr I opened this PR https://github.com/huggingface/transformers/pull/18474 for examples 5,6 and 7.

Read more comments on GitHub >

github_iconTop Results From Across the Web

After update the instance script action and script... - ServiceNow
I created two catalogs where I am using two script actions and a common script include for both. here is my script action....
Read more >
Update and manage your published add-on | Apps Script
When you're ready to publish, create a new version for your add-on deployment. From the Apps Script project, take the following steps: At...
Read more >
UPDATE SCRIPT - IBM Spectrum Protect
UPDATE SCRIPT (Update an IBM Spectrum Protect script). Use this command to change a command line or to add a new command line...
Read more >
Update Data Logic scripts - Cisco IoT Operations Dashboard
To update a script, you must first undeploy it from all EI Agents. You can then update the script using VS Code and...
Read more >
Update a Script | BigCommerce Dev Center
It will enable automatic cleanup of the script when the single click app is uninstalled or OAuth token is revoked. load_method. string. The...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found