Skip to content

[bug fix] Always return one split_dict shard per DP rank - #102

Open
sfc-gh-sbekman wants to merge 3 commits into
mainfrom
stas/adversarial-split-dict-chunk
Open

[bug fix] Always return one split_dict shard per DP rank#102
sfc-gh-sbekman wants to merge 3 commits into
mainfrom
stas/adversarial-split-dict-chunk

Conversation

@sfc-gh-sbekman

Copy link
Copy Markdown
Collaborator

(also removes an accidentally committed PR_DESCRIPTION.md in one of my previous PRs)

split_dict / _split_value used torch.chunk, which can return fewer than num_chunks tensors (for example B=6 at dp=4 → 3 chunks of 2). Indexing the missing chunk is IndexError and /forward-backward 500s. The same helper splits GAS microbatches on the worker.

Use torch.tensor_split so there is always one shard per rank when B >= n. Rows are conserved. B < n still raises ValueError.

Testing

CPU in this clone (PYTHONPATH = checkout): tests/common/test_split_dict.py failed on main (IndexError at B=6 n=4), then 2 passed after the fix. Neighbor tests/common/test_finalize_fwd_bwd_metrics.py, tests/common/test_prune_checkpoint_dirs.py, and tests/sft/test_sft_edge_cases.py::TestGasMicrobatchList passed (10 + 2).

Signed-off-by: Stas Bekman <stas.bekman@snowflake.com>
Signed-off-by: Stas Bekman <stas.bekman@snowflake.com>
Signed-off-by: Stas Bekman <stas.bekman@snowflake.com>
@sfc-gh-sbekman
sfc-gh-sbekman enabled auto-merge (squash) September 1, 2026 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant