Skip to content

Commit

Permalink
distributed: balanced runs
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdidc committed Aug 16, 2023
1 parent b780a94 commit 99dba24
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions clip_benchmark/cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Console script for clip_benchmark."""
import argparse
import sys
import random
import json
import torch
import csv
Expand Down Expand Up @@ -130,6 +131,9 @@ def main_eval(base):
runs = product(models, datasets, languages)
if base.distributed:
local_rank, rank, world_size = world_info_from_env()
runs = list(runs)
# randomize runs so that runs are balanced across gpus
random.shuffle(runs)
runs = [r for i, r in enumerate(runs) if i % world_size == rank]
for (model, pretrained), (dataset), (language) in runs:
# We iterative over all possible model/dataset/languages
Expand Down

0 comments on commit 99dba24

Please sign in to comment.