Skip to content

AI-generated implementations for DaCe library nodes - #2557

Open
tbennun wants to merge 10 commits into
mainfrom
worktree-ai-library-nodes
Open

AI-generated implementations for DaCe library nodes#2557
tbennun wants to merge 10 commits into
mainfrom
worktree-ai-library-nodes

Conversation

@tbennun

@tbennun tbennun commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

This PR provides two elements:

  1. A reserved 'ai' implementation, available on every library node. Expanding with it asks a language model to write the replacement tasklet, given the node's context in the SDFG and on the local machine.
  2. dace.libraries.ai.nodes.ai_node.AINode, a library node that carries only a natural-language description, for microkernels that have no library node of their own.
  3. ai.refine allows AI sessions to refine the implementation (e.g., if it crashes or not fast enough)

The model is reached through a provider selected by the ai.provider configuration entry. It supports the Anthropic Messages API, the OpenAI Responses API, and arbitrary AI models through a manual mode that lets you paste prompts and responses.

@tbennun
tbennun force-pushed the worktree-ai-library-nodes branch from 7e32b3a to 9943722 Compare September 7, 2026 07:49
node to begin with -- a microkernel DaCe does not expose, a vendor intrinsic sequence, a call
into an external library -- so the description *is* the specification::

node = AINode('fma', 'Compute out = a * b + c elementwise over the whole tile.',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the pure/naive lowering of the Library can be provided to describe the semantics on a more constrained way?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the pure/native lowering can be arbitrarily complex (with e.g., multiple maps in reduce) and so it might require a lot of prompt real estate and to actually use the dace codegen (or print out e.g. a schedule tree?)

Not sure. Potential future work?

@ThrudPrimrose ThrudPrimrose Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, also to consider a library node implementation valid we should use symbolic shapes to create fuzzed correctness tests.

I think this should be a future work, I'm doing this for the ICLR submission, we can expand this after ICLR submission. Having measures against reward-hacking and vagueness is critical to avoid token wastage.

desc='Natural-language description of what this node must compute. This is '
'the specification handed to the model, so state the intended semantics, '
'the expected numerical behavior, and any implementation technique that is '
'required (e.g. "use AVX2 intrinsics").')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think DaCe could (or should?) provide a default pre- or post-amble for the description that DaCe requires input language in C++, CUDA, HIP or Python for library node implementations.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, already part of the prompt (see prompt.py)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants