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

docs: Add FAQ on backend support on Apple silicon Macs #2118

Closed
wants to merge 3 commits into from

Conversation

matthewfeickert
Copy link
Member

@matthewfeickert matthewfeickert commented Feb 15, 2023

Description

Superseded by PR #2119


Resolves #2111

At the moment, TensorFlow does not have Apple silicon compatible wheels on PyPI under the tensorflow project namespace, though it does under tensorflow-macos. As an alternative, note that conda-forge has linux-64, osx-64, and osx-arm64 compatible releases for all of pyhf's backends.

Checklist Before Requesting Reviewer

  • Tests are passing
  • "WIP" removed from the title of the pull request
  • Selected an Assignee for the PR to be responsible for the log summary

Before Merging

For the PR Assignees:

  • Summarize commit messages into a comprehensive review of the PR
* At the moment, TensorFlow does not have Apple silicon compatible
  wheels on PyPI. As an alternative, note that conda-forge has linux-64,
  osx-64, and osx-arm64 compatible releases for all of pyhf's backends.
   - c.f. https://github.com/tensorflow/tensorflow/issues/57185

@matthewfeickert matthewfeickert added the docs Documentation related label Feb 15, 2023
@matthewfeickert matthewfeickert self-assigned this Feb 15, 2023
@codecov
Copy link

codecov bot commented Feb 15, 2023

Codecov Report

Base: 98.05% // Head: 98.30% // Increases project coverage by +0.24% 🎉

Coverage data is based on head (a02c668) compared to base (46ce316).
Patch has no changes to coverable lines.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2118      +/-   ##
==========================================
+ Coverage   98.05%   98.30%   +0.24%     
==========================================
  Files          69       69              
  Lines        4531     4531              
  Branches      645      645              
==========================================
+ Hits         4443     4454      +11     
+ Misses         54       45       -9     
+ Partials       34       32       -2     
Flag Coverage Δ
contrib 97.88% <ø> (ø)
doctest 61.15% <ø> (?)
unittests-3.10 96.31% <ø> (ø)
unittests-3.8 96.33% <ø> (ø)
unittests-3.9 96.35% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/pyhf/tensor/jax_backend.py 98.61% <0.00%> (+0.69%) ⬆️
src/pyhf/tensor/tensorflow_backend.py 97.33% <0.00%> (+2.00%) ⬆️
src/pyhf/infer/test_statistics.py 100.00% <0.00%> (+3.33%) ⬆️
src/pyhf/tensor/pytorch_backend.py 98.48% <0.00%> (+3.78%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@alexander-held alexander-held left a comment

Choose a reason for hiding this comment

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

You can also install tensorflow-macos (and tensorflow-metal) via pip, but I guess that's discussed in the issue you linked anyway.

@matthewfeickert
Copy link
Member Author

matthewfeickert commented Feb 16, 2023

You can also install tensorflow-macos (and tensorflow-metal) via pip, but I guess that's discussed in the issue you linked anyway.

Ah yeah I had forgotten about the Metal project to get TensorFlow to work on Mac GPUs. Thanks for the reminder, I'll mention something about them. Though I guess related to that, @alexander-held on your Apple silicon Mac are you able to do the following in your virtual environment that you tried to use for developing in Issue #2111?

# After cloning things locally
$ python -m pip install --upgrade tensorflow-macos
$ python -m pip install --upgrade '.[develop]'
$ pytest

Or given this comment tensorflow/tensorflow#57185 (comment) about tensorflow-macos needing Rosetta are things super slow (I assume Rosetta is being used for emulation which will slow things down) and to get normal speeds do you need to follow Apple's instructions on setting up tensorflow-deps from conda (not conda-forge!)?

@matthewfeickert
Copy link
Member Author

on your Apple silicon Mac are you able to do the following in your virtual environment that you tried to use for developing in Issue #2111?

Ah, no I realize that this will fail regardless. Even though tensorflow-macos should install fine, we'll still run into trouble here as

python -m pip install --upgrade '.[develop]'

invokes the develop extra which includes the backends extra which includes the tensorflow extra

pyhf/pyproject.toml

Lines 64 to 67 in 29fb68e

tensorflow = [
"tensorflow>=2.7.0", # c.f. PR #1962
"tensorflow-probability>=0.11.0", # c.f. PR #1657
]

and so it will still try to do a pip install of tensorflow as that's going to be in the requested list, which will fail.

Normally this is where we would have some code to dynamically change determine the package name to use here based off of os.uname().machine or something, but we can't do that with TOML. I think this is again where using hatchling forces us into using hatch to setup environment workflows rather than using extras. We have Issue #2096 for that but we haven't done further investigation of how to orchestrate this.

Comment on lines +41 to +54
To install the dependencies for the TensorFlow backend you'll need to manually
specify that ``tensorflow-macos`` is required

.. code-block:: console

python -m pip install pyhf tensorflow-macos tensorflow-probability

Similarly, if you want to install the TensorFlow backend dependencies along with the
other backends included in the ``[backends]`` extra you'll need to specify the extras
as well

.. code-block:: console

python -m pip install 'pyhf[torch,jax,minuit]' tensorflow-macos tensorflow-probability
Copy link
Member Author

Choose a reason for hiding this comment

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

@alexander-held I think this should work to actually get things installed. Though I think it is going to be annoying to get a full developer environment setup at the moment given that the test extra also pulls in the backends extra and so will break here.

* At the moment, TensorFlow does not have Apple silicon compatible
  wheels on PyPI. As an alternative, not that conda-forge has linux-64
  and osx-arm64 compatible releases for all of pyhf's backends.
   - c.f. https://github.com/tensorflow/tensorflow/issues 57185
@matthewfeickert
Copy link
Member Author

This PR should no longer be needed as PR #2119 can work.

@matthewfeickert matthewfeickert deleted the docs/add-macos-arm64-faq branch February 16, 2023 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation related
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Cannot resolve dependencies in "all" setup extra
2 participants