ACCELERATE_BYPASS_DEVICE_MAP is the only boolean env flag read case-sensitively, so =True is silently ignored
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 85/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- machine-learning
Research direction
Start in src/accelerate/accelerator.py at the three ACCELERATE_BYPASS_DEVICE_MAP reads identified at lines 1475, 1816, and 1890, and compare them with the sibling boolean flags that lowercase values. Done means True and TRUE behave like true at all three sites without changing the behavior of values accepted today.
Written by the indexing model from the issue text.
Description
Describe the bug
ACCELERATE_BYPASS_DEVICE_MAP is the only boolean environment flag in accelerate that is read case-sensitively, so setting it to True silently does nothing while the identical spelling works for every sibling flag.
All three read sites in src/accelerate/accelerator.py compare without .lower():
# accelerator.py:1475, 1816, 1890
os.environ.get("ACCELERATE_BYPASS_DEVICE_MAP", "false") != "true"
Every other boolean flag lowercases first. Sweeping src/accelerate for boolean env comparisons:
| parsing | flags |
|---|---|
.lower() == "true" |
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_PARAMS, PARALLELISM_CONFIG_SP_SEQ_LENGTH_IS_VARIABLE |
no .lower() |
ACCELERATE_BYPASS_DEVICE_MAP |
Ten of eleven are case-insensitive. The eleventh is the escape hatch.
Reproduction
The expressions as written in accelerator.py, side by side:
def bypass_active(v): # accelerator.py:1475 / 1816 / 1890
return not (v != "true")
def fsdp_active(v): # accelerator.py:381 and 9 sibling sites
return v.lower() == "true"
value BYPASS_DEVICE_MAP USE_FSDP (sibling)
'true' True True
'True' False True
'TRUE' False True
Why it matters
The variable is an escape hatch, and both of the things it guards fail quietly when it is ignored:
accelerator.py:1475raisesValueError("You can't train a model that has been loaded with device_map='auto' in any distributed mode. ..."). A user who setsACCELERATE_BYPASS_DEVICE_MAP=Truestill gets the exception, and the error text does not mention the variable, so there is nothing to suggest the value was the problem.accelerator.py:1890selects DDPdevice_ids/output_device. Ignored here, the process silently takes the non-bypass branch.
The variable is undocumented, so it is learned from issues and discussions where capitalisation is not consistent, and True is the spelling a Python user reaches for first. It is also the spelling that works for ACCELERATE_USE_FSDP in the same file, which makes the inconsistency actively misleading rather than merely strict.
Expected behavior
ACCELERATE_BYPASS_DEVICE_MAP should be read the same way as its ten siblings. Adding .lower() at the three sites only widens acceptance to True and TRUE, so no value that works today changes meaning.
A related question, deliberately kept separate
None of these eleven flags accept 1, yes, or on, even though str_to_bool in utils/environment.py is the library's own documented truth parser and accepts all of them. Routing the flags through str_to_bool would make the whole family consistent, but that is a larger change with a wider blast radius, so I have not folded it in here. Happy to open it separately if it is wanted.
Checked before filing
Searched the tracker, issues and pull requests, open and closed, for ACCELERATE_BYPASS_DEVICE_MAP and BYPASS_DEVICE_MAP; nothing found. Present on main at f13f7c1 (v1.16.0dev), all three sites.
I have the one-line fix ready and am happy to open the PR if you would like it.
- Dominant language
- Python
- Stars
- 9.9k
- Forks
- 1.5k
- Avg merge
- 4d 8h
- Merged PRs (30d)
- 21
Contributor 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 84/100
huggingface/accelerate#4297 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
huggingface/accelerate#4280 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
huggingface/accelerate#4269 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
huggingface/accelerate#4257 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 78/100
huggingface/accelerate#4295 ·
All issues in huggingface/accelerate
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100