-
Notifications
You must be signed in to change notification settings - Fork 0
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 fix galsim random seeding again #28
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain how this fixes the seeding bug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
GalSim uses a different random number generator for each object being rendered. This is so the stamp rendering can be parallelized over multiple processes deterministically. The random seed for each object is sequential based on the initial random seed (
first
here).The problem that Sid was running into was that he was seeding different exposures with not very different random seeds. They were chosen from a set of integers that were fairly small. <32,000 maybe? I'm not sure exactly. But not nearly enough to make the sequences of seed for each exposure be disjoint from the sequences for any other exposure.
This fix (and the similar one in GalSim here) updates the given random seed to map onto some other value in [1,2^64). This essentially guarantees that the sequence of seeds that are used for each object in the exposure will be unique relative to any other exposure. Or at least the probability that they aren't is down at 1/2^64, rather than 1/2^15.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds reasonable, but I think there might be something else going on in addition to whatever this is fixing.
The problem was way more severe than 1/2^15. Essentially the exact series of rotation values were used for objects in all simulated tiles. There seem to be a small fraction that mismatched between the lists, which is odd in itself.
For example there were 31281722 entries in the catalog I had from a large set of simulated tiles, but only 93233 unique rotation values. And when matt looked at the catalogs, most of them were in the same sequence, in order, for different images.
This is almost like the same initial seed is being used for each run of the code (although the claim is that this is not true). If something like that is going on, I think the above would not fix it, because this
first = galsim.BaseDeviate(first).raw()
would be going from the same initial state.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not definitively claiming that this is the only error. But it is a bug that we fixed in GalSim two years ago, which wasn't ported over to montara. It's possible there is something else wrong as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think this is likely the bug. The truth files record every time an object is drawn across all exposures and bands. The fact that the rotation values are only unique for a subset is the correct result.
Instead the issue is that the unique values end up repeated across different tiles. This happens because of the small seeds as Mike points out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My feeling is there is another issue as well, but we should go forward with this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. My plan is to run some code at BNL to see what this fixes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the things that didn't make sense to me has been cleared up: I didn't realize the same object was in the truth catalog Nepoch times, which resulted in more duplicate rotation values than I would have predicted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering about that, but hadn't thought about nepochs (only bands). Glad that is worked out!