Repository navigation
[Data] Add random() and uuid() expression - #59656
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a random() expression, which is a valuable addition. The core implementation for generating random numbers is solid, especially the seeding strategy for distributed execution. I've identified a few areas for improvement, primarily in the parsing of string expressions for random() and its tree representation. My review includes suggestions to fix a bug in argument handling, improve code consistency, and correct a formatting issue. The new RandomExpr class and the public random() factory function are well-designed and documented.
6c3ed95 to
e4f93d4
Compare
|
bugbot run |
f857644 to
2789a75
Compare
|
bugbot run |
1 similar comment
|
bugbot run |
ed1ce31 to
345355d
Compare
|
It seems like I have the same |
84fea5d to
8817016
Compare
94773c4 to
62736da
Compare
|
@goutamvenkat-anyscale How do you think about this PR? Do you the framework here (NullaryExpr) can be used for the monotonically_increasing_id()? #59290 Thanks! |
fcb4c48 to
f0002aa
Compare
f0002aa to
7bedce7
Compare
aslonnie
left a comment
There was a problem hiding this comment.
approval for doc change
dc3338a to
f750938
Compare
f750938 to
ffa8c3a
Compare
57f937d to
ce59336
Compare
|
Re
I think we want different UUID for each row (hence the original list-comp); so pa.repeat is not enough. Anyway, I have implemented a vectorized UUID generation using numpy (added test to confirm to the compatibility). I was thinking about Otherwise I think I have addressed all the comments. Let me know if there are more or if this can be approved+merged. Thanks for the review. |
|
@iamjustinhsu Need your approval for this PR |
ce59336 to
8da59fd
Compare
|
@iamjustinhsu Can I get your approval? 🙏 |
978efd0 to
bd20df3
Compare
d0c568d to
f6aa185
Compare
- break down SyntheticExpr into RandomExpr and UUIDExpr Signed-off-by: Kit Lee <[email protected]>
8a7fadb to
ee8bfb6
Compare
## Description Adding two new expressions: * `random()` for generating a column of uniform random number. * `uuid()` for generating UUID (a column of unique strings) `random()` accepts two arguments, related to reproducibility: * `seed`: a "base" random seed. Default is `None`. * `reseed_after_execution`: This is a flag that affects the random number generation across different iteration of `iter_batches` (i.e., across different epochs in the context of epochs). See also, ray-project#59528. It only matters when the `seed` is set. If False, each dataset execution will generate the same set of random number. If True, each dataset execution (i.e., training epoch) will give a new but reproducible set of random number. `uuid()` takes no argument. ## Related issues Related to ray-project#55275 Related to ray-project#59662 as well. I did this PR first...so probably I could use the same `RandomSeedConfig` in that PR. ## Additional information [Random seed business] The actual seed sequence used to initialize the random number generator is `[block_idx, task_idx, execution_idx, base_seed]`. The block idx is tracked by a counter (like in `monotonically_increasing_id()`). The task and execution indices are coming from `TaskContext` and `DataContext`, respectively. The way I used `execution_idx` is slightly different to what `FileShuffleConfig` is doing, but I think all these random seed business could be consolidated in the future (e.g., random_sample) [Independent visit functions] Following the discussion in ray-project#59290, there are separate `visit_uuid()` and `visit_random` for these expressions. Signed-off-by: Kit Lee <[email protected]>
## Description Adding two new expressions: * `random()` for generating a column of uniform random number. * `uuid()` for generating UUID (a column of unique strings) `random()` accepts two arguments, related to reproducibility: * `seed`: a "base" random seed. Default is `None`. * `reseed_after_execution`: This is a flag that affects the random number generation across different iteration of `iter_batches` (i.e., across different epochs in the context of epochs). See also, ray-project#59528. It only matters when the `seed` is set. If False, each dataset execution will generate the same set of random number. If True, each dataset execution (i.e., training epoch) will give a new but reproducible set of random number. `uuid()` takes no argument. ## Related issues Related to ray-project#55275 Related to ray-project#59662 as well. I did this PR first...so probably I could use the same `RandomSeedConfig` in that PR. ## Additional information [Random seed business] The actual seed sequence used to initialize the random number generator is `[block_idx, task_idx, execution_idx, base_seed]`. The block idx is tracked by a counter (like in `monotonically_increasing_id()`). The task and execution indices are coming from `TaskContext` and `DataContext`, respectively. The way I used `execution_idx` is slightly different to what `FileShuffleConfig` is doing, but I think all these random seed business could be consolidated in the future (e.g., random_sample) [Independent visit functions] Following the discussion in ray-project#59290, there are separate `visit_uuid()` and `visit_random` for these expressions. Signed-off-by: Kit Lee <[email protected]>

Description
Adding two new expressions:
random()for generating a column of uniform random number.uuid()for generating UUID (a column of unique strings)random()accepts two arguments, related to reproducibility:seed: a "base" random seed. Default isNone.reseed_after_execution: This is a flag that affects the random number generation across different iteration ofiter_batches(i.e., across different epochs in the context of epochs). See also, [Train] [Data] Add inter-execution file shuffling to enable deterministic multi-epoch training #59528. It only matters when theseedis set. If False, each dataset execution will generate the same set of random number. If True, each dataset execution (i.e., training epoch) will give a new but reproducible set of random number.uuid()takes no argument.Related issues
Related to #55275
Related to #59662 as well. I did this PR first...so probably I could use the same
RandomSeedConfigin that PR.Additional information
[Random seed business] The actual seed sequence used to initialize the random number generator is
[block_idx, task_idx, execution_idx, base_seed]. The block idx is tracked by a counter (like inmonotonically_increasing_id()). The task and execution indices are coming fromTaskContextandDataContext, respectively. The way I usedexecution_idxis slightly different to whatFileShuffleConfigis doing, but I think all these random seed business could be consolidated in the future (e.g., random_sample)[Independent visit functions] Following the discussion in #59290, there are separate
visit_uuid()andvisit_randomfor these expressions.