Skip to content

The following arguments should be traced but were not: #2853

Description

@dominic-chang

The following code:

function temp(m::T) where {T}
    oneT = one(T)
    a = oneT
    b = sqrt(oneT - m)
    sum_c2 = m 
    pow2 = oneT

    Reactant.@trace for _ = 1:8
        c = (a - b) 
        next_a = (a + b) 
        next_b = sqrt(a * b)
        sum_c2 += pow2 * c * c
        pow2 += pow2
        a = next_a
        b = next_b
    end

    return a
end

 m_r = Reactant.to_rarray(ms)

 Float64[0.01, 0.1, 0.5, 0.9]

Results in the error:

ERROR: Types do not match between function arguments and results.
The following arguments should be traced but were not: pow2 (path=(7, 1), type=Reactant.TracedRNumber{Float64})
The following arguments should be returned but were not: 
argprefix = ##loop_bodyarg#3367
resprefix = ##loop_bodyres#3368
verify_arg_names = (Symbol("##i#3337"), Symbol("##start#3341"), Symbol("##step#3342"), Symbol("##limit#3343"), :a, :b, :pow2, :sum_c2, :next_b, :next_a, :c)
argtys = DataType[Base.RefValue{Reactant.TracedRNumber{Int64}}, Base.RefValue{Reactant.TracedRNumber{Int64}}, Base.RefValue{Reactant.TracedRNumber{Int64}}, Base.RefValue{Reactant.TracedRNumber{Int64}}, Base.RefValue{Reactant.TracedRNumber{Float64}}, Base.RefValue{Reactant.TracedRNumber{Float64}}, Base.RefValue{Reactant.TracedRNumber{Float64}}, Base.RefValue{Reactant.TracedRNumber{Float64}}, Base.RefValue{Nothing}, Base.RefValue{Nothing}, Base.RefValue{Nothing}]
Traced Arg Paths: 
(Ptr{Nothing} @0x0000000372064a10, ((Symbol("##loop_bodyarg#3367"), 1, 1),))
(Ptr{Nothing} @0x0000000372064b10, ((Symbol("##loop_bodyarg#3367"), 2, 1), (Symbol("##loop_bodyresarg#3369"), 2, 1)))
(Ptr{Nothing} @0x0000000372064c10, ((Symbol("##loop_bodyarg#3367"), 3, 1), (Symbol("##loop_bodyresarg#3369"), 3, 1)))
(Ptr{Nothing} @0x0000000372064d30, ((Symbol("##loop_bodyarg#3367"), 4, 1), (Symbol("##loop_bodyresarg#3369"), 4, 1)))
(Ptr{Nothing} @0x0000000372064e50, ((Symbol("##loop_bodyarg#3367"), 5, 1),))
(Ptr{Nothing} @0x0000000372064f50, ((Symbol("##loop_bodyarg#3367"), 6, 1),))
(Ptr{Nothing} @0x0000000372065150, ((Symbol("##loop_bodyarg#3367"), 8, 1),))

Traced Res Paths: 
(Ptr{Nothing} @0x00000003720286b0, ((Symbol("##loop_bodyresarg#3369"), 6, 1),))
(Ptr{Nothing} @0x00000003720294b0, ((Symbol("##loop_bodyresarg#3369"), 8, 1),))
(Ptr{Nothing} @0x0000000372029930, ((Symbol("##loop_bodyresarg#3369"), 7, 1),))
(Ptr{Nothing} @0x0000000372064b10, ((Symbol("##loop_bodyarg#3367"), 2, 1), (Symbol("##loop_bodyresarg#3369"), 2, 1)))
(Ptr{Nothing} @0x0000000372064c10, ((Symbol("##loop_bodyarg#3367"), 3, 1), (Symbol("##loop_bodyresarg#3369"), 3, 1)))
(Ptr{Nothing} @0x0000000372064d30, ((Symbol("##loop_bodyarg#3367"), 4, 1), (Symbol("##loop_bodyresarg#3369"), 4, 1)))
(Ptr{Nothing} @0x00000003720673f0, ((Symbol("##loop_bodyresarg#3369"), 1, 1),))
(Ptr{Nothing} @0x0000000372067d30, ((Symbol("##loop_bodyresarg#3369"), 5, 1),))

Traced Arg NI Paths: 
(Ptr{Nothing} @0x0000000372064a10, ((Symbol("##loop_bodyarg#3367"), 1, 1),))
(Ptr{Nothing} @0x0000000372064e50, ((Symbol("##loop_bodyarg#3367"), 5, 1),))
(Ptr{Nothing} @0x0000000372064f50, ((Symbol("##loop_bodyarg#3367"), 6, 1),))
(Ptr{Nothing} @0x0000000372065150, ((Symbol("##loop_bodyarg#3367"), 8, 1),))

Traced Res NI Paths: 
(Ptr{Nothing} @0x00000003720286b0, ((Symbol("##loop_bodyresarg#3369"), 6, 1),))
(Ptr{Nothing} @0x00000003720294b0, ((Symbol("##loop_bodyresarg#3369"), 8, 1),))
(Ptr{Nothing} @0x0000000372029930, ((Symbol("##loop_bodyresarg#3369"), 7, 1),))
(Ptr{Nothing} @0x00000003720673f0, ((Symbol("##loop_bodyresarg#3369"), 1, 1),))
(Ptr{Nothing} @0x0000000372067d30, ((Symbol("##loop_bodyresarg#3369"), 5, 1),))

traced_result : Nothing

Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] finalize_mlir_fn(result::Nothing, traced_args::Vector{…}, linear_args::Vector{…}, skipped_args::Vector{…}, seen_args::Reactant.OrderedIdDict{…}, fnbody::Reactant.MLIR.IR.Block, func::Reactant.MLIR.IR.Operation, mod::Reactant.MLIR.IR.Module, name::String, in_tys::Vector{…}, do_transpose::Bool, optimize_then_pad::Bool, inv_map::IdDict{…}, args_in_result::Symbol, resprefix::Symbol, argprefix::Symbol, resargprefix::Symbol, verify_arg_names::NTuple{…}, return_dialect::Symbol, traced_args_to_shardings::Reactant.OrderedIdDict{…}, output_shardings::Nothing, sym_visibility::Reactant.MLIR.IR.Attribute, num_replicas::Int64, runtime::Nothing, construct_function_without_args::Bool, args::Vector{…}, N::Int64, concretein::Bool, toscalar::Bool)
    @ Reactant.TracedUtils ~/.julia/packages/Reactant/Tk0YL/src/TracedUtils.jl:818
  [3] make_mlir_fn(f::var"#66#68", args::Vector{…}, kwargs::Tuple{}, name::String, concretein::Bool; toscalar::Bool, return_dialect::Symbol, args_in_result::Symbol, construct_function_without_args::Bool, do_transpose::Bool, within_autodiff::Bool, input_shardings::Nothing, output_shardings::Nothing, runtime::Nothing, verify_arg_names::NTuple{…}, argprefix::Symbol, resprefix::Symbol, resargprefix::Symbol, num_replicas::Int64, optimize_then_pad::Bool)
    @ Reactant.TracedUtils ~/.julia/packages/Reactant/Tk0YL/src/TracedUtils.jl:390
  [4] make_mlir_fn
    @ ~/.julia/packages/Reactant/Tk0YL/src/TracedUtils.jl:299 [inlined]
  [5] while_loop(::var"#65#67", ::var"#66#68", ::Base.RefValue{…}, ::Vararg{…}; track_numbers::Type, verify_arg_names::NTuple{…}, checkpointing::Bool, mincut::Bool, location::Reactant.MLIR.IR.Location)
    @ Reactant.Ops ~/.julia/packages/Reactant/Tk0YL/src/Ops.jl:2362
  [6] #traced_while#162
    @ ~/.julia/packages/Reactant/Tk0YL/src/ControlFlow.jl:20 [inlined]
  [7] traced_while
    @ ~/.julia/packages/Reactant/Tk0YL/src/ControlFlow.jl:11 [inlined]
  [8] macro expansion
    @ ~/.julia/packages/ReactantCore/KHVpc/src/ReactantCore.jl:390 [inlined]
  [9] temp
    @ ./REPL[62]:8
 [10] call_with_reactant(::typeof(temp), ::Reactant.TracedRNumber{Float64})
    @ Reactant ~/.julia/packages/Reactant/Tk0YL/src/utils.jl:1195
 [11] make_mlir_fn(f::typeof(temp), args::Tuple{…}, kwargs::Tuple{}, name::String, concretein::Bool; toscalar::Bool, return_dialect::Symbol, args_in_result::Symbol, construct_function_without_args::Bool, do_transpose::Bool, within_autodiff::Bool, input_shardings::Nothing, output_shardings::Nothing, runtime::Nothing, verify_arg_names::Nothing, argprefix::Symbol, resprefix::Symbol, resargprefix::Symbol, num_replicas::Int64, optimize_then_pad::Bool)
    @ Reactant.TracedUtils ~/.julia/packages/Reactant/Tk0YL/src/TracedUtils.jl:370
 [12] elem_apply(f::Function, args::Reactant.TracedRArray{Float64, 1})
    @ Reactant.TracedUtils ~/.julia/packages/Reactant/Tk0YL/src/TracedUtils.jl:1211
 [13] _copyto!
    @ ~/.julia/packages/Reactant/Tk0YL/src/TracedRArray.jl:397
 [14] call_with_reactant(::Reactant.EnsureReturnType{…}, ::typeof(Reactant.TracedRArrayOverrides._copyto!), ::Reactant.TracedRArray{…}, ::Base.Broadcast.Broadcasted{…})
    @ Reactant ~/.julia/packages/Reactant/Tk0YL/src/utils.jl:1195
 [15] copyto!
    @ ~/.julia/packages/Reactant/Tk0YL/src/TracedRArray.jl:336
 [16] call_with_reactant(::Reactant.EnsureReturnType{…}, ::typeof(copyto!), ::Reactant.TracedRArray{…}, ::Base.Broadcast.Broadcasted{…})
    @ Reactant ~/.julia/packages/Reactant/Tk0YL/src/utils.jl:1195
 [17] copyto!
    @ ./broadcast.jl:956 [inlined]
 [18] _copy
    @ ~/.julia/packages/Reactant/Tk0YL/src/TracedRArray.jl:322
 [19] call_with_reactant(::Reactant.EnsureReturnType{…}, ::typeof(Reactant.TracedRArrayOverrides._copy), ::Base.Broadcast.Broadcasted{…})
    @ Reactant ~/.julia/packages/Reactant/Tk0YL/src/utils.jl:1195
 [20] copy
    @ ~/.julia/packages/Reactant/Tk0YL/src/TracedRArray.jl:326
 [21] call_with_reactant(::Reactant.EnsureReturnType{…}, ::typeof(copy), ::Base.Broadcast.Broadcasted{…})
    @ Reactant ~/.julia/packages/Reactant/Tk0YL/src/utils.jl:1195
 [22] materialize
    @ ./broadcast.jl:903 [inlined]
 [23] BroadcastFunction
    @ ./broadcast.jl:1381 [inlined]
 [24] #apply#102
    @ ~/.julia/packages/Reactant/Tk0YL/src/utils.jl:119
 [25] call_with_reactant(::Reactant.EnsureReturnType{…}, ::Reactant.var"##apply#102", ::@Kwargs{}, ::typeof(Reactant.apply), ::Base.Broadcast.BroadcastFunction{…}, ::Reactant.TracedRArray{…})
    @ Reactant ~/.julia/packages/Reactant/Tk0YL/src/utils.jl:1195
 [26] apply
    @ ~/.julia/packages/Reactant/Tk0YL/src/utils.jl:118
 [27] call_with_reactant(::typeof(Reactant.apply), ::Base.Broadcast.BroadcastFunction{…}, ::Reactant.TracedRArray{…})
    @ Reactant ~/.julia/packages/Reactant/Tk0YL/src/utils.jl:1195
 [28] make_mlir_fn(f::typeof(Reactant.apply), args::Tuple{…}, kwargs::@NamedTuple{}, name::String, concretein::Bool; toscalar::Bool, return_dialect::Symbol, args_in_result::Symbol, construct_function_without_args::Bool, do_transpose::Bool, within_autodiff::Bool, input_shardings::Nothing, output_shardings::Nothing, runtime::Val{…}, verify_arg_names::Nothing, argprefix::Symbol, resprefix::Symbol, resargprefix::Symbol, num_replicas::Int64, optimize_then_pad::Bool)
    @ Reactant.TracedUtils ~/.julia/packages/Reactant/Tk0YL/src/TracedUtils.jl:370
 [29] make_mlir_fn
    @ ~/.julia/packages/Reactant/Tk0YL/src/TracedUtils.jl:299 [inlined]
 [30] #make_mlir_fn#7
    @ ~/.julia/packages/Reactant/Tk0YL/src/TracedUtils.jl:322 [inlined]
 [31] make_mlir_fn
    @ ~/.julia/packages/Reactant/Tk0YL/src/TracedUtils.jl:299 [inlined]
 [32] compile_mlir!(mod::Reactant.MLIR.IR.Module, f::Base.Broadcast.BroadcastFunction{…}, args::Tuple{…}, compile_options::CompileOptions, debugcache::Vector{…}, callcache::Dict{…}, sdycache::Dict{…}, sdygroupidcache::Tuple{…}; fn_kwargs::@NamedTuple{}, backend::String, runtime::Val{…}, legalize_stablehlo_to_mhlo::Bool, client::Reactant.XLA.PJRT.Client, kwargs::@Kwargs{})
    @ Reactant.Compiler ~/.julia/packages/Reactant/Tk0YL/src/Compiler.jl:1289
 [33] compile_mlir!
    @ ~/.julia/packages/Reactant/Tk0YL/src/Compiler.jl:1248 [inlined]
 [34] compile_xla(ctx::Reactant.MLIR.IR.Context, f::Function, args::Tuple{…}; before_xla_optimizations::Bool, client::Nothing, serializable::Bool, kwargs::@Kwargs{})
    @ Reactant.Compiler ~/.julia/packages/Reactant/Tk0YL/src/Compiler.jl:3503
 [35] compile_xla
    @ ~/.julia/packages/Reactant/Tk0YL/src/Compiler.jl:3478 [inlined]
 [36] compile(ctx::Reactant.MLIR.IR.Context, f::Function, args::Tuple{…}; kwargs::@Kwargs{})
    @ Reactant.Compiler ~/.julia/packages/Reactant/Tk0YL/src/Compiler.jl:3599
 [37] macro expansion
    @ ~/.julia/packages/Reactant/Tk0YL/src/Compiler.jl:2556 [inlined]
 [38] macro expansion
    @ ~/.julia/packages/LLVM/Bd7kA/src/base.jl:113 [inlined]
 [39] top-level scope
    @ ~/.julia/packages/Reactant/Tk0YL/src/Compiler.jl:2555
Some type information was truncated. Use `show(err)` to see complete types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions