# Accelerate - WeightedRandomSampler Dataloader

**URL:** <https://discuss.huggingface.co/t/accelerate-weightedrandomsampler-dataloader/92721>\
**Category:** Intermediate\
**Created:** [June 18, 2024, 8:02am UTC](https://discuss.huggingface.co/t/accelerate-weightedrandomsampler-dataloader/92721 "2024-06-18T08:02:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![FrsECM](https://avatars.discourse-cdn.com/v4/letter/f/7993a0/32.png) [@FrsECM](https://discuss.huggingface.co/u/FrsECM)\
**Post date:** [June 18, 2024, 8:02am UTC](https://discuss.huggingface.co/t/accelerate-weightedrandomsampler-dataloader/92721/1 "2024-06-18T08:02:02Z")

</div>

Hi !  
Like you mention in this post :  
[Accelerator .prepare() replaces custom DataLoader Sampler - 🤗Accelerate - Hugging Face Forums](https://discuss.huggingface.co/t/accelerator-prepare-replaces-custom-dataloader-sampler/43392)

When we use a custom sampler, it is used on downstream processes.

But today it works like that :

 ![image](https://us1.discourse-cdn.com/hellohellohello/original/3X/9/5/957b4fcf161a0809226f1fa3a18393dd74573295.png)  
Sampler will generate batches, and batches will be assigned to different processes depending on their indexes.

When we have a weighted sampler, It’s probable to get the same datarows in multiple batches. It means we can have the same data on multiple processes.

I would like to make sure, each process uses independant data…

**Is it currently possible ?**  
**If yes how ?**  
**If no, how should i implement it ?**

I created a script in order to reproduce the issue, it is here :  
[Dataloader WeightedRandomSampler + Distributed Training · Issue #2865 · huggingface/accelerate (github.com)](https://github.com/huggingface/accelerate/issues/2865)

Thanks for your help and feedback

---

<div class="post-metadata">

**Author:** ![FrsECM](https://avatars.discourse-cdn.com/v4/letter/f/7993a0/32.png) [@FrsECM](https://discuss.huggingface.co/u/FrsECM)\
**Post date:** [June 18, 2024, 8:03am UTC](https://discuss.huggingface.co/t/accelerate-weightedrandomsampler-dataloader/92721/2 "2024-06-18T08:03:15Z")

</div>

In the end, what i would like is more a behavior like that :  
 ![](https://us1.discourse-cdn.com/hellohellohello/original/3X/e/1/e1759389e0edfd0be9d7104f10cad07e81e4eb59.png)
