[synthetic-data] Add on-the-fly synthetic length-distribution dataset - #4275
[synthetic-data] Add on-the-fly synthetic length-distribution dataset#4275jinsooihm wants to merge 3 commits into
Conversation
Streaming data source for DP load-balancing and throughput experiments, generating random-token sequences whose lengths follow a configurable distribution. No dataset is written to disk. Components (torchtitan/components/data/synthetic.py): - LengthSpec: BucketLengthSpec (weighted buckets, default) and ParametricLengthSpec (uniform/normal/lognormal/zipf). - SyntheticLengthSource: infinite grain.IterDataset, per-rank seeded, chunk buffered for throughput, exact checkpoint-resume across chunk boundaries. - RandomTokenProcessor (random ids; MoE-representative) and ConstantTokenProcessor (np.full, no RNG; dense-only), sharing _should_drop / _split_next_token helpers. - Package exports and README section. scripts/preview_synthetic_lengths.py: inspect a distribution (percentiles, histogram, DP-balance simulation) for a seed without running training. Tests: tests/unit_tests/components/data/test_synthetic_data.py and tests/unit_tests/test_preview_synthetic_lengths.py (30 tests). ghstack-source-id: 799fbb1 Pull-Request: #4275
Streaming data source for DP load-balancing and throughput experiments, generating random-token sequences whose lengths follow a configurable distribution. No dataset is written to disk. Components (torchtitan/components/data/synthetic.py): - LengthSpec: BucketLengthSpec (weighted buckets, default) and ParametricLengthSpec (uniform/normal/lognormal/zipf). - SyntheticLengthSource: infinite grain.IterDataset, per-rank seeded, chunk buffered for throughput, exact checkpoint-resume across chunk boundaries. - RandomTokenProcessor (random ids; MoE-representative) and ConstantTokenProcessor (np.full, no RNG; dense-only), sharing _should_drop / _split_next_token helpers. - Package exports and README section. scripts/preview_synthetic_lengths.py: inspect a distribution (percentiles, histogram, DP-balance simulation) for a seed without running training. Tests: tests/unit_tests/components/data/test_synthetic_data.py and tests/unit_tests/test_preview_synthetic_lengths.py (30 tests). ghstack-source-id: 6b07fc7 Pull-Request: #4275
| ``` | ||
|
|
||
| Notes: | ||
| - Content is random and irrelevant for perf/load-balancing; only the length |
There was a problem hiding this comment.
For MoE load balance, it is
There was a problem hiding this comment.
Noob question, but is testing MoE on random tokens a fair way to test if token routing matters?
There was a problem hiding this comment.
No, I'm just saying that the note is not accurate
There was a problem hiding this comment.
Yes, I understand that. I am just curious about what kind of dataset one should use when doing perf comparisons on MoE.
|
|
||
| ## Synthetic length-distribution data (experiments) | ||
|
|
||
| For DP load-balancing and throughput experiments you often want sequences whose |
There was a problem hiding this comment.
Do we run this E2E? What if loss / grad norm explode?
There was a problem hiding this comment.
Hmm, my guess would be that if the tokens are random, then the loss / grad would converge to whatever random prediction gives, which should be a finite value?
There was a problem hiding this comment.
I think loss would be. Grad norm, I'm not sure
There was a problem hiding this comment.
This is what claude tells:
The gradient of cross-entropy w.r.t. the logits is always
Both
That bound is independent of the token/label and of vocab size — a random label gives the same
Everything downstream is just this bounded signal times the network's Jacobian. Normalization (RMSNorm) caps activation sizes and residual connections keep each layer's Jacobian ~O(1), so a bounded input stays bounded through backprop. And clip_grad_norm_(max_norm=1.0) caps the applied update at 1.0 regardless.

Stack from ghstack (oldest at bottom):
Streaming data source for DP load-balancing and throughput experiments,
generating random-token sequences whose lengths follow a configurable
distribution. No dataset is written to disk.
Example usage:
Another option is to use
ConstantTokenProcessorproducing same token for perhaps non-MoE models in which token routing does not matter.scripts/preview_synthetic_lengths.py: inspect a distribution (percentiles, histogram, DP-balance simulation) for a seed without running training.Tests: tests/unit_tests/components/data/test_synthetic_data.py and
tests/unit_tests/test_preview_synthetic_lengths.py (30 tests).