Skip to content

Commit d9f7d39

Browse files
authored
Merge pull request #6 from tenstorrent/ddilbaz/python_3.11
Uplift wheel python 3.10 to 3.11
2 parents 96f1d55 + d68bcc4 commit d9f7d39

File tree

3 files changed

+79
-3
lines changed

3 files changed

+79
-3
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: build-torch-xla
2+
on:
3+
workflow_call:
4+
inputs:
5+
torch_version:
6+
description: 'Torch version to build (default: 2.7.0)'
7+
required: false
8+
type: string
9+
default: '2.7.0'
10+
outputs:
11+
artifact_name:
12+
description: 'Name of uploaded wheels artifact'
13+
value: ${{ jobs.build-wheels.outputs.artifact_name }}
14+
workflow_dispatch:
15+
jobs:
16+
build-wheels:
17+
runs-on: ubuntu-latest
18+
env:
19+
ARTIFACT_NAME: install-artifact-torch-xla-release
20+
GIT_VERSIONED_XLA_BUILD: 1
21+
container:
22+
image: us-central1-docker.pkg.dev/tpu-pytorch-releases/docker/development:tpu
23+
options: --user root
24+
outputs:
25+
artifact_name: ${{ steps.set_upload_name.outputs.artifact_name }}
26+
steps:
27+
- name: "Build Torch/XLA wheel"
28+
id: build_wheels
29+
run: |
30+
cmake --version
31+
apt-get update && apt-get install -y curl git build-essential
32+
33+
# Clean up any existing pyenv installation
34+
rm -rf $HOME/.pyenv
35+
36+
curl https://pyenv.run | bash
37+
export PATH="$HOME/.pyenv/bin:$PATH"
38+
eval "$(pyenv init -)"
39+
pyenv install 3.11
40+
pyenv global 3.11
41+
ln -sf $HOME/.pyenv/versions/3.11/bin/python3.11 /usr/local/bin/python3.11
42+
43+
# Install essential packages for Python 3.11
44+
python3.11 -m pip install --upgrade pip
45+
python3.11 -m pip install pyyaml setuptools wheel numpy typing_extensions requests
46+
47+
cd /tmp
48+
git clone --recursive --branch v${{ inputs.torch_version || '2.7.0' }} https://github.com/pytorch/pytorch.git
49+
cd pytorch/
50+
git clone --recursive https://github.com/tenstorrent/pytorch-xla.git xla
51+
52+
# copy pre-built wheels from cache
53+
python3.11 setup.py bdist_wheel
54+
python3.11 setup.py develop
55+
56+
# Build PyTorch/XLA
57+
cd xla/
58+
python3.11 setup.py bdist_wheel
59+
60+
# Collect wheels
61+
mkdir -p /dist
62+
cp dist/*.whl /dist/
63+
64+
# Clean up any existing pyenv installation
65+
rm -rf $HOME/.pyenv
66+
67+
- name: "Upload Wheels Artifact"
68+
id: upload
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: ${{ env.ARTIFACT_NAME }}
72+
path: /dist/*.whl
73+
74+
- name: Set artifact name output
75+
id: set_upload_name
76+
run: echo "artifact_name=${{ env.ARTIFACT_NAME }}" >> $GITHUB_OUTPUT

.github/workflows/_publish_torch_xla.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Set up Python
2626
uses: actions/setup-python@v4
2727
with:
28-
python-version: '3.10'
28+
python-version: '3.11'
2929

3030
- name: Configure AWS Credentials
3131
uses: aws-actions/configure-aws-credentials@v4

.github/workflows/build_and_publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ jobs:
1919
head_sha: ${{ github.sha }}
2020

2121
build-torch-xla:
22-
name: "Build PyTorch/XLA for Python 3.10"
22+
name: "Build PyTorch/XLA for Python 3.11"
2323
if: needs.check_code_changes.outputs.has_code_changes == 'true'
24-
uses: ./.github/workflows/_build_torch_xla_3.10.yml
24+
uses: ./.github/workflows/_build_torch_xla_3.11.yml
2525
needs: check_code_changes
2626

2727
publish-torch-xla:

0 commit comments

Comments
 (0)