-
Notifications
You must be signed in to change notification settings - Fork 96
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
non-deterministic matrix assembly for multiple domains #1002
Comments
This would only affect the |
Another option is to use another dict type that preserves insertion order, e.g.: @mochen4 can you try to use an OrderedDict here?
|
Using an Otherwise, you'd have to switch to an ordinary |
Using |
@mochen4, can you make a pull request that makes this 1-line change (also changing the Project.toml to add the DataStructures dependency)? |
The DataStructures dependency is already specified in Project.toml Line 11 in 632d695
So I simply added |
@mochen4 pointed out via email that Gridap's matrix assembly yields non-deterministic roundoff errors, e.g. the matrices from this tutorial change on the order of machine precision from run to run. This makes debugging harder, and is especially inconvenient if the Gridap outputs are fed into some calculation exhibiting chaos or instability (e.g. we noticed it in optimization problems exhibiting spontaneous symmetry breaking, which converge to a local optimum that is sensitively affected by tiny discrepancies).
@fverdugo wrote to explain:
and indeed the issue arises in problems involving multiple domains. Essentially,
Dict
iteration depends on the hashing algorithm, and Julia's default hashing algorithm for astruct
uses the pointer address (objectid
), which is effectively non-deterministic. Changing iteration order can change the floating-point roundoff errors of a sum.The solution is, in principle, simple — just implement a custom
hash
function (and==
) that is deterministic for any object that is used as aDict
key. Question: which data structures in Gridap need this?The text was updated successfully, but these errors were encountered: