Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Revert "[frontend] Remove Complex Regex for MLIR Parsing (#4924)"" #2681

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

anmyachev
Copy link
Contributor

@anmyachev anmyachev commented Nov 11, 2024

Closes #2653

This reverts commit ecc9bd4.

The issue looks like:

loc("/tmp/pytest-of-runner/pytest-0/popen-gw0/test_convert2d_dst_layout8_int21/test_convert2d.ttgir":4:30): error: #"triton_intel_gpu"<"dpas<{repeatCount=8, systolicDepth=8, executionSize = 8, opsPerChan = 1, threadsPerWarp = 32, warpsPerCTA=[4, 1], repCluster=[1, 1]}>"> : 'none' attribute created with unregistered dialect. If this is intended, please call allowUnregisteredDialects() on the MLIRContext, or use -allow-unregistered-dialect with the MLIR opt tool used

Comment on lines 100 to 102
target = driver.active.get_current_target()
backend = make_backend(target)
backend.load_dialects(context)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The main change is that for our backend, parse_mlir_module function only works correctly with the corresponding dialects.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why DPAS layout requires additional dialects while MMA layout doesn't?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

MMA layout belongs to triton_gpu dialect:

return f"#{GPU_DIALECT}.nvidia_mma<{{versionMajor={self.version[0]}, versionMinor={self.version[1]}, warpsPerCTA={self.warps_per_cta}, CTAsPerCGA={self.ctas_per_cga}, CTASplitNum={self.cta_split_num}, CTAOrder={self.cta_order}, instrShape={self.instr_shape}}}>"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dpas explicitly redefines the dialect (that implicitly comes from DistributedEncoding IIUC):

def DpasEncodingAttr : DistributedEncoding<"DpasEncoding", "intel_dpas_encoding",
[MmaEncodingTrait], TritonIntelGPU_Dialect> {

@anmyachev anmyachev marked this pull request as ready for review November 12, 2024 14:08
context = ir.context()
ir.load_dialects(context)
backend.load_dialects(context)

Copy link
Contributor

Choose a reason for hiding this comment

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

This is different from upstream code:

image

The "else" part is missing.... perhaps it belongs to a more recent upstream commit than the one we are trying to merge ?

Also, would adding the else part eliminate the need to add lines 100-103 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is different from upstream code:

Yes, I made this change on purpose. Now, as far as I understand, the backend dialects should be initialized when calling the IRSource class constructor.

Also, would adding the else part eliminate the need to add lines 100-103 ?

No, because IRSource constructor also calls function self.module = ir.parse_mlir_module(self.path, context), which requires the backend dialects.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One example, we use dpas layout that requires an additional dialect:

DpasLayout(repeatCount=8, systolic_depth=8, execution_size=8, ops_per_chan=1, threads_per_warp=32,

Copy link
Contributor

@whitneywhtsang whitneywhtsang left a comment

Choose a reason for hiding this comment

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

Can this change be upstreamed?

Comment on lines 100 to 102
target = driver.active.get_current_target()
backend = make_backend(target)
backend.load_dialects(context)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why DPAS layout requires additional dialects while MMA layout doesn't?

Signed-off-by: Anatoly Myachev <anatoly.myachev@intel.com>
Signed-off-by: Anatoly Myachev <anatoly.myachev@intel.com>
@anmyachev
Copy link
Contributor Author

Can this change be upstreamed?

I think there is a chance. I brought it to a form more similar to what I am trying to upstream.

@etiotto @whitneywhtsang could we merge it?

@etiotto
Copy link
Contributor

etiotto commented Nov 15, 2024

@anmyachev what is the upstream PR for this changes ? Can you open an issue to track upstreaming the changes as well please ?

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.

Reland upstream commit 038cbc5
3 participants