• Sayak Paul's avatar
    [Core] add "balanced" `device_map` support to pipelines (#6857) · 3e4a6bd2
    Sayak Paul authored
    
    
    * get device <-> component mapping when using multiple gpus.
    
    * condition the device_map bits.
    
    * relax condition
    
    * device_map progress.
    
    * device_map enhancement
    
    * some cleaning up and debugging
    
    * Apply suggestions from code review
    Co-authored-by: default avatarMarc Sun <57196510+SunMarc@users.noreply.github.com>
    
    * incorporate suggestions from PR.
    
    * remove multi-gpu condition for now.
    
    * guard check the component -> device mapping
    
    * fix: device_memory variable
    
    * dispatching transformers model to have force_hooks=True
    
    * better guarding for transformers device_map
    
    * introduce support balanced_low_memory and balanced_ultra_low_memory.
    
    * remove device_map patch.
    
    * fix: intermediate variable scoping.
    
    * fix: condition in cpu offload.
    
    * fix: flax class restrictions.
    
    * remove modifications from cpu_offload and model_offload
    
    * incorporate changes.
    
    * add a simple forward pass test
    
    * add: torch_device in get_inputs()
    
    * add: tests
    
    * remove print
    
    * safe-guard to(), model offloading and cpu offloading when balanced is used as a device_map.
    
    * style
    
    * remove .
    
    * safeguard device_map with more checks and remove invalid device_mapping strategues.
    
    * make  a class attribute and adjust tests accordingly.
    
    * fix device_map check
    
    * fix test
    
    * adjust comment
    
    * fix: device_map attribute
    
    * fix: dispatching.
    
    * max_memory test for pipeline
    
    * version guard the tests
    
    * fix guard.
    
    * address review feedback.
    
    * reset_device_map method.
    
    * add: test for reset_hf_device_map
    
    * fix a couple things.
    
    * add reset_device_map() in the error message.
    
    * add tests for checking reset_device_map doesn't have unintended consequences.
    
    * fix reset_device_map and offloading tests.
    
    * create _get_final_device_map utility.
    
    * hf_device_map -> _hf_device_map
    
    * add documentation
    
    * add notes suggested by Marc.
    
    * styling.
    
    * Apply suggestions from code review
    Co-authored-by: default avatarSteven Liu <59462357+stevhliu@users.noreply.github.com>
    Co-authored-by: default avatarPedro Cuenca <pedro@huggingface.co>
    
    * move updates within gpu condition.
    
    * other docs related things
    
    * note on ignore a device not specified in .
    
    * provide a suggestion if device mapping errors out.
    
    * fix: typo.
    
    * _hf_device_map -> hf_device_map
    
    * Empty-Commit
    
    * add: example hf_device_map.
    
    ---------
    Co-authored-by: default avatarMarc Sun <57196510+SunMarc@users.noreply.github.com>
    Co-authored-by: default avatarSteven Liu <59462357+stevhliu@users.noreply.github.com>
    Co-authored-by: default avatarPedro Cuenca <pedro@huggingface.co>
    3e4a6bd2
testing_utils.py 35.7 KB