Fix multi-node append duplicating existing chunks in index.json - #866
Open
eeshsaxena wants to merge 1 commit into
Open
Fix multi-node append duplicating existing chunks in index.json#866eeshsaxena wants to merge 1 commit into
eeshsaxena wants to merge 1 commit into
Conversation
With optimize(mode="append") and num_nodes > 1, every node folded the
existing index into its own {node_rank}-index.json. The final cross-node
merge then concatenated all of those, so the existing chunks ended up in the
result once per node: existing [A, B] with new [C] and [D] across two nodes
came out as [A, B, C, A, B, D] instead of [A, B, C, D].
Add the existing index only once. For a single node it still goes in at the
node-level merge as before. For multiple nodes the per-node merges now carry
only their own new chunks, and the existing index is folded in at the final
merge that combines the per-node files.
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.
Fixes #865.
When you run
optimize(mode="append")across more than one node, the existing dataset chunks end up repeated once per node in the finalindex.json.The cause is in the two-stage merge. Each node calls
_merge_no_wait(node_rank, existing_index)in_done, and_merge_no_waitprependsexisting_index["chunks"]to that node's{node_rank}-index.json. So every node's index file already contains the existing chunks. The last node then merges all of those per-node files together, and the existing chunks come along once for each node:The fix adds the existing index only once. The single-node path is unchanged: it still folds the existing index in at the node-level merge. For multiple nodes, the per-node merges now carry only their own new chunks, and the existing index is folded in at the final cross-node merge instead:
I added a test in
tests/streaming/test_writer.pythat walks both patterns: it shows the old per-node folding produces[A, B, C, A, B, D], and the new final-merge folding produces[A, B, C, D]. It passes locally.