# \#inference

**URL:** https://discourse.julialang.org/tag/inference/79.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [ReactantServer.jl: serve more models per GPU with Reactant.jl and XLA (gauging interest)](https://discourse.julialang.org/t/reactantserver-jl-serve-more-models-per-gpu-with-reactant-jl-and-xla-gauging-interest/137358)

<div class="topic-metadata">

**Author:** [@csvance](https://discourse.julialang.org/u/csvance)\
**Replies:** 17\
**Last updated:** [September 13, 2026, 8:27pm UTC](https://discourse.julialang.org/t/reactantserver-jl-serve-more-models-per-gpu-with-reactant-jl-and-xla-gauging-interest/137358 "2026-09-13T20:27:02Z")

</div>

I have been building a Julia inference server and want to find out whether others would find it useful before investing more in polishing it for general use. Feedback, criticism, and “we already have this, it is called X…

---

## [Can Symbolics/MTK split the generated RHS into multiple smaller functions?](https://discourse.julialang.org/t/can-symbolics-mtk-split-the-generated-rhs-into-multiple-smaller-functions/138469)

<div class="topic-metadata">

**Author:** [@Bart\_van\_de\_Lint](https://discourse.julialang.org/u/Bart_van_de_Lint)\
**Replies:** 1\
**Last updated:** [July 26, 2026, 7:39pm UTC](https://discourse.julialang.org/t/can-symbolics-mtk-split-the-generated-rhs-into-multiple-smaller-functions/138469 "2026-07-26T19:39:39Z")

</div>

I have a large ModelingToolkit model. mtkcompile inlines ~32k observed equations into a single big RHS function in around 60 seconds, and first-call compilation of that one function takes \>1000 s (dominated by type infer…

---

## [\`x !== nothing\` incorrectly reported by \`@code\_lowered\` and Cthulhu.jl?](https://discourse.julialang.org/t/x-nothing-incorrectly-reported-by-code-lowered-and-cthulhu-jl/133345)

<div class="topic-metadata">

**Author:** [@johnomotani](https://discourse.julialang.org/u/johnomotani)\
**Replies:** 6\
**Last updated:** [October 22, 2025, 12:57pm UTC](https://discourse.julialang.org/t/x-nothing-incorrectly-reported-by-code-lowered-and-cthulhu-jl/133345 "2025-10-22T12:57:08Z")

</div>

Not sure if this is a bug, or I’m missing something about understanding the output of @code\_lowered and Cthulhu’s @descend. The following REPL snippet shows a very simple function, which if called with argument nothing d…

---

## [Why does \`Cthulhu.@descend\` report incorrect \`Any\` inference in the call menu?](https://discourse.julialang.org/t/why-does-cthulhu-descend-report-incorrect-any-inference-in-the-call-menu/127400)

<div class="topic-metadata">

**Author:** [@Benny](https://discourse.julialang.org/u/Benny)\
**Replies:** 0\
**Last updated:** [March 27, 2025, 4:33am UTC](https://discourse.julialang.org/t/why-does-cthulhu-descend-report-incorrect-any-inference-in-the-call-menu/127400 "2025-03-27T04:33:30Z")

</div>

Cthulhu.@descend sometimes annotates return types of calls as ::Any in the call menu, contradicting @code\_warntype. Descending into the ::Any calls show different return types in the annotated method body, consistent wit…

---

## [\[RELEASE\] RxInfer 4.0.0 and updated documentation](https://discourse.julialang.org/t/release-rxinfer-4-0-0-and-updated-documentation/126145)

<div class="topic-metadata">

**Author:** [@bvdmitri](https://discourse.julialang.org/u/bvdmitri)\
**Replies:** 2\
**Last updated:** [February 24, 2025, 8:40am UTC](https://discourse.julialang.org/t/release-rxinfer-4-0-0-and-updated-documentation/126145 "2025-02-24T08:40:55Z")

</div>

We are pleased to announce the release of RxInfer.jl v4.0.0, which introduces significant enhancements to our probabilistic programming framework. A bit of a background RxInfer.jl is a Julia package designed for eff…

---

## [Type instability clarification](https://discourse.julialang.org/t/type-instability-clarification/123118)

<div class="topic-metadata">

**Author:** [@s\_amap](https://discourse.julialang.org/u/s_amap)\
**Replies:** 6\
**Last updated:** [November 27, 2024, 8:47am UTC](https://discourse.julialang.org/t/type-instability-clarification/123118 "2024-11-27T08:47:57Z")

</div>

Hi. I’m currently investigating performance and type stability matters relating to a package (and learning along the way). Here’s one type stability issue I don’t understand regarding a parametric type used in a variab…

---

## [In what cases does Cthulhu.jl give a more precise inferred return type than Julia's built-in return type inference?](https://discourse.julialang.org/t/in-what-cases-does-cthulhu-jl-give-a-more-precise-inferred-return-type-than-julias-built-in-return-type-inference/122064)

<div class="topic-metadata">

**Author:** [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Replies:** 0\
**Last updated:** [October 31, 2024, 10:19am UTC](https://discourse.julialang.org/t/in-what-cases-does-cthulhu-jl-give-a-more-precise-inferred-return-type-than-julias-built-in-return-type-inference/122064 "2024-10-31T10:19:15Z")

</div>

I was testing the inferrability of some of my code with Base.infer\_return\_type, and found a case with suboptimal abstract inference. When I tried using Cthulhu.jl to debug this, though, descend shows a more precise, opti…

---

## [Type inference difference in \`mapreduce(f, op, t)\` vs \`reduce(op, map(f, t))\`](https://discourse.julialang.org/t/type-inference-difference-in-mapreduce-f-op-t-vs-reduce-op-map-f-t/93265)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 1\
**Last updated:** [October 24, 2024, 8:42am UTC](https://discourse.julialang.org/t/type-inference-difference-in-mapreduce-f-op-t-vs-reduce-op-map-f-t/93265 "2024-10-24T08:42:21Z")

</div>

For tuples, it seems mapreduce has poorer type inference than map + reduce. julia\> using FillArrays, Infinities, InfiniteArrays, Test julia\> ax = Ones{Int}(InfiniteCardinal{0}()); julia\> y = (ax,ax); julia\> @inferred…

---

## [Extracting each iteration result in KissABC.jl](https://discourse.julialang.org/t/extracting-each-iteration-result-in-kissabc-jl/118658)

<div class="topic-metadata">

**Author:** [@Sahil\_Khan](https://discourse.julialang.org/u/Sahil_Khan)\
**Replies:** 4\
**Last updated:** [September 5, 2024, 1:34pm UTC](https://discourse.julialang.org/t/extracting-each-iteration-result-in-kissabc-jl/118658 "2024-09-05T13:34:45Z")

</div>

Hello everyone, I was wondering Is it possible to extract results from each iteration in smc( ) run in kissABC package ? I was reading the documentation link but I don’t see much there. Thank you :slight\_smile:

---

## [What are the dangers of a possible proliferation of exception types?](https://discourse.julialang.org/t/what-are-the-dangers-of-a-possible-proliferation-of-exception-types/117310)

<div class="topic-metadata">

**Author:** [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Replies:** 7\
**Last updated:** [July 24, 2024, 4:33pm UTC](https://discourse.julialang.org/t/what-are-the-dangers-of-a-possible-proliferation-of-exception-types/117310 "2024-07-24T16:33:52Z")

</div>

I vaguely remember some advice about the necessity of being conservative with the number of different exception types. I can’t remember the rationale or find any on the Web, so I’m asking here. What’s wrong with having m…

---

## [Base.return\_types and \`Test.@inferred\` conditionally failing unlike \`@code\_warntype\`](https://discourse.julialang.org/t/base-return-types-and-test-inferred-conditionally-failing-unlike-code-warntype/114902)

<div class="topic-metadata">

**Author:** [@Benny](https://discourse.julialang.org/u/Benny)\
**Replies:** 6\
**Last updated:** [May 30, 2024, 6:28am UTC](https://discourse.julialang.org/t/base-return-types-and-test-inferred-conditionally-failing-unlike-code-warntype/114902 "2024-05-30T06:28:57Z")

</div>

Experimenting with world age and ran into a weird thing. This is the session that makes sense: julia\> function evalbad(i) ex = :(globali() = $i) eval(ex) # evaluates new global method at runtime …

---

## [Inconsistency between Core.Compiler.return\_type and Test.@inferred](https://discourse.julialang.org/t/inconsistency-between-core-compiler-return-type-and-test-inferred/114246)

<div class="topic-metadata">

**Author:** [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Replies:** 1\
**Last updated:** [May 14, 2024, 12:59pm UTC](https://discourse.julialang.org/t/inconsistency-between-core-compiler-return-type-and-test-inferred/114246 "2024-05-14T12:59:03Z")

</div>

The Any here indicates a total failure of the return type inference: julia\> f(op::Op, a, b) where {Op} = op(a, b) f (generic function with 1 method) julia\> Core.Compiler.return\_type(f, Tuple{typeof(=\>),Int,Int}) Any W…

---

## [Why Julia fails to infere types in this example? What is the cost of this? What are requirements for type inference?](https://discourse.julialang.org/t/why-julia-fails-to-infere-types-in-this-example-what-is-the-cost-of-this-what-are-requirements-for-type-inference/113800)

<div class="topic-metadata">

**Author:** [@shamazmazum](https://discourse.julialang.org/u/shamazmazum)\
**Replies:** 12\
**Last updated:** [May 8, 2024, 8:10am UTC](https://discourse.julialang.org/t/why-julia-fails-to-infere-types-in-this-example-what-is-the-cost-of-this-what-are-requirements-for-type-inference/113800 "2024-05-08T08:10:44Z")

</div>

Hi! I’ve opened a bug report (#54344) on github today which was immediately closed and I was sent here. I’ve read that for a good performance @code\_warntype macro should produce an output without lines colored in red. Fo…

---

## [Tips for Estimating Non-linear Latent SDE](https://discourse.julialang.org/t/tips-for-estimating-non-linear-latent-sde/104326)

<div class="topic-metadata">

**Author:** [@dleather](https://discourse.julialang.org/u/dleather)\
**Replies:** 1\
**Last updated:** [April 7, 2024, 1:42pm UTC](https://discourse.julialang.org/t/tips-for-estimating-non-linear-latent-sde/104326 "2024-04-07T13:42:20Z")

</div>

I was hoping to use Turing.jl alongside DifferentialEquations.jl to estimate a partially observable SDE via quasi-likelihood methods. Being new to continuous-time models, I was hoping to get some suggestions on the most …

---

## [Make Julia complete the inference of some recursive code](https://discourse.julialang.org/t/make-julia-complete-the-inference-of-some-recursive-code/111449)

<div class="topic-metadata">

**Author:** [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Replies:** 2\
**Last updated:** [March 11, 2024, 2:44pm UTC](https://discourse.julialang.org/t/make-julia-complete-the-inference-of-some-recursive-code/111449 "2024-03-11T14:44:47Z")

</div>

Background I have a function with a real number input coming from a finite interval. To implement the function, I break down that interval into several subintervals and implement the function on each of them. Suppose, fo…

---

## [RFC: Some Ideas to Tackle #15276 - performance of captured variables in closures](https://discourse.julialang.org/t/rfc-some-ideas-to-tackle-15276-performance-of-captured-variables-in-closures/95260)

<div class="topic-metadata">

**Author:** [@uniment](https://discourse.julialang.org/u/uniment)\
**Replies:** 65\
**Last updated:** [February 16, 2024, 8:56pm UTC](https://discourse.julialang.org/t/rfc-some-ideas-to-tackle-15276-performance-of-captured-variables-in-closures/95260 "2024-02-16T20:56:29Z")

</div>

Naïvely written Julia should be performant. It shouldn’t take memorizing a 35-page manual to reliably beat Matlab. Unless more performance footguns are removed, it’s impossible for a package ecosystem to be performant. F…

---

## [Failure to optimize due to type recursion](https://discourse.julialang.org/t/failure-to-optimize-due-to-type-recursion/108568)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 4\
**Last updated:** [January 9, 2024, 4:56pm UTC](https://discourse.julialang.org/t/failure-to-optimize-due-to-type-recursion/108568 "2024-01-09T16:56:31Z")

</div>

I find that it is relatively easy to get non-inferred code where the mapfoldl family is involved, because their implementation has so many layers. Eg a simple example is \_length(c::Real) = 1 \_length(c::Tuple) = mapfoldl…

---

## [Infer return type from ambiguous input](https://discourse.julialang.org/t/infer-return-type-from-ambiguous-input/105396)

<div class="topic-metadata">

**Author:** [@Elmo](https://discourse.julialang.org/u/Elmo)\
**Replies:** 6\
**Last updated:** [October 26, 2023, 6:38am UTC](https://discourse.julialang.org/t/infer-return-type-from-ambiguous-input/105396 "2023-10-26T06:38:44Z")

</div>

What is the best way to help Julia’s compiler infer that the output type of the following function can only be Union{Int64, Nothing}? function inferme(x::Dict{String, Any}, y::String) if haskey(x, y) return …

---

## [How to write a unit test that checks whether a function is type stable](https://discourse.julialang.org/t/how-to-write-a-unit-test-that-checks-whether-a-function-is-type-stable/104587)

<div class="topic-metadata">

**Author:** [@CFBaptista](https://discourse.julialang.org/u/CFBaptista)\
**Replies:** 23\
**Last updated:** [October 6, 2023, 11:07am UTC](https://discourse.julialang.org/t/how-to-write-a-unit-test-that-checks-whether-a-function-is-type-stable/104587 "2023-10-06T11:07:18Z")

</div>

I want to write unit tests that check whether a function is type stable. What is currently the most recommendable way to do this? There is an old post on this subject which mentions the Traceur.jl and TraceCalls.jl pac…

---

## [Allocations when indexing (Abstract)Arrays with large dimension](https://discourse.julialang.org/t/allocations-when-indexing-abstract-arrays-with-large-dimension/103383)

<div class="topic-metadata">

**Author:** [@spionkaese](https://discourse.julialang.org/u/spionkaese)\
**Replies:** 6\
**Last updated:** [August 31, 2023, 9:49pm UTC](https://discourse.julialang.org/t/allocations-when-indexing-abstract-arrays-with-large-dimension/103383 "2023-08-31T21:49:30Z")

</div>

I’ve been working with tensors based on AbstractArrays (see https://gist.github.com/AlexanderNenninger/461f37315e45071a8c91b18d73901431 ) that map Base.getindex(A, i...) to a function call A.f(i). While the individual i…

---

## [Inference in nested quadgk](https://discourse.julialang.org/t/inference-in-nested-quadgk/99937)

<div class="topic-metadata">

**Author:** [@lxvm](https://discourse.julialang.org/u/lxvm)\
**Replies:** 0\
**Last updated:** [June 6, 2023, 1:11pm UTC](https://discourse.julialang.org/t/inference-in-nested-quadgk/99937 "2023-06-06T13:11:48Z")

</div>

There have been a handful of threads on this forum regarding long compilation times for nested quadgk calls (e.g. here) and I was wondering what are some of the possible reasons that type inference may be failing in this…

---

## [Nested sampling for Bayesian parameter estimation in Julia](https://discourse.julialang.org/t/nested-sampling-for-bayesian-parameter-estimation-in-julia/96105)

<div class="topic-metadata">

**Author:** [@tomkimpson](https://discourse.julialang.org/u/tomkimpson)\
**Replies:** 0\
**Last updated:** [March 15, 2023, 4:32am UTC](https://discourse.julialang.org/t/nested-sampling-for-bayesian-parameter-estimation-in-julia/96105 "2023-03-15T04:32:33Z")

</div>

It is a common problem to want to infer parameters (Bayesian) given some data, a set of priors on those parameters, and a (parameterised) model. In the past, coming from Python, I have used tools such as Bilby, a Python…

---

## [Constant propagation and inference of constructed types](https://discourse.julialang.org/t/constant-propagation-and-inference-of-constructed-types/36279)

<div class="topic-metadata">

**Author:** [@benninkrs](https://discourse.julialang.org/u/benninkrs)\
**Replies:** 14\
**Last updated:** [February 7, 2023, 10:49pm UTC](https://discourse.julialang.org/t/constant-propagation-and-inference-of-constructed-types/36279 "2023-02-07T22:49:01Z")

</div>

Context: I had a parameterized struct type with convenience constructors that input some of the parameters as arguments. Based on previous experience, I expected that if such constructors are provided with constant valu…

---

## [Type-inference with two variables that must have the same type](https://discourse.julialang.org/t/type-inference-with-two-variables-that-must-have-the-same-type/93421)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 13\
**Last updated:** [January 25, 2023, 4:32am UTC](https://discourse.julialang.org/t/type-inference-with-two-variables-that-must-have-the-same-type/93421 "2023-01-25T04:32:31Z")

</div>

julia\> fs() = rand(Bool) ? (1,1) : (1.0, 1.0) fs (generic function with 1 method) julia\> f(fs, i) = fs()\[i\] f (generic function with 1 method) julia\> g(fs) = (f(fs, 1), f(fs, 2)) g (generic function with 1 method) jul…

---

## [\`@inferred\` check for a small \`Union\` without being specific about the types](https://discourse.julialang.org/t/inferred-check-for-a-small-union-without-being-specific-about-the-types/93470)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 1\
**Last updated:** [January 24, 2023, 8:55pm UTC](https://discourse.julialang.org/t/inferred-check-for-a-small-union-without-being-specific-about-the-types/93470 "2023-01-24T20:55:23Z")

</div>

Suppose I have a function f(x) = x \> 1 ? 0 : x For this, I obtain julia\> @code\_warntype f(0.2) MethodInstance for f(::Float64) from f(x) @ Main REPL\[43\]:1 Arguments #self#::Core.Const(f) x::Float64 Body::Union{F…

---

## [Why are the inferred types different between collect and comprehension?](https://discourse.julialang.org/t/why-are-the-inferred-types-different-between-collect-and-comprehension/92590)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 3\
**Last updated:** [January 6, 2023, 9:23am UTC](https://discourse.julialang.org/t/why-are-the-inferred-types-different-between-collect-and-comprehension/92590 "2023-01-06T09:23:10Z")

</div>

julia\> using ApproxFun julia\> A = Derivative(); B = Multiplication(Fun()); julia\> ops = (A, B); julia\> \[ops...\] |\> eltype Operator{Float64} julia\> collect(ops) |\> eltype Operator Shouldn’t these lead to the same res…

---

## [\[ANN\] ProfileLikelihood.jl: Computing profile likelihoods](https://discourse.julialang.org/t/ann-profilelikelihood-jl-computing-profile-likelihoods/91823)

<div class="topic-metadata">

**Author:** [@DanielVandH](https://discourse.julialang.org/u/DanielVandH)\
**Replies:** 3\
**Last updated:** [December 28, 2022, 3:00am UTC](https://discourse.julialang.org/t/ann-profilelikelihood-jl-computing-profile-likelihoods/91823 "2022-12-28T03:00:00Z")

</div>

Hi all, I have just released my package ProfileLikelihood.jl that will be fully registered in a few days. The aim of this package is to provide an easy interface for computing maximum likelihood estimates (MLEs), profil…

---

## [How to use type parameter variables across multiple parametric types](https://discourse.julialang.org/t/how-to-use-type-parameter-variables-across-multiple-parametric-types/90162)

<div class="topic-metadata">

**Author:** [@christophE](https://discourse.julialang.org/u/christophE)\
**Replies:** 10\
**Last updated:** [November 12, 2022, 4:45pm UTC](https://discourse.julialang.org/t/how-to-use-type-parameter-variables-across-multiple-parametric-types/90162 "2022-11-12T16:45:33Z")

</div>

Hello Julia folk, I am testing something very simple, a dot product, and I want to ensure, it gets two arrays (or vectors) of the same length. This attempt does not work: function dot\_product{N::UInt64}(vec1::Array{Flo…

---

## [Why doesn't \`vect\` return a union-typed result if the number of elements is small?](https://discourse.julialang.org/t/why-doesnt-vect-return-a-union-typed-result-if-the-number-of-elements-is-small/87155)

<div class="topic-metadata">

**Author:** [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Replies:** 3\
**Last updated:** [September 13, 2022, 3:28pm UTC](https://discourse.julialang.org/t/why-doesnt-vect-return-a-union-typed-result-if-the-number-of-elements-is-small/87155 "2022-09-13T15:28:41Z")

</div>

Eg.: julia\> struct A end julia\> struct B end julia\> \[A(), B()\] 2-element Vector{Any}: A() B() Would it not be better to return julia\> Union{A,B}\[A(), B()\] 2-element Vector{Union{A, B}}: A() B() instead, as this…

---

## [Constructors for \`\<:Function\` types when possible, like in C++](https://discourse.julialang.org/t/constructors-for-function-types-when-possible-like-in-c/86611)

<div class="topic-metadata">

**Author:** [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Replies:** 7\
**Last updated:** [September 1, 2022, 2:13am UTC](https://discourse.julialang.org/t/constructors-for-function-types-when-possible-like-in-c/86611 "2022-09-01T02:13:32Z")

</div>

I was thinking about how C++20 added support for default constructors for stateless (with no captures) lambdas, meaning that nowadays all function object families may be default-constructible in C++. Then I realized tha…

[Next page](https://discourse.julialang.org/tag/inference/79.md?match_all_tags=true&page=1&tags%5B%5D=inference)
