Skip to content

[MLIR][Quant] Add alias type printing for BlockFloat#803

Open
jorickert wants to merge 2 commits intoaie-publicfrom
jrickert.mx6_alias
Open

[MLIR][Quant] Add alias type printing for BlockFloat#803
jorickert wants to merge 2 commits intoaie-publicfrom
jrickert.mx6_alias

Conversation

@jorickert
Copy link
Copy Markdown
Contributor

No description provided.


// -----

// CHECK: !bfp16_bf = !quant.block_float<mode=BFP16, axis=1>
Copy link
Copy Markdown
Contributor Author

@jorickert jorickert Feb 26, 2026

Choose a reason for hiding this comment

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

I am not very happy with the _bf suffix. As mlir does not allow an alias to end in a number, another approach would be to use _ as suffix or adjust MLIR to allow aliases to end in a number

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.

Do you know if there is a hard requirement why this constraint is enforced? For types, it's quite common to end in numbers.

Otherwise, for me it's fine the way it is.
A few other suggestions just for fun:

  • mx6t (t for "type")
  • mx6+
  • mx6!

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.

I like mx6!, bfp16! !

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In commit b9f07f40ae3b074f42203491d22a83aa2670864c (i plan to upstream this one) i lifted the restriction that alias can not end in a number. Now it can simply be mx6 and bfp16

@jorickert jorickert requested a review from gerion-amd February 27, 2026 10:42
gerion-amd
gerion-amd previously approved these changes Mar 4, 2026
Copy link
Copy Markdown
Contributor

@gerion-amd gerion-amd left a comment

Choose a reason for hiding this comment

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

Thanks. I think, it's much easier to read with that.

if (!blockType)
return AliasResult::NoAlias;
if (blockType.getAxis() != 1)
return AliasResult::NoAlias;
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.

Maybe we want this to encode the axis in the type (e.g. mx6_1bf) some time in the future, but I see no blocker for this with the current design.


// -----

// CHECK: !bfp16_bf = !quant.block_float<mode=BFP16, axis=1>
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.

Do you know if there is a hard requirement why this constraint is enforced? For types, it's quite common to end in numbers.

Otherwise, for me it's fine the way it is.
A few other suggestions just for fun:

  • mx6t (t for "type")
  • mx6+
  • mx6!

ttjost
ttjost previously approved these changes Mar 5, 2026
Copy link
Copy Markdown
Contributor

@ttjost ttjost left a comment

Choose a reason for hiding this comment

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

Could you check how ! would look like as the last character? It looks prettier than what you have right now, IMO.

@jorickert jorickert dismissed stale reviews from ttjost and gerion-amd via 6eb12a5 March 5, 2026 15:55
@jorickert jorickert force-pushed the jrickert.mx6_alias branch from 486ada0 to 6eb12a5 Compare March 5, 2026 15:55
@jorickert jorickert added the upstream PRs to upstream label Mar 5, 2026
@jorickert jorickert requested review from gerion-amd and ttjost March 5, 2026 15:57
…with a digit.

To prevent collisions when multiple aliases are registered with the same
name, keep track of all used aliases and skip used ones when generating
conflict-resolving suffixes.

This does not affect the reading of .mlir files, but will affect the
printing of aliases that end in a digit, as they won't have an _
appended anymore.

Signed-off-by: Jonas Rickert <jonas.rickert@amd.com>
Signed-off-by: Jonas Rickert <jonas.rickert@amd.com>
@jorickert jorickert force-pushed the jrickert.mx6_alias branch from 6eb12a5 to f3caaa5 Compare March 10, 2026 11:07
Copy link
Copy Markdown
Contributor

@ttjost ttjost left a comment

Choose a reason for hiding this comment

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

I wonder if disambiguation is the only reason for not having the support for trailing digits in the first place. If it is, then LGTM, but I think it makes more sense to open a PR upstream to get an idea of why we didn't allow it in the first place. Then we can merge this safely.

@jorickert
Copy link
Copy Markdown
Contributor Author

I wonder if disambiguation is the only reason for not having the support for trailing digits in the first place. If it is, then LGTM, but I think it makes more sense to open a PR upstream to get an idea of why we didn't allow it in the first place. Then we can merge this safely.

Upstream completely changed the implementation of the alias printing, its now part of the type not dialect. :-/

@gerion-amd
Copy link
Copy Markdown
Contributor

I wonder if disambiguation is the only reason for not having the support for trailing digits in the first place. If it is, then LGTM, but I think it makes more sense to open a PR upstream to get an idea of why we didn't allow it in the first place. Then we can merge this safely.

Upstream completely changed the implementation of the alias printing, its now part of the type not dialect. :-/

What is the consequence? Should we bump first or still merge? If bumping is not an option in the near future, I would still merge it, if we can achieve the same MLIR syntax after the bump.

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

Labels

upstream PRs to upstream

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants