ChrisHegarty commented on PR #12727:
URL: https://github.com/apache/lucene/pull/12727#issuecomment-1783913908

   Hi @benwtrent I think that this is fine - LGTM, just dropping a few small 
comments / questions.
   
   
   I grabbed and modified your test, and was able to repo this on both my Linux 
and Mac. Here's what I did.
   
   ```
   diff --git 
a/lucene/core/src/test/org/apache/lucene/internal/vectorization/TestVectorUtilSupport.java
 
b/lucene/core/src/test/org/apache/lucene/internal/vectorization/TestVectorUtilSupport.java
   index 9fe5ddd0e2b..e0fd056ce33 100644
   --- 
a/lucene/core/src/test/org/apache/lucene/internal/vectorization/TestVectorUtilSupport.java
   +++ 
b/lucene/core/src/test/org/apache/lucene/internal/vectorization/TestVectorUtilSupport.java
   @@ -104,4 +104,25 @@ public class TestVectorUtilSupport extends 
BaseVectorizationTestCase {
            func.applyAsInt(LUCENE_PROVIDER.getVectorUtilSupport()),
            func.applyAsInt(PANAMA_PROVIDER.getVectorUtilSupport()));
      }
   +
   +  public void testExtremeNumericsCosine() {
   +    float[] v1 = new float[1536];
   +    float[] v2 = new float[1536];
   +    float[] v3 = new float[1536];
   +    for (int i = 0; i <1536; i++) {
   +      v1[i] = -0.888888f;
   +      v2[i] = 0.888888f;
   +      v3[i] = -0.777777f;
   +    }
   +    float v = (1 + LUCENE_PROVIDER.getVectorUtilSupport().cosine(v1, v3)) / 
2;
   +    assertTrue("expected >=0 got:" + v,  v >= 0);
   +    v = (1 + PANAMA_PROVIDER.getVectorUtilSupport().cosine(v1, v3)) / 2;
   +    assertTrue("expected >=0 got:" + v,  v >= 0);
   +
   +    v = (1 + LUCENE_PROVIDER.getVectorUtilSupport().cosine(v2, v3)) / 2;
   +    assertTrue("expected >=0 got:" + v,  v >= 0);
   +    v = (1 + PANAMA_PROVIDER.getVectorUtilSupport().cosine(v2, v3)) / 2;
   +    assertTrue("expected >=0 got:" + v,  v >= 0);
   +  }
    }
   ```
   
   ```
   davekim$ env | grep -i java
   RUNTIME_JAVA_HOME=/home/chegar/binaries/jdk-21
   JAVA_HOME=/home/chegar/binaries/jdk-19.0.2/
   
   davekim$ export CI=true; ./gradlew :lucene:core:test --tests 
"org.apache.lucene.internal.vectorization.TestVectorUtilSupport.testExtremeNumericsCosine"
   ```
   
   It fails reliably on the final assert.
   
   ```
   org.apache.lucene.internal.vectorization.TestVectorUtilSupport > 
testExtremeNumericsCosine {p0=64 seed=[955C5CC916EEAA95:C5EFC08B75B72D11]} 
FAILED
       java.lang.AssertionError: expected >=0 got:-1.7881393E-7
           at 
__randomizedtesting.SeedInfo.seed([955C5CC916EEAA95:C5EFC08B75B72D11]:0)
           at org.junit.Assert.fail(Assert.java:89)
           at org.junit.Assert.assertTrue(Assert.java:42)
           at 
org.apache.lucene.internal.vectorization.TestVectorUtilSupport.testExtremeNumericsCosine(TestVectorUtilSupport.java:125)
   ```
   
   Maybe we could go with a variant of this, but as you had it in 
TestVectorUtil - testing the outer similarity which will pick different 
providers depending on the environment - which is fine.  I think we just need 
the v2 v3 comparison?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to