Skip to content

[MPS] Fix partitioner parameters recognition #2777

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

Closed

Conversation

DenisVieriu97
Copy link
Collaborator

Fixes parameters recognition for MPS backend

Testing:

python3 -m unittest backends.apple.mps.test.test_mps -k test_mps_backend_partitioner -v
./cmake-out/examples/apple/mps/mps_executor_runner --model_path mps_backend_partitioner.pte --bundled_program

cc @cccclai, @shoumikhin

Copy link

pytorch-bot bot commented Mar 30, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/2777

Note: Links to docs will display an error until the docs builds have been completed.

❌ 1 New Failure, 1 Unrelated Failure

As of commit e5fe065 with merge base d4b3e5c (image):

NEW FAILURE - The following job has failed:

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@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 Mar 30, 2024
@facebook-github-bot
Copy link
Contributor

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


def is_node_supported(self, submodules, node: torch.fx.Node) -> bool:
# Parameters are supported if any of their users are supported
if is_parameter(self.edge_program, node):
Copy link
Contributor

@cccclai cccclai Mar 31, 2024

Choose a reason for hiding this comment

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

Actually, after reading the pr again, why does the following lines mean it's parameter?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

here by it's parameter we're checking only if it's a constant (lifter buffer)

Copy link
Contributor

Choose a reason for hiding this comment

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

it's a constant (lifter buffer)

right, I'm trying to find the logic to determine if it's a constant. This line doesn't look like so.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We're checking if it's a constant if is_param or is_buffer are true (or is_get_attr is set to true - which I think it's not the case anymore after moving to lifted graphs)

def is_parameter(exp_prog: torch.export.ExportedProgram, node: torch.fx.Node) -> bool:
    """
    Check if a node is a lifted parameter (static data like weights and bias are
    are supplied as inputs to the graph.

    Args:
        edge_program (torch.export.ExportedProgram): _description_
        node (torch.fx.Node): _description_

    Returns:
        bool: _description_
    """
    return is_get_attr(node) or is_param(exp_prog, node) or is_buffer(exp_prog, node)

@facebook-github-bot
Copy link
Contributor

@cccclai merged this pull request in 6965120.

@cccclai
Copy link
Contributor

cccclai commented Apr 9, 2024

@pytorchbot cherry-pick --onto release/0.2 -c critical

@pytorchbot
Copy link
Collaborator

Cherry picking #2777

Command git -C /home/runner/work/executorch/executorch cherry-pick -x -X theirs 696512016e01173aadf9b83e2710013bf9de888f returned non-zero exit code 1

The previous cherry-pick is now empty, possibly due to conflict resolution.
If you wish to commit it anyway, use:

    git commit --allow-empty

Otherwise, please use 'git cherry-pick --skip'
On branch cherry-pick-2777-by-pytorch_bot_bot_
You are currently cherry-picking commit 696512016.
  (all conflicts fixed: run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

nothing to commit, working tree clean
Details for Dev Infra team Raised by workflow job

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants