Read ACCELERATE_BYPASS_DEVICE_MAP case-insensitively, like every other boolean flag - #4241
Open
Sreekant13 wants to merge 1 commit into
Open
Read ACCELERATE_BYPASS_DEVICE_MAP case-insensitively, like every other boolean flag#4241Sreekant13 wants to merge 1 commit into
Sreekant13 wants to merge 1 commit into
Conversation
…r flag All three read sites compared the raw value against "true", so ACCELERATE_BYPASS_DEVICE_MAP=True silently did nothing. It is the only one of eleven boolean environment flags in the library read this way: USE_FSDP, USE_DEEPSPEED, USE_MEGATRON_LM, USE_SAGEMAKER, USE_PARALLELISM_CONFIG, ALLOW_CP_STANDALONE, DEBUG_MODE, DEEPSPEED_ZERO3_SAVE_16BIT_MODEL, FSDP_OFFLOAD_PARAMS and PARALLELISM_CONFIG_SP_SEQ_LENGTH_IS_VARIABLE all lowercase first. That inconsistency is what makes it a trap rather than merely strict: True is the spelling a Python user reaches for, and it works for ACCELERATE_USE_FSDP in this same file. When it is ignored the user still hits the device_map=auto ValueError, whose text does not mention the variable, so nothing points at the value being the problem; the DDP device_ids branch at 1890 silently takes the non-bypass path for the same reason. Adding .lower() only widens acceptance to True and TRUE, so no value that works today changes meaning. Fixes huggingface#4240.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Reads
ACCELERATE_BYPASS_DEVICE_MAPcase-insensitively, the way every other boolean environment flag in the library is read.All three sites compared the raw value, so
ACCELERATE_BYPASS_DEVICE_MAP=Truesilently did nothing:It is the only one of eleven such flags read this way.
ACCELERATE_USE_FSDP,ACCELERATE_USE_DEEPSPEED,ACCELERATE_USE_MEGATRON_LM,ACCELERATE_USE_SAGEMAKER,ACCELERATE_USE_PARALLELISM_CONFIG,ACCELERATE_ALLOW_CP_STANDALONE,ACCELERATE_DEBUG_MODE,ACCELERATE_DEEPSPEED_ZERO3_SAVE_16BIT_MODEL,FSDP_OFFLOAD_PARAMSandPARALLELISM_CONFIG_SP_SEQ_LENGTH_IS_VARIABLEall.lower()first.That inconsistency is what makes it a trap rather than merely strict.
Trueis the spelling a Python user reaches for, and it works for the flag two hundred lines up. When it is ignored the user still hits thedevice_map='auto'ValueError, whose text does not mention the variable, so nothing points at the value as the cause; the DDPdevice_idsbranch at 1890 takes the non-bypass path for the same reason.Adding
.lower()only widens acceptance toTrueandTRUE, so no value that works today changes meaning.Fixes #4240
Before submitting
On that last box, deliberately unticked: the three call sites need a distributed
Acceleratorand a model loaded withdevice_map='auto', so a faithful test is heavier than the change. Happy to add one if you would rather have it, and equally happy to route these flags throughstr_to_boolinstead, which would also make them accept1,yesandonlike the library's own documented parser does. I kept that out of here because it is a wider blast radius than a bug fix.Who can review?
Anyone in the community is free to review the PR once the tests have passed.