# What are the effects of maxtypeoffset! and maxtypedepth! in Enzyme?

**URL:** <https://discourse.julialang.org/t/what-are-the-effects-of-maxtypeoffset-and-maxtypedepth-in-enzyme/127039>\
**Category:** Numerics\
**Tags:** question, autodiff, enzyme\
**Created:** [March 17, 2025, 4:19am UTC](https://discourse.julialang.org/t/what-are-the-effects-of-maxtypeoffset-and-maxtypedepth-in-enzyme/127039 "2025-03-17T04:19:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ToPo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/topo/32/205868_2.png) [@ToPo](https://discourse.julialang.org/u/ToPo)\
**Post date:** [March 17, 2025, 4:19am UTC](https://discourse.julialang.org/t/what-are-the-effects-of-maxtypeoffset-and-maxtypedepth-in-enzyme/127039/1 "2025-03-17T04:19:31Z")

</div>

I use automatic differentiation by Enzyme.jl.  
What are the functions of the two APIs, **maxtypeoffset!** and **maxtypedepth!**?  
I want to use these APIs to stabilize the operation of the Enzyme.jl.

- maxtypeoffset!  
What is the maximum offset to type that Enzyme considers?  
The default is 512, is this the value of memory used?  
For example, what happens if we change from 512 to 1024?

- maxtypedepth!  
Does this depth mean the depth that can be nested in the structure?  
It is my understanding that the depth is 2 when the automatic differentiation is applied to the calculation involving structure B in the following cases.  
I believe that if there are more nests than this depth, the Enzyme will not be able to check the type well.

```julia
struct A
    val::Float64
end

struct B
    a::A
end

```

If anyone knows, I would appreciate it if you could let me know.
