Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Inconsistent behavior of 'neighbor_sampler' when setting a random seed for PyTorch #66

Open
shun-zheng opened this issue Apr 27, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@shun-zheng
Copy link

When testing with the following codes

torch.manual_seed(1234)
start = torch.tensor([0, 1])
cumdeg = torch.tensor([0, 3, 7])
neighbor_sampler(start, cumdeg, size=2)

we cannot get consistent bebaviors with multiple runs as expected in test_sampler.py.

The reason for such inconsistence is that the sampling code in cpu has two sampling branches:

if (size < 0.7 * float(num_neighbors)) {
      ......
      int64_t sample = rand() % num_neighbors;
      ......
    } else {
      auto sample = torch::randperm(num_neighbors, start.options());
      ......
}

The upper branch utilizes the rand function provided by C++, which causes this inconsistence.

Maybe we should leverage similar functions provided by PyTorch, which can be controlled by 'torch.manual_seed()'?

@github-actions
Copy link

This issue had no activity for 6 months. It will be closed in 2 weeks unless there is some new activity. Is this issue already resolved?

@github-actions github-actions bot added the stale label Sep 16, 2021
@rusty1s rusty1s added enhancement New feature or request and removed stale labels Sep 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants