Skip to content

feat(compile): graph-output pruning for export + finite causal mask - #760

Merged
michalharakal merged 2 commits into
developfrom
feature/stablehlo-output-pruning
Jun 24, 2026
Merged

michalharakal merged 2 commits into
developfrom
feature/stablehlo-output-pruning

Conversation

@michalharakal

Copy link
Copy Markdown
Contributor

What

StableHLO/IREE export hygiene for decoder graphs, toward unblocking the Llama→IREE path (#759).

  • Graph-output pruning — OutputDesignatedGraph (compile-dag) + ComputeGraph.prunedToOutputs(outputNodeIds) (compile-opt, = designate outputs + DeadCodeEliminationPass). A traced decoder marks every leaf as a graph output, so the export returned the logits plus ~44 dangling per-layer intermediates (extra func returns + dead subgraphs). Exporters can now keep only the logits. Verified on a real TinyLlama export: 45 outputs → 1, 1467 → 1247 nodes, attention intact. Adds GraphPruningTest.
  • SDPA causal mask — the attention HLO converter's causal path now emits -1.000000e+30 instead of -inf (0xFF800000) for the masked-fill, matching MultiHeadAttention.buildSlidingCausalMask (numerically equivalent after softmax; avoids a -inf splat in the IR).

Why

Part of fixing the iree-compile decoder-export crash (#759). This removes the dangling-output contribution and the -inf splat. It does not fully fix #759 — a deeper trigger remains (K activations are const-folded into parameters during the VoidTensorOps+embedConstants export, and IREE's insert_slice/extract_slice fold over those frozen constants null-derefs). That root cause is documented in #759 and is the next step.

Test

  • :skainet-compile:skainet-compile-opt:jvmTest --tests "*GraphPruningTest" ✅
  • Affected modules compile (compile-dag, compile-opt, compile-hlo).

Refs #759

🤖 Generated with Claude Code

A traced decoder marks every leaf tensor as a graph output, so a StableHLO/IREE export
returns the logits plus dozens of dangling per-layer intermediates (extra func returns +
dead op subgraphs). Add OutputDesignatedGraph (compile-dag) to override the output set by
node id, and ComputeGraph.prunedToOutputs(ids) (compile-opt) = designate + DeadCodeElimination,
so an exporter keeps only the logits. Verified on a real TinyLlama export: 45 outputs -> 1,
1467 -> 1247 nodes, attention intact. Adds GraphPruningTest.

Also: SDPA causal-mask converter emits -1e30 instead of -inf (0xFF800000) for the masked-fill,
matching buildSlidingCausalMask (numerically equivalent after softmax; avoids a -inf splat).

Refs the iree-compile decoder-export crash (constant-fold null-deref); this removes the
dangling-output contribution. A deeper trigger (K activations frozen as constants) is tracked
separately.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@michalharakal
michalharakal changed the base branch from release/0.31.2 to develop June 24, 2026 19:18
@michalharakal
michalharakal merged commit c9680a5 into develop Jun 24, 2026
3 of 4 checks passed
@michalharakal
michalharakal deleted the feature/stablehlo-output-pruning branch June 25, 2026 13:50
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.

iree-compile crash on decoder StableHLO export: const-fold null-deref (frozen K activations)

1 participant