[QUESTION]Splitting large document and bucketing #1090
Replies: 1 comment
-
|
Yes — this is something Megatron-LM can handle, but not in the same “out-of-the-box BucketIterator + automatic splitting” way that torchtext does. You need to understand how Megatron’s data pipeline is designed. 1. Does Megatron-LM support bucketization?✔ Yes — but indirectlyMegatron-LM achieves “bucket-like behavior” through:
However:
Instead, it builds a contiguous token dataset and then chunks it. 2. How Megatron actually batches dataMegatron training data pipeline is: So batching is based on:
NOT:
3. Is explicit bucketization supported?❌ Not natively like torchtextMegatron does not:
4. What Megatron uses instead✔ Token packing (closest equivalent)If enabled in dataset preprocessing:
This achieves:
5. Your use case: large documents + splittingYou said:
This is already how Megatron expects data to be structured. ✔ You should:Preprocess offline:
Then Megatron will:
6. Can Megatron do splitting automatically?❌ Not intelligentlyIt does NOT:
You must do this before training. 7. Why true bucketization is not usedBucketization (like torchtext) improves:
But Megatron prefers: ✔ global token streamingBecause it enables:
8. What about “length-aware batching”?Some Megatron variants can:
But this is:
9. Recommended approach (best practice)For your case: ✔ Step 1: split documents offlineExample:
✔ Step 2: shuffle chunks globally
✔ Step 3: feed into Megatron as token streamLet Megatron handle:
10. Key distinction
11. Bottom line
If this answer helped or pointed you in the right direction, I'd appreciate it if you could mark it as the accepted answer so it's easier for others with the same issue to find. Also, if you found my contribution useful, I'd appreciate it if you could check out my GitHub profile, follow me, and star any repositories you find interesting. GitHub: https://github.com/Advait251206 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I asked this question in the discussion section but did not receive any response so asking here with a little bit more details. I am trying to figure out if bucketization is done (or can be done) for model training. By "bucketization" I am referring to batching based on similar sequence length (https://torchtext.readthedocs.io/en/latest/data.html#bucketiterator).. The motivation is that I have documents with very large text and I want pick a splitting schema (which may create a lot of samples with small number of tokens and bucketize them). That brings me to the second question which is - is splitting supported in Megatron?
Any answer would be much appreciated - Thanks.
Beta Was this translation helpful? Give feedback.
All reactions