[feature request] A more flexible `free_memory` function
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- python
- Domain
- machine-learning
Research direction
Start with src/accelerate/accelerator.py around lines 1788-1799 and read the existing free_memory implementation and its handling of Accelerator internals. Define the behavior needed for repeatedly preparing and unloading custom cached objects, then verify that the proposed interface supports the example loop without accessing internal objects individually.
Written by the indexing model from the issue text.
Description
After looking at the existing issues and PRs, I'm opening this feature request since I couldn't find my use case.
https://github.com/huggingface/accelerate/blob/7889ba6b6dd094e72fa222194146a40426fb3d5a/src/accelerate/accelerator.py#L1788-L1799
- In my case, I'm using a custom cache system instead of regular dataloaders and I need to load and unload the same objects multiple times in the
Acceleratorfor each iteration to free up memory. For now, I need to access the different internal objects of theAcceleratorclass individually. This could happen in different non-standard training loop (e.g. reloading a model and corresponding optimizers, ...). - It only needs a quick modification of the
free_memoryfunction. I'm not sure how you would implement that to be coherent with the whole library though. - This feature could be used as followed:
# load cache
# prepare it with the Accelerator
for iteration in range(nb_iterations):
# take random batch from cache
# Forward pass
if iteration % reload_frequency == 0:
# unload the cache from the Accelerator to free up memory
# load new cache
# prepare it with the Accelerator
Thank you for this library by the way. It makes things much easier for everyone!
- Dominant language
- Python
- Stars
- 9.9k
- Forks
- 1.6k
- Avg merge
- 20h 23m
- Merged PRs (30d)
- 12
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from huggingface/accelerate
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
huggingface/accelerate#4511 ·
Maintainers usually reply within 1 day
-
BatchSamplerShard padding mutates retained sampler batches and changes original loader samplesPossibly taken @davrens101 claimed this 3 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
huggingface/accelerate#4505 ·
Maintainers usually reply within 1 day
-
accelerator.reduce(tensor, "mean") fails on integer tensors when more than one process is usedPossibly taken @MaiAditya claimed this 12 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
huggingface/accelerate#4469 ·
Maintainers usually reply within 1 day
-
merge_fsdp_weights with remove_checkpoint_dir=True deletes the merged model when output_path is inside checkpoint_dirPossibly taken @assass1nlike claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 25/100
huggingface/accelerate#4514 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
huggingface/accelerate#4510 ·
Maintainers usually reply within 1 day
All issues in huggingface/accelerate
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
bytedance/agentkit-samples#277 ·
-
ai-driven-fuzzing bug claude Minor
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 2 days
-
channels:edit check:passed
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
[Bug] The blue-green mitigation strategy lists catalog names and views before the source tablesOpen
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
aws-samples/sample-aws-genai-db-modernizer#2097 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day