[Bug] run.py: LOCAL_RANK defaults to 1 instead of 0
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- python
- Domain
- distributed-systems
Research direction
Start in run.py around the LOCAL_RANK definition at line 36 and compare its fallback with the other distributed environment variables. Change the fallback to the identity value described in the issue, then verify that rank 0 computes the correct GPU slice when LOCAL_RANK is absent.
Written by the indexing model from the issue text.
Description
Summary
In run.py (confirmed on main @ 224943f), LOCAL_RANK defaults to 1:
RANK = int(os.environ.get('RANK', 0))
WORLD_SIZE = int(os.environ.get('WORLD_SIZE', 1))
LOCAL_WORLD_SIZE = int(os.environ.get("LOCAL_WORLD_SIZE", 1))
LOCAL_RANK = int(os.environ.get("LOCAL_RANK", 1)) # <-- should default to 0
https://github.com/open-compass/VLMEvalKit/blob/224943f9b5833f8dcb5b5040de64cfcdd59a3090/run.py#L36
Every other distributed variable defaults to its identity value (RANK=0, WORLD_SIZE=1, LOCAL_WORLD_SIZE=1). LOCAL_RANK defaulting to 1 is inconsistent and incorrect — a local rank starts at 0.
Impact
LOCAL_RANK is used to compute the per-process GPU slice:
DEVICE_START_IDX = GPU_PER_PROC * LOCAL_RANK
If a multi-process run sets LOCAL_WORLD_SIZE but does not export LOCAL_RANK for rank 0 (e.g. a custom launcher rather than torchrun), process 0 computes DEVICE_START_IDX = GPU_PER_PROC * 1 and binds to the wrong GPU slice; the highest-rank process can index past the GPU list. On a single-GPU machine there is no device index >= 1.
Fix
LOCAL_RANK = int(os.environ.get("LOCAL_RANK", 0))
Happy to open a one-line PR.
- Dominant language
- Python
- Stars
- 4.4k
- Forks
- 768
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 20
Contributor guide
No contributing guide indexed for this repository
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 open-compass/VLMEvalKit
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
open-compass/VLMEvalKit#1698 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
open-compass/VLMEvalKit#1697 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
open-compass/VLMEvalKit#1695 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
open-compass/VLMEvalKit#1690 · 3 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
open-compass/VLMEvalKit#1580 ·
All issues in open-compass/VLMEvalKit
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