Hacker News new | ask | show | jobs
by brap 501 days ago
Not strictly related, but does anyone know why JAX uses tracing and not AST via reflection?
2 comments

The short answer is that tracing is way, way easier to implement in a predictable and reliably performant way. This especially matters for distributed computation and automatic differentiation, two areas where JAX shines.

AST parsing via reflection means your ML compiler needs to re-implement all of Python, which is not a small language. This is a lot of work and hard to do well with abstractions that are not designed for those use-cases. (I believe Julia's whole language auto-diff systems struggle for essential the same reason.)

> AST via reflection

I literally am a paid ML compiler engineer and I have no idea what this means. You understand that reflection, ala looking in a mirror is about being about to identify a type's type at runtime. It has nothing to do with the AST.

Congratulations, but that's not what reflection means.

Wikipedia: "reflection is the ability of a process to examine, introspect, and modify its own structure and behavior."

Would you say inspect.getsource(func) fits the definition of reflection?

Would you say ast.parse(inspect.getsource(func)) has something to do with the AST?

> Would you say inspect.getsource(func) fits the definition of reflection?

I would say that reflection is absolutely meaningless in an an interpreted runtime because you can always query the runtime.

> Would you say ast.parse(inspect.getsource(func)) has something to do with the AST?

It has something to do with the AST but it doesn't have much to do with reflection.