JuliaLang / LinearAlgebra.jl

Julia Linear Algebra standard library
Other
17 stars 4 forks source link

[CI] Doctests in `LinearAlgebra` depend on the CPU #1094

Closed giordano closed 1 month ago

giordano commented 1 month ago

We've got a new CI runner, which has probably a different CPU than the rest of the fleet, and here some LinearAlgebra doctests are failing because of a small differences of the results: https://buildkite.com/julialang/julia-master/builds/40579#01925a0d-05aa-4e4f-9490-52ead541ba20/799-865

┌ Error: doctest failure in /cache/build/builder-amdci4-1/julialang/julia-master/usr/share/julia/stdlib/v1.12/LinearAlgebra/src/hessenberg.jl
│ 
│ ```jldoctest
│ julia> A = [4. 9. 7.; 4. 4. 1.; 4. 3. 2.]
│ 3×3 Matrix{Float64}:
│  4.0  9.0  7.0
│  4.0  4.0  1.0
│  4.0  3.0  2.0
│ 
│ julia> F = hessenberg(A)
│ Hessenberg{Float64, UpperHessenberg{Float64, Matrix{Float64}}, Matrix{Float64}, Vector{Float64}, Bool}
│ Q factor: 3×3 LinearAlgebra.HessenbergQ{Float64, Matrix{Float64}, Vector{Float64}, false}
│ H factor:
│ 3×3 UpperHessenberg{Float64, Matrix{Float64}}:
│   4.0      -11.3137       -1.41421
│  -5.65685    5.0           2.0
│    ⋅        -8.88178e-16   1.0
│ 
│ julia> F.Q * F.H * F.Q'
│ 3×3 Matrix{Float64}:
│  4.0  9.0  7.0
│  4.0  4.0  1.0
│  4.0  3.0  2.0
│ 
│ julia> q, h = F; # destructuring via iteration
│ 
│ julia> q == F.Q && h == F.H
│ true
│ ```
│ 
│ Subexpression:
│ 
│ F = hessenberg(A)
│ 
│ Evaluated output:
│ 
│ Hessenberg{Float64, UpperHessenberg{Float64, Matrix{Float64}}, Matrix{Float64}, Vector{Float64}, Bool}
│ Q factor: 3×3 LinearAlgebra.HessenbergQ{Float64, Matrix{Float64}, Vector{Float64}, false}
│ H factor:
│ 3×3 UpperHessenberg{Float64, Matrix{Float64}}:
│   4.0      -11.3137      -1.41421
│  -5.65685    5.0          2.0
│    ⋅        -1.0444e-15   1.0
│ 
│ Expected output:
│ 
│ Hessenberg{Float64, UpperHessenberg{Float64, Matrix{Float64}}, Matrix{Float64}, Vector{Float64}, Bool}
│ Q factor: 3×3 LinearAlgebra.HessenbergQ{Float64, Matrix{Float64}, Vector{Float64}, false}
│ H factor:
│ 3×3 UpperHessenberg{Float64, Matrix{Float64}}:
│   4.0      -11.3137       -1.41421
│  -5.65685    5.0           2.0
│    ⋅        -8.88178e-16   1.0
│ 
│   diff =
│    Hessenberg{Float64, UpperHessenberg{Float64, Matrix{Float64}}, Matrix{Float64}, Vector{Float64}, Bool}
│    Q factor: 3×3 LinearAlgebra.HessenbergQ{Float64, Matrix{Float64}, Vector{Float64}, false}
│    H factor:
│    3×3 UpperHessenberg{Float64, Matrix{Float64}}:
│      4.0      -11.3137       -11.3137      -1.41421
│     -5.65685    5.0           5.0          2.0
│       ⋅        -8.88178e-16   -1.0444e-15   1.0
└ @ Documenter /cache/build/builder-demeter6-0/julialang/julia-master/usr/share/julia/stdlib/v1.12/LinearAlgebra/src/hessenberg.jl
┌ Error: doctest failure in /cache/build/builder-amdci4-1/julialang/julia-master/usr/share/julia/stdlib/v1.12/LinearAlgebra/src/LinearAlgebra.jl
│ 
│ ```jldoctest
│ julia> A = [1 2.2 4; 3.1 0.2 3; 4 1 2];
│ 
│ julia> X = [1; 2.5; 3];
│ 
│ julia> Y = zero(X);
│ 
│ julia> ldiv!(Y, qr(A), X);
│ 
│ julia> Y
│ 3-element Vector{Float64}:
│   0.7128099173553719
│  -0.051652892561983674
│   0.10020661157024757
│ 
│ julia> A\X
│ 3-element Vector{Float64}:
│   0.7128099173553719
│  -0.05165289256198333
│   0.10020661157024785
│ ```
│ 
│ Subexpression:
│ 
│ Y
│ 
│ Evaluated output:
│ 
│ 3-element Vector{Float64}:
│   0.7128099173553719
│  -0.051652892561983806
│   0.10020661157024781
│ 
│ Expected output:
│ 
│ 3-element Vector{Float64}:
│   0.7128099173553719
│  -0.051652892561983674
│   0.10020661157024757
│ 
│   diff =
│    3-element Vector{Float64}:
│      0.7128099173553719
│     -0.051652892561983674
│      0.10020661157024757-0.051652892561983806
│      0.10020661157024781
└ @ Documenter /cache/build/builder-demeter6-0/julialang/julia-master/usr/share/julia/stdlib/v1.12/LinearAlgebra/src/LinearAlgebra.jl
┌ Error: doctest failure in /cache/build/builder-amdci4-1/julialang/julia-master/usr/share/julia/stdlib/v1.12/LinearAlgebra/src/LinearAlgebra.jl
│ 
│ ```jldoctest
│ julia> A = [1 2.2 4; 3.1 0.2 3; 4 1 2];
│ 
│ julia> X = [1; 2.5; 3];
│ 
│ julia> Y = zero(X);
│ 
│ julia> ldiv!(Y, qr(A), X);
│ 
│ julia> Y
│ 3-element Vector{Float64}:
│   0.7128099173553719
│  -0.051652892561983674
│   0.10020661157024757
│ 
│ julia> A\X
│ 3-element Vector{Float64}:
│   0.7128099173553719
│  -0.05165289256198333
│   0.10020661157024785
│ ```
│ 
│ Subexpression:
│ 
│ A\X
│ 
│ Evaluated output:
│ 
│ 3-element Vector{Float64}:
│   0.7128099173553719
│  -0.05165289256198342
│   0.1002066115702479
│ 
│ Expected output:
│ 
│ 3-element Vector{Float64}:
│   0.7128099173553719
│  -0.05165289256198333
│   0.10020661157024785
│ 
│   diff =
│    3-element Vector{Float64}:
│      0.7128099173553719
│     -0.05165289256198333
│      0.10020661157024785-0.05165289256198342
│      0.1002066115702479
└ @ Documenter /cache/build/builder-demeter6-0/julialang/julia-master/usr/share/julia/stdlib/v1.12/LinearAlgebra/src/LinearAlgebra.jl
┌ Error: doctest failure in /cache/build/builder-amdci4-1/julialang/julia-master/usr/share/julia/stdlib/v1.12/LinearAlgebra/src/LinearAlgebra.jl
│ 
│ ```jldoctest
│ julia> A = [1 2.2 4; 3.1 0.2 3; 4 1 2];
│ 
│ julia> X = [1; 2.5; 3];
│ 
│ julia> Y = copy(X);
│ 
│ julia> ldiv!(qr(A), X);
│ 
│ julia> X
│ 3-element Vector{Float64}:
│   0.7128099173553719
│  -0.051652892561983674
│   0.10020661157024757
│ 
│ julia> A\Y
│ 3-element Vector{Float64}:
│   0.7128099173553719
│  -0.05165289256198333
│   0.10020661157024785
│ ```
│ 
│ Subexpression:
│ 
│ X
│ 
│ Evaluated output:
│ 
│ 3-element Vector{Float64}:
│   0.7128099173553719
│  -0.051652892561983806
│   0.10020661157024781
│ 
│ Expected output:
│ 
│ 3-element Vector{Float64}:
│   0.7128099173553719
│  -0.051652892561983674
│   0.10020661157024757
│ 
│   diff =
│    3-element Vector{Float64}:
│      0.7128099173553719
│     -0.051652892561983674
│      0.10020661157024757-0.051652892561983806
│      0.10020661157024781
└ @ Documenter /cache/build/builder-demeter6-0/julialang/julia-master/usr/share/julia/stdlib/v1.12/LinearAlgebra/src/LinearAlgebra.jl
┌ Error: doctest failure in /cache/build/builder-amdci4-1/julialang/julia-master/usr/share/julia/stdlib/v1.12/LinearAlgebra/src/LinearAlgebra.jl
│ 
│ ```jldoctest
│ julia> A = [1 2.2 4; 3.1 0.2 3; 4 1 2];
│ 
│ julia> X = [1; 2.5; 3];
│ 
│ julia> Y = copy(X);
│ 
│ julia> ldiv!(qr(A), X);
│ 
│ julia> X
│ 3-element Vector{Float64}:
│   0.7128099173553719
│  -0.051652892561983674
│   0.10020661157024757
│ 
│ julia> A\Y
│ 3-element Vector{Float64}:
│   0.7128099173553719
│  -0.05165289256198333
│   0.10020661157024785
│ ```
│ 
│ Subexpression:
│ 
│ A\Y
│ 
│ Evaluated output:
│ 
│ 3-element Vector{Float64}:
│   0.7128099173553719
│  -0.05165289256198342
│   0.1002066115702479
│ 
│ Expected output:
│ 
│ 3-element Vector{Float64}:
│   0.7128099173553719
│  -0.05165289256198333
│   0.10020661157024785
│ 
│   diff =
│    3-element Vector{Float64}:
│      0.7128099173553719
│     -0.05165289256198333
│      0.10020661157024785-0.05165289256198342
│      0.1002066115702479
└ @ Documenter /cache/build/builder-demeter6-0/julialang/julia-master/usr/share/julia/stdlib/v1.12/LinearAlgebra/src/LinearAlgebra.jl

These doctests should be more robust against variations due to the specific microarchitecture of the CPU where the CI job runs on, or these shouldn't be doctests in the first place if they are unreliable to be tested verbatim.