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

#10860: Split Conv2dConfig into Compute config #15164

Merged
merged 23 commits into from
Dec 9, 2024

Conversation

sankarmanoj-tt
Copy link
Contributor

@sankarmanoj-tt sankarmanoj-tt commented Nov 18, 2024

Ticket

#10860

Problem description

Conv2dConfig contains Compute kernel specific arguments which should be passed using DeviceComputeKernelConfig

What's changed

Removed compute kernel arguments from Conv2dConfig. conv2d takes an additional argument called compute_config. Used pybind to expose helper functions to create DeviceComputeKernelConfig from the model code.

Checklist

ttnn/ttnn/device.py Outdated Show resolved Hide resolved
@@ -102,8 +102,10 @@ Result conv_transpose2d(
std::array<uint32_t, 2> dilation,
uint32_t groups,
std::optional<const ttnn::Tensor> bias_tensor,
std::optional<const conv2d::Conv2dConfig> conv_config_) {
std::optional<const conv2d::Conv2dConfig> conv_config_,
std::optional<const DeviceComputeKernelConfig> compute_config_) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would do pass by const ref for compute_config_, not just here but in general

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should conv_config also be pass by const ref?

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 can make this change in a different PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I think there is PR in flight that does this in general
#15187

Copy link
Contributor

@pavlejosipovic pavlejosipovic left a comment

Choose a reason for hiding this comment

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

You need go over all instances of ttnn.Conv2dConfig() in the code and fixup params.
I see that many of them still accept math_fidelity for example

@sankarmanoj-tt sankarmanoj-tt force-pushed the smanoj/conv_compute_config branch from 0728049 to 290ed51 Compare November 19, 2024 19:51
}
if (conv_config.reallocate_halo_output) {
auto move_output = ttnn::operations::core::reallocate(halo_output, halo_output.memory_config());
ttnn::operations::core::deallocate(halo_output);
Copy link
Contributor

Choose a reason for hiding this comment

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

doesn't reallocate already deallocate its input?

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'm not certain. From a quick read through of the reallocate implementation, it looks like it does. I have removed the deallocate.

math_approx_mode=math_approx_mode,
dst_full_sync_en=dst_full_sync_en,
)
else:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should check if is_grayskull instead of defaulting to it.

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.

@bbradelTT
Copy link
Contributor

Please after this PR look at init_device_compute_kernel_config and see how to remove it.

I assume we just have to construct/build the DeviceKernelConfig. Having method like "init_device.." in ttnn is very misleading. It almost looks like I must call it once to initialize something and thats it.

It's a useful utility function that hides creating an object based on device type. If anything we should rename it to something like get_compute_kernel_config

@sankarmanoj-tt sankarmanoj-tt merged commit 612744d into main Dec 9, 2024
119 checks passed
@sankarmanoj-tt sankarmanoj-tt deleted the smanoj/conv_compute_config branch December 9, 2024 07:37
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.