Skip to content

During multi-gpus training, each card will execute the cache text embedding operation once? #4089

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pixeli99 opened this issue Jul 14, 2023 · 8 comments
Labels
stale Issues that haven't received updates

Comments

@pixeli99
Copy link

pixeli99 commented Jul 14, 2023

text_encoders = [text_encoder_one, text_encoder_two]
tokenizers = [tokenizer_one, tokenizer_two]
train_dataset = get_train_dataset(args, accelerator)
compute_embeddings_fn = functools.partial(
    compute_embeddings,
    text_encoders=text_encoders,
    tokenizers=tokenizers,
    proportion_empty_prompts=args.proportion_empty_prompts,
)
with accelerator.main_process_first():
    train_dataset = train_dataset.map(compute_embeddings_fn, batched=True)

Each card will execute the above code during training, which will occupy too much disk space. Is this unreasonable? Or is it possible that I have misunderstood because currently, a fill50k training requires 15*8GB of storage space when using 8 cards.

@patrickvonplaten
Copy link
Contributor

cc @williamberman

@williamberman
Copy link
Contributor

Sorry, I'm not sure which training script this code is in? @pixeli99

@pixeli99
Copy link
Author

pixeli99 commented Jul 18, 2023

Sorry, I'm not sure which training script this code is in? @pixeli99

hi, @williamberman
Sorry for my late reply. You can take a look here

text_encoders = [text_encoder_one, text_encoder_two]

My question is whether this code can be selectively executed. If I have to cache these embeddings, it will consume approximately 1TB of my hard drive space, and my dataset size is 500K.

Whether this consumption is normal, and I find that it seems that every GPU will execute this cache, which is very strange. Of course, it may be that I understand it incorrectly

@williamberman
Copy link
Contributor

williamberman commented Jul 18, 2023

Ah yes understood, unfortunately I as well am not really familiar with the semantics here of what datasets and accelerate are actually doing. See some of my questions here #4038 (comment)

@sayakpaul probably understands better

@pixeli99
Copy link
Author

image
Yes, it seems that every card will perform cache operations. Did I misunderstand?

@sayakpaul
Copy link
Member

There's an answer here by @lhoestq: #4038 (comment)

Also ccing @muellerzr for additional insights in case.

@williamberman
Copy link
Contributor

Ah yes, super helpful @pixeli99 ! So @sayakpaul I believe if you follow up on my comment here #4038 (comment) it should fix this. It looks like it's re doing the same computation on all processes and re-caching the results. Manually telling datasets a hash key will fix this :)

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.

@github-actions github-actions bot added the stale Issues that haven't received updates label Aug 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Issues that haven't received updates
Projects
None yet
Development

No branches or pull requests

4 participants