Created
July 4, 2024 00:57
-
-
Save richardliaw/d7503f02cc76ec97ea8e76a2e9e6358a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import ray.data | |
class DataGenerator: | |
def __init__(self, permute_config): | |
device = torch.device("cuda") | |
self.model = Model().to(device) | |
self.config = permute_config | |
def __call__(self, input): | |
for test_input in self.permute(permute_config, input): | |
yield self.model(input) | |
ds = ray.data.read_json("s3://path_to_bucket/user_prompts.json") | |
ds.map_batches(DataGenerator, num_gpus=1, concurrency=100) # run on 100 GPUs | |
ds.write_json("s3://path_to_bucket/generated_prompts.json") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment