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

Check determinism using function name only #10241

Closed
wants to merge 1 commit into from

Conversation

rui-mo
Copy link
Collaborator

@rui-mo rui-mo commented Jun 18, 2024

In ExpressionFuzzer, the determinism could be decided without argument
types. This PR changes to check determinism using function name only by
fetching all registry entries for the given function name and checking if all
of them are deterministic. The function is deterministic if "deterministic" is
true for every entry. With this change, argument types are not required when
the signature variables are not empty.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 18, 2024
Copy link

netlify bot commented Jun 18, 2024

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit db0dfa2
🔍 Latest deploy log https://app.netlify.com/sites/meta-velox/deploys/66836a89a17e0b00070a6e27

@rui-mo rui-mo force-pushed the wip_deterministic branch 3 times, most recently from c2cea96 to e876e68 Compare June 18, 2024 03:49
@rui-mo rui-mo force-pushed the wip_deterministic branch 2 times, most recently from 11808fe to 3abd0e2 Compare June 24, 2024 03:08
@rui-mo
Copy link
Collaborator Author

rui-mo commented Jun 25, 2024

@mbasmanova Would you help review this PR? It addresses the discussion at #9149 (comment). Thanks.

Copy link
Contributor

@mbasmanova mbasmanova left a comment

Choose a reason for hiding this comment

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

@rui-mo Rui, thank you for working on this. Some comments.

/// no function with the specified name.
std::optional<
std::pair<std::vector<FunctionSignaturePtr>, VectorFunctionMetadata>>
getVectorFunctionSignaturesAndMetadata(const std::string& name);
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like the only caller of this API uses only the metadata. Perhaps, change the API to return just that:

std::optional<VectorFunctionMetadata> getVectorFunctionMetadata(const std::string& name);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated. Thanks.

@@ -26,6 +26,14 @@
#include "velox/vector/tests/utils/VectorMaker.h"

namespace facebook::velox::fuzzer {
namespace detail {
Copy link
Contributor

Choose a reason for hiding this comment

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

APIs in 'detail' namespaces are not supposed to be used outside of the header/cpp files.

I wonder if this API belongs to velox/functions/FunctionRegistry.h and whether it is clearer to return std::optional to indicate not-found condition clearly.

/// Returns if `functionName` with the given `argTypes` is deterministic.
/// Returns true if the function was not found or determinism cannot be
/// established.
bool isDeterministic(
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's keep this function, but remove 'argTypes' and replace code from L359 with a call to new isDeterministic(name) API. The new API would go into elox/functions/FunctionRegistry.h and return std::optional<bool>. std::nullopt would indicate that function not found, true would indicate that all function signatures are deterministic, false would mean that at least one function signature is non-deterministic.

What do you think?

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 the suggestion. Added a new isDeterministic API in FunctionRegistry.h.

@rui-mo rui-mo force-pushed the wip_deterministic branch 2 times, most recently from c183362 to 0046a88 Compare June 26, 2024 02:36
Copy link
Contributor

@mbasmanova mbasmanova left a comment

Choose a reason for hiding this comment

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

@rui-mo Looks great. Thanks.

// get their determinism.
std::vector<TypePtr> argTypes;
if (signature->variables().empty()) {
if (!isDeterministic(function.first)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to change anything in this PR, but I wonder if we can move this check into filterSignatures now that the check only needs function name.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I see. Will follow up this change in a separate PR. Thanks.

@mbasmanova mbasmanova added the ready-to-merge PR that have been reviewed and are ready for merging. PRs with this tag notify the Velox Meta oncall label Jun 26, 2024
@facebook-github-bot
Copy link
Contributor

@bikramSingh91 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@rui-mo rui-mo force-pushed the wip_deterministic branch from 0046a88 to db0dfa2 Compare July 2, 2024 02:48
@facebook-github-bot
Copy link
Contributor

@bikramSingh91 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@bikramSingh91 merged this pull request in 63cceca.

Copy link

Conbench analyzed the 1 benchmark run on commit 63ccecaa.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details.

facebook-github-bot pushed a commit that referenced this pull request Jul 10, 2024
Summary:
The check for determinism could be moved into filterSignatures as it only needs
function name.
#10241 (comment)

Pull Request resolved: #10394

Reviewed By: bikramSingh91

Differential Revision: D59592576

Pulled By: pedroerp

fbshipit-source-id: 82b1673c4f0efdee7cfd6084daba98d96163c7d5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged ready-to-merge PR that have been reviewed and are ready for merging. PRs with this tag notify the Velox Meta oncall
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants