-
Notifications
You must be signed in to change notification settings - Fork 178
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
fix: addressing indeterminate Map orderings in tests #220
Conversation
Signed-off-by: Kaiyao Ke <kaiyaok2@illinois.edu>
Signed-off-by: Kaiyao Ke <kaiyaok2@illinois.edu>
Unfortunately switching the label maps over to There are a few more tests which have issues when run under nondex, but I've not figured out the root cause of all of them yet. Some of them are due to a lack of label ordering in the evaluations which is straightforward to fix (and mostly is due to the |
Hi there, thanks for the response! |
Sure, but I'd prefer the code not to rely upon iteration order in the output infos, as it isn't an invariant guaranteed by the output info contract (and we had a bug in v4.0 and v4.1 due to issues where the regression code was depending on iteration order when it shouldn't have been). I ran nondex on an internal repo we use for validating Tribuo releases which has all the public Tribuo tests in a single project, and hit the errors you found as well as some others. This branch fixes some of the flakyness, but I've not had chance to run down all of it (Craigacp@d9e5825). There were some failures in the way that the single label tests were run, K-Means reproducibility test, and those in the ensemble export you found which haven't been fixed that way, which suggests there is a deeper bug or we're depending on label order when we shouldn't be. |
I updated a commit with a fix without switching to
Also I updated the solution to flakiness in |
|
I wonder if I understand your message correctly - is it undesirable to sort the keyset? |
The indices for both features and output dimensions are considered an internal implementation detail of a model, and we try pretty hard to not have them leak out of a model, even to other models within an ensemble. The feature ids are guaranteed (and documented) to be in the lexicographic order of the feature names, though even this might be worth reconsidering in a future version of Tribuo. There's no documented constraint on how the output ids are generated, and so anything that depends on them being generated in a specific order is a bug. Fixing the problem by adding a constraint on the ordering is going to make more bits of Tribuo depend on that ordering, rather than less, and that will make it harder to evolve the system in the future. |
Thanks for your clarification! I understand the problem now. |
Sorting inside After looking at the ONNX export of |
I agree that changes to ONNX shall be nontrivial, so I updated this pr to only include changes for |
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.
LGTM thanks.
Thanks for flagging the iteration order issues. I've got a fix for the ensemble export, and some label ordering flakiness in the other tests which I'll make a PR for shortly. |
No problem! Glad it works out |
* Fixed Flakiness Signed-off-by: Kaiyao Ke <kaiyaok2@illinois.edu> * Fixed Flakiness Signed-off-by: Kaiyao Ke <kaiyaok2@illinois.edu> * removed need for linkedhashmaps * removed print message * include only csvsaver changes * removed print message
Description
Using Nondex when running command
mvn edu.illinois:nondex-maven-plugin:1.1.2:nondex
in thetests
directory after installing all dependencies, several tests inCSVSaverWithMultiOutputsTest.java
andEnsembleExportTest.java
produce flaky results (nondeterministically pass or fail). The reason is that the outputs in the tests are dependent on iterators for hashmaps, which does not guarantee a fixed order by default. (From the Javadoc: "HashMap class makes no guarantees as to the order of the map; in particular, it does not guarantee that the order will remain constant over time.") For example, in the functionsave(Path csvPath, Dataset<T> dataset, Set<String> responseNames)
inCSVSaver.java
, the code is using the iterator defined forImmutableFeatureMap
that deals with aCollection
of values in a HashMap. Therefore, there is no guaranteed order for the entries inheaderLine[]
, which leads to possible test flakiness.To resolve the problem, I changed the code to construct a sorted
ArrayList
for all keys in the referenced HashMap to ensure determinate iteration order.Motivation
The change is necessary as related functionalities / tests may fail when, for example, the Java version upgrades in the future, or when the code is run in a different environment.
OCA
https://oca.opensource.oracle.com/api/v1/oca-requests/6710/documents/6730/download