Skip to content

Tracing on optimized IR? #40

@ToucheSir

Description

@ToucheSir

This is a speculative issue instead of a speculative PR because I'm not sure what the implementation ought to look like, but wanted to write it down for posterity:

My understanding is that, presently, Umlaut works with typed but unoptimized IR because inlining and related optimizations might dismantle primitives before they can be detected by isprimitive. So how do some AD libraries (Enzyme and Diffractor) make custom rules/primitives work on optimized IR given only static information? It turns out that they use the AbstractInterpreter API, specifically overriding Core.Compiler.inlining_policy. This is apparently sufficient to prevent inlining of selected function calls.

So the question becomes whether Umlaut can also use this inlining control mechanism to fetch optimized typed IR. Functions like code_typed already support passing in a custom AbstractInterpreter. The main challenges I see are that isprimitive assumes you're passing values instead of just types, the compiler APIs used are somewhat complex and compiler internals shift (i.e. break backwards compat) quite a bit across different Julia versions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions