Skip to content

Conversation

@avik-pal
Copy link
Collaborator

No description provided.

@avik-pal avik-pal force-pushed the avik-pal-patch-1 branch 2 times, most recently from 23910f3 to f112745 Compare October 26, 2025 19:48
@avik-pal
Copy link
Collaborator Author

julia> using Reactant
Precompiling SparseArraysExt finished.
  1 dependency successfully precompiled in 2 seconds
Info Given ReactantStatisticsExt was explicitly requested, output will be shown live 
┌ Warning: Reactant.jl currently doesn't support versions of Julia 1.12 or newer. We are
│ actively working on adding support for newer versions of Julia. For the time
│ being we recommend using 1.11 or LTS.
│ 
│ For latest updates, check the status of support for Julia 1.12+ at
│ https://github.com/EnzymeAD/Reactant.jl/issues/1736.
└ @ Reactant /mnt/software/lux/Reactant.jl/src/Reactant.jl:335
Precompiling ReactantStatisticsExt finished.
  1 dependency successfully precompiled in 3 seconds
  1 dependency had output during precompilation:
┌ ReactantStatisticsExt
│  [Output was shown above]
└  

julia> x_ra = Reactant.to_rarray(rand(Float32, 4, 3))
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
I0000 00:00:1761508771.477702  407258 service.cc:158] XLA service 0x2c47d3e0 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices:
I0000 00:00:1761508771.477929  407258 service.cc:166]   StreamExecutor device (0): NVIDIA GeForce RTX 4050 Laptop GPU, Compute Capability 8.9
I0000 00:00:1761508771.479202  407258 se_gpu_pjrt_client.cc:1295] Using BFC allocator.
I0000 00:00:1761508771.479253  407258 gpu_helpers.cc:136] XLA backend allocating 4538351616 bytes on device 0 for BFCAllocator.
I0000 00:00:1761508771.479437  407258 gpu_helpers.cc:177] XLA backend will use up to 1512783872 bytes on device 0 for CollectiveBFCAllocator.
I0000 00:00:1761508771.490449  407258 cuda_dnn.cc:463] Loaded cuDNN version 91200
4×3 ConcretePJRTArray{Float32,2}:
 0.609525  0.56646   0.355121
 0.314876  0.276415  0.855706
 0.755625  0.511299  0.640577
 0.463603  0.581469  0.106345

julia> @code_hlo sum(x_ra)
ERROR: TypeError: non-boolean (Compiler.IRCode) used in boolean context
Stacktrace:
  [1] semiconcrete_result_item(result::Compiler.SemiConcreteResult, info::Compiler.CallInfo, flag::UInt32, state::Compiler.InliningState{Enzyme.Compiler.Interpreter.EnzymeInterpreter{typeof(Reactant.set_reactant_abi)}})
    @ Compiler ./../usr/share/julia/Compiler/src/ssair/inlining.jl:1449
  [2] handle_semi_concrete_result!(cases::Vector{Compiler.InliningCase}, result::Compiler.SemiConcreteResult, match::Core.MethodMatch, info::Compiler.CallInfo, flag::UInt32, state::Compiler.InliningState{Enzyme.Compiler.Interpreter.EnzymeInterpreter{…}})
    @ Compiler ./../usr/share/julia/Compiler/src/ssair/inlining.jl:1462
  [3] handle_any_const_result!(cases::Vector{…}, result::Any, match::Core.MethodMatch, argtypes::Vector{…}, info::Compiler.CallInfo, flag::UInt32, state::Compiler.InliningState{…}; allow_typevars::Bool)
    @ Compiler ./../usr/share/julia/Compiler/src/ssair/inlining.jl:1304
  [4] handle_any_const_result!
    @ ./../usr/share/julia/Compiler/src/ssair/inlining.jl:1297 [inlined]
  [5] compute_inlining_cases(info::Compiler.CallInfo, flag::UInt32, sig::Compiler.Signature, state::Compiler.InliningState{Enzyme.Compiler.Interpreter.EnzymeInterpreter{typeof(Reactant.set_reactant_abi)}})
    @ Compiler ./../usr/share/julia/Compiler/src/ssair/inlining.jl:1369
  [6] handle_call!
    @ ./../usr/share/julia/Compiler/src/ssair/inlining.jl:1401 [inlined]
  [7] assemble_inline_todo!(ir::Compiler.IRCode, state::Compiler.InliningState{Enzyme.Compiler.Interpreter.EnzymeInterpreter{typeof(Reactant.set_reactant_abi)}})
    @ Compiler ./../usr/share/julia/Compiler/src/ssair/inlining.jl:1652
  [8] ssa_inlining_pass!
    @ ./../usr/share/julia/Compiler/src/ssair/inlining.jl:76 [inlined]
  [9] run_passes_ipo_safe(ci::Core.CodeInfo, sv::Compiler.OptimizationState{Enzyme.Compiler.Interpreter.EnzymeInterpreter{typeof(Reactant.set_reactant_abi)}}, optimize_until::Nothing)
    @ Compiler ./../usr/share/julia/Compiler/src/optimize.jl:1013
 [10] run_passes_ipo_safe
    @ ./../usr/share/julia/Compiler/src/optimize.jl:1027 [inlined]
 [11] optimize(interp::Enzyme.Compiler.Interpreter.EnzymeInterpreter{typeof(Reactant.set_reactant_abi)}, opt::Compiler.OptimizationState{Enzyme.Compiler.Interpreter.EnzymeInterpreter{typeof(Reactant.set_reactant_abi)}}, caller::Compiler.InferenceResult)
    @ Compiler ./../usr/share/julia/Compiler/src/optimize.jl:1002
 [12] finish_nocycle(::Enzyme.Compiler.Interpreter.EnzymeInterpreter{typeof(Reactant.set_reactant_abi)}, frame::Compiler.InferenceState, time_before::UInt64)
    @ Compiler ./../usr/share/julia/Compiler/src/typeinfer.jl:202
 [13] typeinf(interp::Enzyme.Compiler.Interpreter.EnzymeInterpreter{typeof(Reactant.set_reactant_abi)}, frame::Compiler.InferenceState)
    @ Compiler ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:4507
 [14] const_prop_call(interp::Enzyme.Compiler.Interpreter.EnzymeInterpreter{typeof(Reactant.set_reactant_abi)}, mi::Core.MethodInstance, result::Compiler.MethodCallResult, arginfo::Compiler.ArgInfo, sv::Compiler.InferenceState, concrete_eval_result::Nothing)
    @ Compiler ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:1348
 [15] abstract_call_method_with_const_args(interp::Enzyme.Compiler.Interpreter.EnzymeInterpreter{…}, result::Compiler.MethodCallResult, f::Any, arginfo::Compiler.ArgInfo, si::Compiler.StmtInfo, match::Core.MethodMatch, sv::Compiler.InferenceState, invokecall::Nothing)
    @ Compiler ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:898
 [16] abstract_call_method_with_const_args
    @ ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:868 [inlined]
 [17] (::Compiler.var"#handle1#abstract_call_gf_by_type##1"{})(interp::Enzyme.Compiler.Interpreter.EnzymeInterpreter{…}, sv::Compiler.InferenceState)
    @ Compiler ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:178
 [18] (::Compiler.var"#infercalls#abstract_call_gf_by_type##0"{})(interp::Enzyme.Compiler.Interpreter.EnzymeInterpreter{…}, sv::Compiler.InferenceState)
    @ Compiler ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:252
 [19] abstract_call_gf_by_type(interp::Enzyme.Compiler.Interpreter.EnzymeInterpreter{typeof(Reactant.set_reactant_abi)}, func::Any, arginfo::Compiler.ArgInfo, si::Compiler.StmtInfo, atype::Any, sv::Compiler.InferenceState, max_methods::Int64)
    @ Compiler ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:338
 [20] abstract_call_gf_by_type(interp::Enzyme.Compiler.Interpreter.EnzymeInterpreter, f::Any, arginfo::Compiler.ArgInfo, si::Compiler.StmtInfo, atype::Any, sv::Compiler.InferenceState, max_methods::Int64)
    @ Enzyme.Compiler.Interpreter /mnt/.julia/packages/Enzyme/Ah2fT/src/compiler/interpreter.jl:364
 [21] abstract_call_known(interp::Enzyme.Compiler.Interpreter.EnzymeInterpreter{typeof(Reactant.set_reactant_abi)}, f::Any, arginfo::Compiler.ArgInfo, si::Compiler.StmtInfo, sv::Compiler.InferenceState, max_methods::Int64)
    @ Compiler ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:2782
 [22] set_reactant_abi(interp::Enzyme.Compiler.Interpreter.EnzymeInterpreter{typeof(Reactant.set_reactant_abi)}, f::Any, arginfo::Compiler.ArgInfo, si::Compiler.StmtInfo, sv::Compiler.InferenceState, max_methods::Int64)
    @ Reactant /mnt/software/lux/Reactant.jl/src/Interpreter.jl:66
 [23] abstract_call_known(interp::Enzyme.Compiler.Interpreter.EnzymeInterpreter{typeof(Reactant.set_reactant_abi)}, f::Any, arginfo::Compiler.ArgInfo, si::Compiler.StmtInfo, sv::Compiler.InferenceState, max_methods::Int64)
    @ Enzyme.Compiler.Interpreter /mnt/.julia/packages/Enzyme/Ah2fT/src/compiler/interpreter.jl:1184
 [24] abstract_call(interp::Enzyme.Compiler.Interpreter.EnzymeInterpreter{typeof(Reactant.set_reactant_abi)}, arginfo::Compiler.ArgInfo, si::Compiler.StmtInfo, sv::Compiler.InferenceState, max_methods::Int64)
    @ Compiler ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:2889
 [25] abstract_call
    @ ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:2882 [inlined]
 [26] abstract_call(interp::Enzyme.Compiler.Interpreter.EnzymeInterpreter{typeof(Reactant.set_reactant_abi)}, arginfo::Compiler.ArgInfo, sstate::Compiler.StatementState, sv::Compiler.InferenceState)
    @ Compiler ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:3042
 [27] abstract_eval_call
    @ ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:3060 [inlined]
 [28] abstract_eval_statement_expr(interp::Enzyme.Compiler.Interpreter.EnzymeInterpreter{typeof(Reactant.set_reactant_abi)}, e::Expr, sstate::Compiler.StatementState, sv::Compiler.InferenceState)
    @ Compiler ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:3389
 [29] abstract_eval_basic_statement
    @ ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:3835 [inlined]
 [30] abstract_eval_basic_statement
    @ ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:3792 [inlined]
 [31] typeinf_local(interp::Enzyme.Compiler.Interpreter.EnzymeInterpreter{typeof(Reactant.set_reactant_abi)}, frame::Compiler.InferenceState, nextresult::Compiler.CurrentState)
    @ Compiler ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:4342
 [32] typeinf(interp::Enzyme.Compiler.Interpreter.EnzymeInterpreter{typeof(Reactant.set_reactant_abi)}, frame::Compiler.InferenceState)
    @ Compiler ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:4500
 [33] typeinf_frame(interp::Enzyme.Compiler.Interpreter.EnzymeInterpreter{typeof(Reactant.set_reactant_abi)}, mi::Core.MethodInstance, run_optimizer::Bool)
    @ Compiler ./../usr/share/julia/Compiler/src/typeinfer.jl:1122
 [34] typeinf_ircode(interp::Enzyme.Compiler.Interpreter.EnzymeInterpreter{typeof(Reactant.set_reactant_abi)}, mi::Core.MethodInstance, optimize_until::Nothing)
    @ Compiler ./../usr/share/julia/Compiler/src/typeinfer.jl:1101
 [35] call_with_reactant_generator(world::UInt64, source::Union{LineNumberNode, Method}, self::Any, redub_arguments::Any)
    @ Reactant /mnt/software/lux/Reactant.jl/src/utils.jl:695
 [36] make_mlir_fn(f::typeof(sum), 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, 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 /mnt/software/lux/Reactant.jl/src/TracedUtils.jl:345
 [37] make_mlir_fn
    @ /mnt/software/lux/Reactant.jl/src/TracedUtils.jl:275 [inlined]
 [38] compile_mlir!(mod::Reactant.MLIR.IR.Module, f::typeof(sum), args::Tuple{…}, compile_options::CompileOptions, callcache::Dict{…}, sdycache::Dict{…}; fn_kwargs::@NamedTuple{}, backend::String, runtime::Val{…}, legalize_stablehlo_to_mhlo::Bool, client::Reactant.XLA.PJRT.Client, kwargs::@Kwargs{})
    @ Reactant.Compiler /mnt/software/lux/Reactant.jl/src/Compiler.jl:1608
 [39] (::Reactant.Compiler.var"#11#12"{Reactant.XLA.PJRT.Client, typeof(sum), Tuple{ConcretePJRTArray{Float32, 2, 1, Reactant.Sharding.ShardInfo{Reactant.Sharding.NoSharding, Nothing}}}})(ctx::Reactant.MLIR.IR.Context)
    @ Reactant.Compiler /mnt/software/lux/Reactant.jl/src/Compiler.jl:1411
 [40] with_context(f::Reactant.Compiler.var"#11#12"{Reactant.XLA.PJRT.Client, typeof(sum), Tuple{ConcretePJRTArray{Float32, 2, 1, Reactant.Sharding.ShardInfo{Reactant.Sharding.NoSharding, Nothing}}}}; allow_use_existing::Bool)
    @ Reactant.MLIR.IR /mnt/software/lux/Reactant.jl/src/mlir/IR/Context.jl:99
 [41] with_context(f::Function)
    @ Reactant.MLIR.IR /mnt/software/lux/Reactant.jl/src/mlir/IR/Context.jl:82
 [42] compile_mlir(f::Function, args::Tuple{…}; client::Nothing, kwargs::@Kwargs{})
    @ Reactant.Compiler /mnt/software/lux/Reactant.jl/src/Compiler.jl:1407
 [43] top-level scope
    @ /mnt/software/lux/Reactant.jl/src/Compiler.jl:2649
 [44] top-level scope
    @ REPL:1
Some type information was truncated. Use `show(err)` to see complete types.

elseif VERSION < v"1.12.0-"
return CallMeta(Union{}, Union{}, Effects(), NoCallInfo())
else
return Core.Compiler.Future{Core.Compiler.CallMeta}(CallMeta(Union{}, Union{}, Effects(), NoCallInfo()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
return Core.Compiler.Future{Core.Compiler.CallMeta}(CallMeta(Union{}, Union{}, Effects(), NoCallInfo()))
return Core.Compiler.Future{Core.Compiler.CallMeta}(
CallMeta(Union{}, Union{}, Effects(), NoCallInfo())
)

Comment on lines +59 to +61
return Core.Compiler.Future{Core.Compiler.CallMeta}(CallMeta(
Core.Const(true), Union{}, Core.Compiler.EFFECTS_TOTAL, MethodResultPure()
))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
return Core.Compiler.Future{Core.Compiler.CallMeta}(CallMeta(
Core.Const(true), Union{}, Core.Compiler.EFFECTS_TOTAL, MethodResultPure()
))
return Core.Compiler.Future{Core.Compiler.CallMeta}(
CallMeta(
Core.Const(true),
Union{},
Core.Compiler.EFFECTS_TOTAL,
MethodResultPure(),
),
)

true,
)::Core.OpaqueClosure
ores = @static if VERSION < v"1.11"
ccall(:jl_new_opaque_closure_from_code_info,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
ccall(:jl_new_opaque_closure_from_code_info,
ccall(
:jl_new_opaque_closure_from_code_info,

true,
)::Core.OpaqueClosure
else
ccall(:jl_new_opaque_closure_from_code_info,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
ccall(:jl_new_opaque_closure_from_code_info,
ccall(
:jl_new_opaque_closure_from_code_info,

return Reactant.call_with_reactant(
Reactant.ka_with_reactant, ndrange, workgroupsize, obj, args...
)
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
end
return Reactant.call_with_reactant(
Reactant.ka_with_reactant, ndrange, workgroupsize, obj, args...
)
end

Comment on lines +123 to +129
Reactant.@reactant_overlay function (obj::KA.Kernel{ReactantBackend})(
args...; ndrange=nothing, workgroupsize=nothing
)
Base.@_noinline_meta
Base.@_nospecializeinfer_meta
return Reactant.call_with_reactant(
Reactant.ka_with_reactant, ndrange, workgroupsize, obj, args...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
Reactant.@reactant_overlay function (obj::KA.Kernel{ReactantBackend})(
args...; ndrange=nothing, workgroupsize=nothing
)
Base.@_noinline_meta
Base.@_nospecializeinfer_meta
return Reactant.call_with_reactant(
Reactant.ka_with_reactant, ndrange, workgroupsize, obj, args...
Reactant.@reactant_overlay function (obj::KA.Kernel{ReactantBackend})(
args...; ndrange=nothing, workgroupsize=nothing

return Reactant.call_with_reactant(
Reactant.ka_with_reactant, ndrange, workgroupsize, obj, args...
)
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
end
Base.@_noinline_meta
Base.@_nospecializeinfer_meta
return Reactant.call_with_reactant(
Reactant.ka_with_reactant, ndrange, workgroupsize, obj, args...
)
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Reactant.@reactant_overlay Base.@nospecializeinfer @noinline function (
obj::KA.Kernel{ReactantBackend}
)(
@nospecialize args...; ndrange=nothing, workgroupsize=nothing
)
return Reactant.call_with_reactant(
Reactant.ka_with_reactant, ndrange, workgroupsize, obj, args...

@wsmoses
Copy link
Member

wsmoses commented Oct 28, 2025

@avik-pal in a twist of events, can you review this?

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 this pull request may close these issues.

2 participants