Skip to content

feat: add post 'The Good, the Bad, the Brittle. Fusing Attention in ONNX Graphs'✨#11

Open
KarelZe wants to merge 38 commits into
masterfrom
attention-fusion
Open

feat: add post 'The Good, the Bad, the Brittle. Fusing Attention in ONNX Graphs'✨#11
KarelZe wants to merge 38 commits into
masterfrom
attention-fusion

Conversation

@KarelZe
Copy link
Copy Markdown
Owner

@KarelZe KarelZe commented Jun 8, 2025

No description provided.

@KarelZe KarelZe force-pushed the attention-fusion branch from 0f97724 to 4813e1d Compare June 8, 2025 15:12
@KarelZe KarelZe self-assigned this Jun 9, 2025
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds a new blog post about attention fusion in ONNX graphs, covering approaches using onnxruntime and onnxscript. It also includes minor configuration updates and a small stylistic change in another post. The new post provides valuable insights and code examples, although some code snippets are incomplete or have minor issues like missing imports and hardcoded paths. Addressing these will improve the clarity and usability of the examples.

Comment thread content/post/attention-fusion-onnx/index.md
Comment on lines +289 to +293
ir.passes.Sequential(
onnxscript.rewriter.RewritePass([rule]),
common_passes.RemoveUnusedNodesPass(),
common_passes.ShapeInferencePass(),
)(onnx_model)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The common_passes module is used here but not imported in the code snippet. Please add the necessary import.

Suggested change
ir.passes.Sequential(
onnxscript.rewriter.RewritePass([rule]),
common_passes.RemoveUnusedNodesPass(),
common_passes.ShapeInferencePass(),
)(onnx_model)
ir.passes.Sequential(
onnxscript.rewriter.RewritePass([rule]),
onnxscript.ir.passes.common_passes.RemoveUnusedNodesPass(),
onnxscript.ir.passes.common_passes.ShapeInferencePass(),
)(onnx_model)

),
name="qkv_bias",
)
num_heads = _ir_utils.get_dim(q_reshaped, 2)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The _ir_utils module is used here but not imported in the code snippet. Please add the necessary import.

Suggested change
num_heads = _ir_utils.get_dim(q_reshaped, 2)
num_heads = onnxscript.ir.utils.get_dim(q_reshaped, 2)

Comment on lines +205 to +206
gathered_shape = op.Gather(shape, op.Constant(), axis=0)
q_unsqueezed_shape = op.Unsqueeze(gathered_shape, op.Constant())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Using op.Constant() without arguments in the pattern might match any constant node, which may not be specific enough to correctly identify the shape constants used in the original graph. Consider using pattern.ANY_VALUE if the exact constant value doesn't matter for the match, or matching specific constant values if they are fixed.

Comment thread content/post/attention-fusion-onnx/index.md
Comment thread content/post/attention-fusion-onnx/index.md Outdated
@KarelZe KarelZe changed the title feat: add post The Good, the Bad, the Brittle. Fusing Attention in ONNX Graphs✨ feat: add post 'The Good, the Bad, the Brittle. Fusing Attention in ONNX Graphs'✨ Jun 21, 2025
@KarelZe KarelZe changed the title feat: add post 'The Good, the Bad, the Brittle. Fusing Attention in ONNX Graphs'✨ feat: add post 'The Good, the Bad, the Brittle. Fusing Attention in ONNX Graphs'✨ (part 1) Jun 22, 2025
@KarelZe KarelZe changed the title feat: add post 'The Good, the Bad, the Brittle. Fusing Attention in ONNX Graphs'✨ (part 1) feat: add post 'The Good, the Bad, the Brittle. Fusing Attention in ONNX Graphs' Jun 30, 2025
@KarelZe KarelZe changed the title feat: add post 'The Good, the Bad, the Brittle. Fusing Attention in ONNX Graphs' feat: add post 'The Good, the Bad, the Brittle. Fusing Attention in ONNX Graphs'✨ Jun 30, 2025
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.

1 participant