Skip to content

feat: InlineHint metadata#1532

Open
aborgna-q wants to merge 1 commit intomainfrom
ab/inline-funcs-meta
Open

feat: InlineHint metadata#1532
aborgna-q wants to merge 1 commit intomainfrom
ab/inline-funcs-meta

Conversation

@aborgna-q
Copy link
Copy Markdown
Collaborator

Follow up to #1524. Defines a metadata value for hinting the compiler on which functions to inline.

Part of Quantinuum/hugr#2328.

Note that this definition is rust-only. We still need to add exports for all tket metadata definitions on the python bindings.

Guppy issue/PR (they'll need to be updated):

@aborgna-q aborgna-q requested a review from acl-cqc April 21, 2026 10:37
@aborgna-q aborgna-q requested a review from a team as a code owner April 21, 2026 10:37
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.82%. Comparing base (9a25ec8) to head (bb5d1f2).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1532      +/-   ##
==========================================
+ Coverage   83.79%   83.82%   +0.02%     
==========================================
  Files         188      188              
  Lines       29032    29036       +4     
  Branches    27928    27932       +4     
==========================================
+ Hits        24326    24338      +12     
+ Misses       3543     3536       -7     
+ Partials     1163     1162       -1     
Flag Coverage Δ
python 92.32% <ø> (ø)
qis-compiler 91.66% <ø> (ø)
rust 83.48% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

@acl-cqc acl-cqc left a comment

Choose a reason for hiding this comment

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

Ok let's combine functionality (not necessarily PRs) here with #1449.
I've updated that to use a similar metadata (there without the Never, with #[non_exhaustive], and I called it InlineAnnotation rather than hint, but at least it's in the same place ;-)).
Noting that #1524 uses inline_acyclic which will mean any function on a cycle will not be inlined at all (cycles are removed from graph rather than merely broken), I think #1449 handles the "Always" bit better, so that can be run first as a separate pass.

Thus, either (a) put this in first, but without the Always option (to be added in 1449); or (b) let's get #1449 in first and then this can add the Never option. I don't really mind which way around, and I think #1449 can be marked ready now (probably for a random reviewer? But you might want to check over the annotation).

WRT this PR:

  • I am also unsure about "follow_hints=False" still respecting the "Never" hint; are we sure it shouldn't follow that too? (Otherwise, follow_hints will do nothing when Always is removed. One could say "Always is not a hint" but an annotation, iow it's correct for "follow_hints" to have no effect until we add some InlineAnnotation::XYZHint).
  • Would be nice to add to the heuristic here that (non-preserved?) functions with only one call "are always small enough" ;)
  • I haven't checked what you're doing here, but I note it's quite tricksy doing inlining respecting PassScope::EntrypointXXX :(

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