-
Notifications
You must be signed in to change notification settings - Fork 84
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
signed-int4 support for Pack/Unpack #3359
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3359 +/- ##
===========================================
- Coverage 92.16% 92.14% -0.02%
===========================================
Files 504 504
Lines 20486 20505 +19
===========================================
+ Hits 18880 18895 +15
- Misses 1606 1610 +4 ☔ View full report in Codecov by Sentry. |
0xBA, | ||
0xDC, | ||
0xFE}; | ||
0xFF, |
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.
add tests "ref" tests for "unpack" as well
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.
There already is a test for pack_unpack. Isn't that enough?
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.
Just to clarify further, there are ref tests that check for pack operations, and then followed by its unpack counterpart. And those initial and final values are compared appropriately. Thanks.
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 the math's fine here, yeah
On the MLIR side, I'd prefer unpack
to carry an attribute indicating signedness behavior instead, but that can be special-cased at the edge
int8_t val2 = inp[in_data_multi_idx]; | ||
val2 = std::min(std::max(val2, min_4bit), max_4bit); // clip | ||
|
||
out[i] = (val2 << 4) | (val1 & 0xf); // pack |
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.
Re these warnings, you'll want to static_cast
yourself to the unsigned version and then static_cast
yourself back.
... Heck, personally, I'd prefer that the signededness of the packed values not be indicated by int8/uint8 in the packed buffer - instead, put a little flag on unpack
whether the uint8
s represent signed or unsigned int4's
out[data_idx] = val1; | ||
|
||
data_idx[axis] += 1; | ||
val2 >>= 4; |
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.
Yeah, this does look like a correct implementation of signed unpack
8d83d76
to
a38549f
Compare
Check results before merge 🔆 |
🔴bert_large_uncased_fp16: FAILED: MIGraphX is not within tolerance - check verbose output |
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, but can we get another reviewer from migraphx team?
No description provided.