Skip to content

Conversation

ZeguanXiao
Copy link

What does this PR do?

Fixes #139

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Have you gone through the contributions guide?
  • Are your changes documented? Read documentation guidelines here.

g = torch.Generator()
rank = torch.distributed.get_rank() if torch.distributed.is_initialized() else 0
seed = int(torch.empty((), dtype=torch.int64).random_().item() + rank)
g.manual_seed(seed)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be better to use the seed from the experiment config here, rather than
int(torch.empty((), dtype=torch.int64).random_().item() to avoid introducing randomness uncontrolled by the seed.

can you try to see if you can make the experiment's cfg.seed available to this dataset class and then use seed = exp_seed + rank here?

Copy link
Collaborator

@molereddy molereddy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR! Please see comment

@ZeguanXiao
Copy link
Author

Thanks for the feedback! I've updated the PR accordingly. Please let me know if there are any further adjustments required.

@molereddy
Copy link
Collaborator

Please fix the lint errors!

Copy link
Collaborator

@molereddy molereddy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not ideal to set the seed at the exact example level. This would mean we select the same retain example index sequences even if we are using a different dataset.

Since the point is that each rank must get a different seed, imo it is better to get the rank in the global seed function: https://github.com/locuslab/open-unlearning/blob/main/src/trainer/utils.py#L8

Let me know if you see any issues.

cc @Dornavineeth

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Same retain samples across ranks

2 participants