Created
July 4, 2024 00:55
-
-
Save richardliaw/d686c7c37877e0beeb42b6ce0e73a6ad to your computer and use it in GitHub Desktop.
This file contains 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 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("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