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

Adding support for binary8 #4

Merged
merged 6 commits into from
Apr 30, 2024
Merged

Adding support for binary8 #4

merged 6 commits into from
Apr 30, 2024

Conversation

mfasi
Copy link
Collaborator

@mfasi mfasi commented Apr 30, 2024

I'm creating a pull request so that we can comment on changes before rebasing.

mfasi and others added 4 commits April 30, 2024 08:20
Specifically, e4m3 in the OCP standard does not represent infinities to expand the maximum exponent to 8.
This allows to make fp8-e4m3 fully OCP compliant, where it is specified with emax = 8 and emin = -6.
Copy link
Collaborator Author

@mfasi mfasi left a comment

Choose a reason for hiding this comment

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

Just a few minor comments. The main issue I see is that the tests are currently failing, but that seems an unrelated problem – I'll look into it.

* @brief Minimum exponent of target format.
*
* @details The minimum values allowed are -126 and -1022 if the storage format
* is `float` or `double`, respectively. Smaller values are increase to the
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

increased? Perhaps I would change this sentence to read If a smaller value is chosen, this is changed to the minimum allowed value without warning. And probably, the emax docstring should be changed accordingly – I find it's not the clearest description of what's happening.

@@ -106,6 +106,7 @@ optstruct *init_optstruct() {
fpopts->bitseed = NULL;
fpopts->randseedf = NULL;
fpopts->randseed = NULL;
fpopts->emin = -99999;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure I like this magic constant – would 0 do as well here? emin should be strictly negative anyway.

@@ -279,6 +280,10 @@ static inline int VALIDATE_INPUT(const optstruct *fpopts) {
if (fpopts->flip != CPFLOAT_NO_SOFTERR && (fpopts->p > 1 || fpopts->p < 0))
return 5;

/* Return -6 if emin is invalid (either nonnegative or too small). */
if (fpopts->emin < DEFEMIN || fpopts->emin >= 0)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No changes needed here, as far as I can tell.

int emin = 1-emax;
int emin = fpopts->emin;
/* If emin is not set by user, set it to the default 1-emax. */
if (emin == -99999)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This -9999 would become a 0, I think.

@@ -304,7 +309,14 @@ static inline FPPARAMS COMPUTE_GLOBAL_PARAMS(const optstruct *fpopts,
}

/* Derived floating point parameters. */
int emin = 1-emax;
int emin = fpopts->emin;
/* If emin is not set by user, set it to the default 1-emax. */
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should this be the user?

@@ -1199,7 +1211,7 @@ GENERATE_UNIVARIATE_MATH_H(lgamma, lgamma)
if (temp == FP_ILOGB0 || temp == FP_ILOGBNAN || temp == INT_MAX) { \
params.precision = DEFPREC-1; \
params.emax = DEFEMAX; \
params.emax = DEFEMIN; \
params.emin = DEFEMIN; \
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for this – can you change the message of the last commit to

Fixed the emin bug (closes #2)

@mfasi
Copy link
Collaborator Author

mfasi commented Apr 30, 2024

The main issue I see is that the tests are currently failing, but that seems an unrelated problem – I'll look into it.

I think I've found the issue and fixed it locally. I can push this to main if you're happy to rebase dev onto it, or I can wait for you to be done with this PR and rebase my change onto dev.

@mmikaitis
Copy link
Collaborator

The main issue I see is that the tests are currently failing, but that seems an unrelated problem – I'll look into it.

I think I've found the issue and fixed it locally. I can push this to main if you're happy to rebase dev onto it, or I can wait for you to be done with this PR and rebase my change onto dev.

Please push it to main. I will rebase onto it once done here.

@mfasi
Copy link
Collaborator Author

mfasi commented Apr 30, 2024

Looks good, thanks! I'll rebase and merge – the code should pass the revised tests, and if not, we can fix it later.

@mfasi mfasi merged commit 039a655 into main Apr 30, 2024
1 of 3 checks passed
@mfasi
Copy link
Collaborator Author

mfasi commented Apr 30, 2024

Mhh – it didn't quite work. It seems that rebase and merge doesn't actually rebase on main... Will do it by hand.

mmikaitis added a commit that referenced this pull request Apr 30, 2024
mmikaitis added a commit that referenced this pull request May 29, 2024
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.

2 participants