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

Use module attribute to specify target arch. #3387

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ienkovich
Copy link
Contributor

This variant makes the target arch attribute mandatory for conversion to the LLVM dialect. We can fall back to the optional attribute if it looks too intrusive.

@ienkovich ienkovich force-pushed the ienkovich/target-arch-attr branch from c531872 to b5eeb9e Compare February 10, 2025 21:49
op = op->getParentOfType<ModuleOp>();
auto arch = op->getAttrOfType<StringAttr>(
triton::gpu::intel::TritonIntelGPUDialect::getTargetArchAttrName());
assert(arch);
Copy link
Contributor

Choose a reason for hiding this comment

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

Add an assert message pls.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -46,6 +47,16 @@ inline unsigned getNumElementsPerThread(
inline bool applyTransposedReduction() {
return tools::getBoolEnv("TRITON_INTEL_REDUCE_TRANSPOSE");
}

// Check if module's target arch is SPIRV.
inline bool hasSpirvTargetArch(Operation *op) {
Copy link
Contributor

@etiotto etiotto Feb 10, 2025

Choose a reason for hiding this comment

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

Should we require the user to pass a ModuleOp rather than a generic operation ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought accepting any nested op would be more convenient

@ienkovich ienkovich force-pushed the ienkovich/target-arch-attr branch from b5eeb9e to a7f5a86 Compare February 11, 2025 02:19
@whitneywhtsang
Copy link
Contributor

This variant makes the target arch attribute mandatory for conversion to the LLVM dialect. We can fall back to the optional attribute if it looks too intrusive.

My preference is to fall back to the optional attribute, as the original design is to rely on features attributes given either by PyTorch or ocloc query. One concern is by having the target arch attribute, passes will start to make assumptions based on that.

@ienkovich
Copy link
Contributor Author

My preference is to fall back to the optional attribute, as the original design is to rely on features attributes given either by PyTorch or ocloc query. One concern is by having the target arch attribute, passes will start to make assumptions based on that.

This new attribute is orthogonal to the set of features. There is a set of features and a target arch that affects how you get access to those features.

We shouldn't use this attribute to assume HW features. I don't see how optionality can resolve your concern. We should just see that nobody tries to use the target arch attribute to make any feature assumptions because different target archs can be used for the same target HW.

@whitneywhtsang
Copy link
Contributor

This new attribute is orthogonal to the set of features. There is a set of features and a target arch that affects how you get access to those features.

We shouldn't use this attribute to assume HW features. I don't see how optionality can resolve your concern. We should just see that nobody tries to use the target arch attribute to make any feature assumptions because different target archs can be used for the same target HW.

Having target arch attribute increases the chance one uses it to assume HW features, but we can try to prevent that with code reviews, so I am not against this change.

@ienkovich
Copy link
Contributor Author

@whitneywhtsang @etiotto Layout-related tests fail because they use TTGIR as an input and it doesn't have the required attribute. I can add more test modifications to resolve it, but I think we better get back to the optional attribute. What do you think?

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.

3 participants