-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[microNPU] Add various options to the cascader #10509
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jacobbohlin, looks good to me in general, mostly nits and questions :)
if len(self.output_shape) != len(other.output_shape): | ||
return False | ||
|
||
return other >= self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it supposed to be similar to the comparison in __ge__
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I thought the easiest way to define strict less than in this case was as the inverse of greater or equal, i.e. __ge__
.
output_cycles = self._get_output_cycles( | ||
op_type, op_str, ifm_dtype, ofm_dtype, activation | ||
) | ||
output_cycles *= reduce(lambda a, b: a * b, block_shape, 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe np.prod(block_shape)
for simplicity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's probably simpler, I will change it.
break | ||
if select_proposal_idx != -1: | ||
# Manually select proposal based on index | ||
proposal_choice = proposals[select_proposal_idx % len(proposals)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the % len(proposals)
for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just to ensure that we always select a proposal. I can add a comment to clarify.
/*! \brief Flag to disable pareto culling for proposals to allow non pareto-optimal proposals */ | ||
bool disable_pareto_proposals; | ||
/*! \brief Whether to consider multi-dimensional striping */ | ||
bool multi_dimensional_striping; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe enable_multi_dimensional_striping
to match with other similar variables
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good!
TVM_ATTR_FIELD(dev_force_block_config) | ||
.describe( | ||
"Force the block config to a given value; format = " | ||
"\"[BLK_HEIGHT]x[BLK_WIDTH]x[BLK_DEPTH]\"") | ||
.set_default(""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should that dev option also also come with a dev_warning
?
expected_stripe_configs = { | ||
cs.StripeConfig([1, 1], [400, 400], [1, 1], [1, 2], [400, 400], [0, 0]), | ||
cs.StripeConfig([1, 1], [400, 400], [1, 1], [2, 1], [400, 400], [0, 0]), | ||
cs.StripeConfig([200, 1], [400, 400], [200, 1], [1, 2], [2, 400], [0, 0]), | ||
cs.StripeConfig([200, 1], [400, 400], [200, 1], [2, 1], [2, 400], [0, 0]), | ||
cs.StripeConfig([400, 1], [400, 400], [400, 1], [2, 1], [1, 400], [0, 0]), | ||
cs.StripeConfig([1, 200], [400, 400], [1, 200], [1, 2], [400, 2], [0, 0]), | ||
cs.StripeConfig([1, 200], [400, 400], [1, 200], [2, 1], [400, 2], [0, 0]), | ||
cs.StripeConfig([200, 200], [400, 400], [200, 200], [2, 1], [2, 2], [0, 0]), | ||
cs.StripeConfig([200, 200], [400, 400], [200, 200], [1, 2], [2, 2], [0, 0]), | ||
cs.StripeConfig([400, 200], [400, 400], [400, 200], [2, 1], [1, 2], [0, 0]), | ||
cs.StripeConfig([1, 400], [400, 400], [1, 400], [1, 2], [400, 1], [0, 0]), | ||
cs.StripeConfig([200, 400], [400, 400], [200, 400], [1, 2], [2, 1], [0, 0]), | ||
cs.StripeConfig([400, 400], [400, 400], [400, 400], [1, 2], [1, 1], [0, 0]), | ||
} | ||
|
||
output_stripe_configs = _generate_output_stripe_configs( | ||
part=part_1, stripe_factors=stripe_factors, multi_dimensional=True | ||
) | ||
|
||
assert len(output_stripe_configs) == len(expected_stripe_configs) | ||
assert set(output_stripe_configs) == expected_stripe_configs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to have some tests for the various culling disabling options. Is it possible to compare sets of plans, proposals or block configs similarly to how it is done here for the stripe configs? In that case we could have similar regressions tests for non optimal proposals, plans and block configs.
4dbc61d
to
61a78c7
Compare
a3e03cd
to
eb788dc
Compare
Might need to retrigger the CI... |
eb788dc
to
f518c57
Compare
* Added option to toggle multi-dimensional striping, it is disabled by default because it has a very high computational cost. Single dimension striping shares most of the benefit with greatly reduced cost. * Added multiple developer/debugging options prefixed with 'dev_' Also added these options to tvmc. * Added cascader logging, if enabled it will dump information about the cascader proposals to a 'cascader_log.json' file. Co-authored-by: Matthew Barrett <[email protected]> Change-Id: I2ec59ae0bd84b73b2cc4bc56d39e3831b0aeec27
f518c57
to
0e304b8
Compare
Also added enable_striping to plan_generator.h Change-Id: I496b30ed6af6f0730087329cd81a69c5040a5e4d
0e304b8
to
4dddb0e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Thanks all! This is merged now |
Thank you! |
* [microNPU] Added options to Cascader * Added option to toggle multi-dimensional striping, it is disabled by default because it has a very high computational cost. Single dimension striping shares most of the benefit with greatly reduced cost. * Added multiple developer/debugging options prefixed with 'dev_' Also added these options to tvmc. * Added cascader logging, if enabled it will dump information about the cascader proposals to a 'cascader_log.json' file. Co-authored-by: Matthew Barrett <[email protected]> Change-Id: I2ec59ae0bd84b73b2cc4bc56d39e3831b0aeec27 * Updated memory_reduction testcases Also added enable_striping to plan_generator.h Change-Id: I496b30ed6af6f0730087329cd81a69c5040a5e4d Co-authored-by: Matthew Barrett <[email protected]>
* [microNPU] Added options to Cascader * Added option to toggle multi-dimensional striping, it is disabled by default because it has a very high computational cost. Single dimension striping shares most of the benefit with greatly reduced cost. * Added multiple developer/debugging options prefixed with 'dev_' Also added these options to tvmc. * Added cascader logging, if enabled it will dump information about the cascader proposals to a 'cascader_log.json' file. Co-authored-by: Matthew Barrett <[email protected]> Change-Id: I2ec59ae0bd84b73b2cc4bc56d39e3831b0aeec27 * Updated memory_reduction testcases Also added enable_striping to plan_generator.h Change-Id: I496b30ed6af6f0730087329cd81a69c5040a5e4d Co-authored-by: Matthew Barrett <[email protected]>
* [microNPU] Added options to Cascader * Added option to toggle multi-dimensional striping, it is disabled by default because it has a very high computational cost. Single dimension striping shares most of the benefit with greatly reduced cost. * Added multiple developer/debugging options prefixed with 'dev_' Also added these options to tvmc. * Added cascader logging, if enabled it will dump information about the cascader proposals to a 'cascader_log.json' file. Co-authored-by: Matthew Barrett <[email protected]> Change-Id: I2ec59ae0bd84b73b2cc4bc56d39e3831b0aeec27 * Updated memory_reduction testcases Also added enable_striping to plan_generator.h Change-Id: I496b30ed6af6f0730087329cd81a69c5040a5e4d Co-authored-by: Matthew Barrett <[email protected]>
This PR adds multiple options to the cascader. One option is to toggle multi-dimensional striping and it is disabled by default. The reasoning is that exploring striping in more than 1 dimension has a very high computational cost.
The remainder of the options are aimed towards developers/debugging and are prefixed with dev_. The options are exposed to tvmc. It also introduces the ability to dump information about the cascader proposals to a .json file.
Co-authored-by: Matthew Barrett [email protected]