question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

scan abstract values and tree prefix convention bug

See original GitHub issue

Repro from @fehiepsi in the #772 thread:

import jax.numpy as np
from jax import jit, grad, lax
from jax.config import config; config.update("jax_platform_name", "cpu")

def f(init_s):
    seasonality = init_s.shape[0]

    def scan_fn(carry, t):
        level, s, moving_sum = carry
        season = s[0] * level ** 0.6
        exp_val = level + 2 * level ** 0.5 + season
        exp_val = np.clip(exp_val, a_min=0)

        moving_sum = moving_sum + y[t] - np.where(t >= seasonality, y[t - seasonality], 0.)
        #level_p = np.where(t >= seasonality, moving_sum / seasonality, y[t] - season)
        #level = 0.2 * level_p + (1 - 0.2) * level
        level = np.clip(level, a_min=0)
        new_s = (0.3 * (y[t] - level) / season + (1 - 0.3)) * s[0]
        s = np.concatenate([s[1:], new_s[None]], axis=0)
        return (level, s, moving_sum), exp_val

    y = np.ones(80)
    level_init = y[0]
    s_init = np.concatenate([init_s[1:], init_s[:1]], axis=0)
    moving_sum = level_init
    (last_level, last_s, moving_sum), exp_vals = lax.scan(
        scan_fn, (level_init, s_init, moving_sum), np.arange(1, y.shape[0]))
    return exp_vals.sum()

f(np.ones(38))
jit(f)(np.ones(38))  # Type Error

I think this is related to partial_eval._split_avals not instantiating tuple-trees of units but instead truncating at the same tree prefix as the second_component tree.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
mattjjcommented, Aug 13, 2019

@fehiepsi I believe we have a branch that will close this. Hoping to merge sometime this week.

1reaction
fehiepsicommented, Jun 11, 2019

Here is a much smaller repro code that exercises this issue:

import jax.numpy as np
from jax import jit, lax

def f(s):
    def scan_fn(carry, t):
        a, b = carry
        return (a, b), a + b

    _, bs = lax.scan(scan_fn, (0., s), np.arange(10))
    return bs.sum()

print(f(np.array(1.)))
jit(f)(np.array(1.))
Read more comments on GitHub >

github_iconTop Results From Across the Web

Java static code analysis: Abstract class names should comply ...
Unique rules to find Bugs, Vulnerabilities, Security Hotspots, and Code Smells in your JAVA ... Abstract class names should comply with a naming...
Read more >
Bug listing with status RESOLVED with resolution OBSOLETE ...
Bug:1523 - "[IDEA] Offload work by distributing trivial ebuild ... sometimes crashes vdr while scanning" status:RESOLVED resolution:OBSOLETE severity:normal ...
Read more >
Database Engine events and errors - SQL Server
Consult this MSSQL error code list to find explanations for error messages for SQL Server database engine events.
Read more >
RFC 6020: YANG - A Data Modeling Language for the ...
RFC 6020 YANG October 2010 o list: An interior data node that may exist in multiple instances in the data tree. A list...
Read more >
W3C XML Schema Definition Language (XSD) 1.1 Part 1
This chapter gives an overview of XML Schema Definition Language: Structures at the level of its abstract data model.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found