Time masking for a Gaussian Random Walk

Hello !

I am having trouble masking a gaussian random walk. Let’s say I have four different items that vary over time according to a random walk. We assume that the time is discretized such that T=[0, 1, 2, …, 99]. If I have data available for all the items I create a gaussian random walk with a matrix of gaussians on which I apply a cumulative sum:

err = pm.Normal(
    "err",
    mu=0,
    sigma=sigma,
    dims=("time", "items"),
)

err = err.reshape([100, 4])

# ----------------------
# Baseline implementation
# ----------------------
cumulated_err = at.cumsum(err, axis=0)
cumulated_err = cumulated_err.reshape([100, 4])

Now let’s assume that for item 1 I do not have data until time 10 such that I need to mask the first 10 instants of this item. I tried the following but I get divergences (block with Masking option):

err = pm.Normal(
    "err",
    mu=0,
    sigma=sigma,
    dims=("time", "items"),
)

err = err.reshape([100, 4])

# -------------------
# Masking option
# -------------------
# Manual definition of cumulated err to take into account
# missing temporal data of some items
items_range = {
    0: [10, 100],
    1: [0, 100],
    2: [0, 100],
    3: [0, 100],
}
list_cum_err = list()
for i in range(4):
    start, end = items_range[i]
    tmp_cum_err = pm.math.concatenate(
        [
            at.zeros(start),
            at.cumsum(err[start:end, 0, i], axis=0),
            at.zeros(100 - end),
        ], axis=0)
    list_cum_err.append(tmp_cum_err)
cumulated_err = pm.math.concatenate(list_cum_err, axis=0)
cumulated_err = cumulated_err.reshape([100, 4])

And setting the items range to the full range does not give me the same behaviour as the reference implementation as I also have divergences:

items_range = {
    0: [0, 100],
    1: [0, 100],
    2: [0, 100],
    3: [0, 100],
}

Any ideas as to why my “manual” concatenation does not behave like the cumsum function :)?
Any help would be appreciated!