Repository: huggingface/transformers
Pull request: Add write token for uploading benchmark results to the Hub

# What does this PR do?

This PR passes in the correct write token for uploading the benchmarking result to the hub.

## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [ ] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#create-a-pull-request),
      Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [ ] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?


## Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

<!-- Your PR will be replied to more quickly if you can figure out the right person to tag with @

 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.

Models:

- text models: @ArthurZucker
- vision models: @amyeroberts, @qubvel
- speech models: @eustlb
- graph models: @clefourrier

Library:

- flax: @gante and @Rocketknight1
- generate: @zucchini-nlp (visual-language models) or @gante (all others)
- pipelines: @Rocketknight1
- tensorflow: @gante and @Rocketknight1
- tokenizers: @ArthurZucker
- trainer: @zach-huggingface, @SunMarc and @qgallouedec
- chat templates: @Rocketknight1

Integrations:

- deepspeed: HF Trainer/Accelerate: @SunMarc @zach-huggingface
- ray/raytune: @richardliaw, @amogkam
- Big Model Inference: @SunMarc
- quantization (bitsandbytes, autogpt): @SunMarc @MekkCyber

Documentation: @stevhliu

HF projects:

- accelerate: [different repo](https://github.com/huggingface/accelerate)
- datasets: [different repo](https://github.com/huggingface/datasets)
- diffusers: [different repo](https://github.com/huggingface/diffusers)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Maintained examples (not research project or legacy):

- Flax: @Rocketknight1
- PyTorch: See Models above and tag the person corresponding to the modality of the example.
- TensorFlow: @Rocketknight1

 -->


Changed files:
filename: .github/workflows/benchmark_v2.yml
patch: @@ -70,7 +70,8 @@ jobs:
           python3 run_benchmarks.py \
           --commit-id '${{ inputs.commit_sha || github.sha }}' \
           --run-id '${{ inputs.run_id }}' \
-          --upload-to-hub '${{ inputs.benchmark_repo_id}}' \
+          --push-to-hub '${{ inputs.benchmark_repo_id}}' \
+          --token '${{ secrets.TRANSFORMERS_CI_RESULTS_UPLOAD_TOKEN }}' \
           --log-level INFO
         env:
           HF_TOKEN: ${{ secrets.HF_HUB_READ_TOKEN }}
\ No newline at end of file

filename: benchmark_v2/README.md
patch: @@ -27,10 +27,13 @@ You can automatically upload benchmark results to a HuggingFace Dataset for trac
 
 ```bash
 # Upload to a public dataset with auto-generated run ID
-python run_benchmarks.py --upload-to-hf username/benchmark-results
+python run_benchmarks.py --upload-to-hub username/benchmark-results
 
 # Upload with a custom run ID for easy identification
-python run_benchmarks.py --upload-to-hf username/benchmark-results --run-id experiment_v1
+python run_benchmarks.py --upload-to-hub username/benchmark-results --run-id experiment_v1
+
+# Upload with custom HuggingFace token (if not set in environment)
+python run_benchmarks.py --upload-to-hub username/benchmark-results --token hf_your_token_here
 ```
 
 **Dataset Directory Structure:**
@@ -51,6 +54,13 @@ dataset_name/
     └── ...
 ```
 
+**Authentication for Uploads:**
+
+For uploading results, you need a HuggingFace token with write permissions to the target dataset. You can provide the token in several ways (in order of precedence):
+
+1. Command line: `--token hf_your_token_here`
+3. Environment variable: `HF_TOKEN`
+
 ### Running Specific Benchmarks
 
 ```bash

filename: benchmark_v2/run_benchmarks.py
patch: @@ -195,6 +195,7 @@ def upload_results_to_hf_dataset(
     summary_file: str,
     dataset_name: str,
     run_id: Optional[str] = None,
+    token: Optional[str] = None,
     logger: Optional[logging.Logger] = None,
 ) -> Optional[str]:
     """
@@ -205,6 +206,7 @@ def upload_results_to_hf_dataset(
         summary_file: Path to the summary file
         dataset_name: Name of the HuggingFace dataset to upload to
         run_id: Unique run identifier (if None, will generate one)
+        token: HuggingFace token for authentication (if None, will use environment variables)
         logger: Logger instance
     Returns:
         The run_id used for the upload, None if upload failed
@@ -237,9 +239,6 @@ def upload_results_to_hf_dataset(
     logger.info(f"Uploading benchmark results to dataset '{dataset_name}' at path '{repo_path}'")
 
     try:
-        # Get the authentication token (prioritize specific token, fallback to HF_TOKEN)
-        token = os.getenv("TRANSFORMERS_CI_RESULTS_UPLOAD_TOKEN") or os.getenv("HF_TOKEN")
-
         # Upload all files in the output directory
         from pathlib import Path
 
@@ -357,6 +356,10 @@ def main():
         "--run-id", type=str, help="Custom run ID for organizing results (if not provided, will generate a unique ID)"
     )
 
+    parser.add_argument(
+        "--token", type=str, help="HuggingFace token for dataset uploads (if not provided, will use HF_TOKEN environment variable)"
+    )
+
     args = parser.parse_args()
 
     # Setup logging
@@ -440,6 +443,7 @@ def main():
                 summary_file=summary_file,
                 dataset_name=args.upload_to_hub,
                 run_id=effective_run_id,
+                token=args.token,
                 logger=logger,
             )
             if upload_run_id: