Kotlin / Kotlin/multik

Flaky: NativeLinAlg.dot matrix-vector ComplexDouble returns wrong result on Linux

Open
#284 0 comments 0 reactions 0 assignees View on GitHub
ai-generated bug
Dominant language
Kotlin
Stars
734
Forks
51
Avg merge
9h 52m
Merged PRs (30d)
6

Description

### Multik version

0.3.0

### Module

multik-openblas

### Platform

JVM

### Operating System

Linux

### Description

`NativeLinAlg.dot` for matrix-vector multiplication with `ComplexDouble` produces incorrect results intermittently on Linux (Ubuntu 22.04.5 LTS, gcc-12 12.3.0, JDK 21 Temurin). The test uses a 2x2 ComplexDouble matrix and a 2-element vector with exact integer expected values. Failed in 2 out of 4 CI runs.

### Reproducer

```kotlin
val matrix = mk.ndarray(
mk[mk[ComplexDouble(1, 2), ComplexDouble(3, 4)],
mk[ComplexDouble(5, 6), ComplexDouble(7, 8)]]
)
val vector = mk.ndarray(mk[ComplexDouble(1, 0), ComplexDouble(0, 1)])

// [1+2i, 3+4i] . [1+0i, 0+1i] = (1+2i)*1 + (3+4i)*i = 1+2i + 3i-4 = -3+5i
// [5+6i, 7+8i] . [1+0i, 0+1i] = (5+6i)*1 + (7+8i)*i = 5+6i + 7i-8 = -3+13i
val expected = mk.ndarray(mk[ComplexDouble(-3, 5), ComplexDouble(-3, 13)])

val actual = NativeLinAlg.dot(matrix, vector)
assertComplexFloatingNDArray(expected, actual) // Fails intermittently
```

### Additional information

```text
Flaky — failed in 2/4 CI runs.
AssertionFailedError at NativeLinAlgTest.kt:256.
CI runs: 22511673326, 22511741037.
Environment: Ubuntu 22.04.5 LTS, gcc-12 (12.3.0), g++-12, JDK 21 Temurin, x86_64.
```

Contributor guide

Open the contributing guide

Research direction

Start with the failing case around NativeLinAlgTest.kt:256 and reproduce the 2x2 ComplexDouble matrix-vector call described in the issue on Linux. Trace NativeLinAlg.dot through the multik-openblas module and compare intermittent results with the expected [-3+5i, -3+13i]. Done means the test is deterministic and passes in the reported CI environment.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin, linux
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.