Skip to content
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

Inference error in Julia 1.8 #178

Closed
fredrikekre opened this issue Feb 17, 2022 · 3 comments · Fixed by JuliaLang/julia#44282
Closed

Inference error in Julia 1.8 #178

fredrikekre opened this issue Feb 17, 2022 · 3 comments · Fixed by JuliaLang/julia#44282

Comments

@fredrikekre
Copy link
Member

Found in PkgEval:

using Test, Tensors

function Ψ(C)
    μ = 1e10
    Kb = 1.66e11
    detC = det(C)
    J = sqrt(detC)
    Ĉ = detC^(-1/3)*C
    return 1/2** (tr(Ĉ)- 3) + Kb*(J-1)^2)
end

const F = one(Tensor{2,2}) + rand(Tensor{2,2})
const C = tdot(F)

@inferred hessian(Ψ, C)

git bisects points to JuliaLang/julia@e3b681c (cc @aviatesk if you have time to have a look).

e3b681c6872d87d74db63dd7ec3da2beee8e3ae4 is the first bad commit
commit e3b681c6872d87d74db63dd7ec3da2beee8e3ae4
Author: Shuhei Kadowaki <40514306+aviatesk@users.noreply.github.com>
Date:   Wed Feb 2 10:39:19 2022 +0900

    inference: always use const-prop'ed result (#44001)
    
    Previously, for `invoke`/opaque closure callsite, we use constant-prop'ed
    method body only when the inferred return type gets strictly improved
    by const-prop. But since the inliner is now able to inline the method
    body from `InferenceResult`, I believe it is always better to use method
    body shaped up by const-prop' no matter if the return type is improved
    (as we already do for ordinal call sites).
    
    > use constant prop' result even when the return type doesn't get refined
    ```julia
    const Gx = Ref{Any}()
    Base.@constprop :aggressive function conditional_escape!(cnd, x)
        if cnd
            Gx[] = x
        end
        return nothing
    end
    @test fully_eliminated((String,)) do x
        Base.@invoke conditional_escape!(false::Any, x::Any)
    end
    ```

:040000 040000 c48f5010124361b197808e99d69f5cd6d8327c73 e1c3e4c63b4c7128dbb0b4acae99ba864a580983 M     base
:040000 040000 5699d8a554ff36c25a94d4e2ed9576a2c6aab040 519f5968c110b456bbdab1b57015111630741106 M     test
bisect run success
@aviatesk
Copy link

Thanks, this is an interesting example. I will look into this later.

aviatesk added a commit to JuliaLang/julia that referenced this issue Feb 20, 2022
A return type derived by const-prop' inference can be wider than that of
non const-prop' inference in rare cases e.g. when there are cycles but
cached result is still accurate. This commit checks if the const-prop'ed
result is really more accurate than non-const result.

fix Ferrite-FEM/Tensors.jl#178
aviatesk added a commit to JuliaLang/julia that referenced this issue Feb 21, 2022
A return type derived by const-prop' inference can be wider than that of
non const-prop' inference in rare cases e.g. when there are cycles but
cached result is still accurate. This commit checks if the const-prop'ed
result is really more accurate than non-const result.

fix Ferrite-FEM/Tensors.jl#178
aviatesk added a commit to JuliaLang/julia that referenced this issue Feb 21, 2022
A return type derived by const-prop' inference can be wider than that of
non const-prop' inference in rare cases e.g. when there are cycles but
cached result is still accurate. This commit checks if the const-prop'ed
result is really more accurate than non-const result.

fix Ferrite-FEM/Tensors.jl#178
aviatesk added a commit to JuliaLang/julia that referenced this issue Feb 21, 2022
A return type derived by const-prop' inference can be wider than that of
non const-prop' inference in rare cases e.g. when there are cycles but
cached result is still accurate. This commit checks if the const-prop'ed
result is really more accurate than non-const result.

fix Ferrite-FEM/Tensors.jl#178
aviatesk added a commit to JuliaLang/julia that referenced this issue Feb 21, 2022
#44282)

A return type derived by const-prop' inference can be wider than that of
non const-prop' inference in rare cases e.g. when there are cycles but
cached result is still accurate. This commit checks if the const-prop'ed
result is really more accurate than non-const result.

fix Ferrite-FEM/Tensors.jl#178
@aviatesk
Copy link

Ok, this can be closed now.

aviatesk added a commit to JuliaLang/julia that referenced this issue Feb 21, 2022
#44282)

A return type derived by const-prop' inference can be wider than that of
non const-prop' inference in rare cases e.g. when there are cycles but
cached result is still accurate. This commit checks if the const-prop'ed
result is really more accurate than non-const result.

fix Ferrite-FEM/Tensors.jl#178
@fredrikekre
Copy link
Member Author

Great, thank you!

staticfloat pushed a commit to JuliaCI/julia-buildkite-testing that referenced this issue Mar 2, 2022
JuliaLang#44282)

A return type derived by const-prop' inference can be wider than that of
non const-prop' inference in rare cases e.g. when there are cycles but
cached result is still accurate. This commit checks if the const-prop'ed
result is really more accurate than non-const result.

fix Ferrite-FEM/Tensors.jl#178
LilithHafner pushed a commit to LilithHafner/julia that referenced this issue Mar 8, 2022
JuliaLang#44282)

A return type derived by const-prop' inference can be wider than that of
non const-prop' inference in rare cases e.g. when there are cycles but
cached result is still accurate. This commit checks if the const-prop'ed
result is really more accurate than non-const result.

fix Ferrite-FEM/Tensors.jl#178
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants