Add manual eviction support - #3
Conversation
| if reinsert: | ||
| r.sadd(f'{queue_name}-full', *reinsert) | ||
| if free: | ||
| r.sadd(f'{queue_name}-empty', *free) |
There was a problem hiding this comment.
idx_list is already random,
something like this should be enough
- r.sadd(f'{queue_name}-empty', *idx_list)
+
+ keep = int(config.reinsert_prob * len(idx_list))
+ r.sadd(f'{queue_name}-empty', *idx_list[keep:])
+ if keep > 0: r.sadd('{queue_name}-full', *idx_list[:keep])There was a problem hiding this comment.
- The randomness in
idx_listcomes from Redis SPOP. This guarantees the set of elements is random but the order they're returned in is often not random:
$ redis-cli
127.0.0.1:6379> SADD spop_test 1 2 3 4 5 6 7 8 9 10 11 12
(integer) 12
127.0.0.1:6379> SPOP spop_test 4
1) "7"
2) "8"
3) "9"
4) "11"
127.0.0.1:6379> SPOP spop_test 4
1) "3"
2) "6"
3) "10"
4) "12"
- This makes the number of elements reinserted constant instead of a binomial distribution, not sure if this distinction matters.
|
@YassineYousfi I looked at tianshou, RLlib, and stable-baselines3 and you're generally right: replay happens on the training side and not in the dataloader. I do still think putting reinsertion in gigashuffle is cleaner. The way we want to use it in |
|
I agree it's cleaner in gigashuffle |
|
I think the better way to do this is:
|
|
Agreed, that leaves it to the trainer to choose an eviction strategy |
| pass | ||
|
|
||
| def __iter__(self) -> Iterator[Buffer]: | ||
| def __iter__(self) -> Iterator[Buffer | tuple[Buffer, list[int]]]: |
There was a problem hiding this comment.
This changes the interface, ty in xx will complain on existing code
There was a problem hiding this comment.
I think it's reasonable to have Buffer always contain the indices.
|
lgtm besides always returning the indices (maybe as an attribute of the Buffer objects if that’s clean) |
I agree, this is cleaner and existing code shouldn't be affected (unless it iterates over the dictionary keys in some weird way). |
Adds
config.reinsert_probto have some probability of reinserting a sample into the buffer after being read. Set to0.0by default so it shouldn't affect existing code.This could be made to work with
fill_oncebut it's a lot uglier and I don't think anyone would use it.