Skip to content

[Ref Mode] PyTorch reference mode (eager only) #339

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

Merged
merged 1 commit into from
Jul 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions .github/workflows/test-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Reusable Test Workflow

on:
workflow_call:
inputs:
test-name:
required: true
type: string
ref-eager:
required: false
type: boolean
default: false

jobs:
test:
name: ${{ inputs.test-name }}-cuda12.6-py${{ matrix.python-version }}-a10g

container:
image: nvidia/cuda:12.6.3-devel-ubuntu24.04
options: --gpus all

runs-on: linux.g5.4xlarge.nvidia.gpu

strategy:
matrix:
python-version: ["3.10", "3.12"]

defaults:
run:
shell: bash -l {0}

steps:
- name: Check out code
uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v6
with:
python-version: ${{ matrix.python-version }}
enable-cache: true

- name: Create virtual environment
run: |
uv venv --python ${{ matrix.python-version }}

- name: Get current month
id: date
run: echo "month=$(date +'%Y-%m')" >> $GITHUB_OUTPUT

- name: Cache dependencies
id: cache
uses: actions/cache@v4
with:
path: |
~/.cache/uv
~/.venv
key: ${{ runner.os }}-deps-${{ matrix.python-version }}-${{ hashFiles('.github/workflows/test.yml', 'requirements.txt') }}-${{ steps.date.outputs.month }}
Copy link
Contributor

Choose a reason for hiding this comment

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

@yf225 i think you broke the cache key with this. Why did you need to use templates? we could just do this with strategy matrix instead

Copy link
Contributor

Choose a reason for hiding this comment

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

i can clean it up

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

stamped, sorry for breakage and thanks so much for catching this!

restore-keys: |
${{ runner.os }}-deps-

- name: Install PyTorch
run: |
source .venv/bin/activate
uv pip install -U --pre torch --index-url https://download.pytorch.org/whl/nightly/cu126

- name: Install Triton
if: steps.cache.outputs.cache-hit != 'true'
run: |
set -x
source .venv/bin/activate
apt-get update
apt-get install -y git
apt-get install -y gcc-13 g++-13 zlib1g-dev
export CC=gcc-13
export CXX=g++-13
mkdir -p /tmp/$USER
cd /tmp/$USER
uv pip uninstall triton pytorch-triton || true
rm -rf triton/ || true
git clone https://github.com/triton-lang/triton.git
cd triton/
uv pip install -r python/requirements.txt
MAX_JOBS=$(nproc) TRITON_PARALLEL_LINK_JOBS=2 uv pip install .
cd /tmp/$USER
rm -rf triton/

- name: Install Requirements
run: |
source .venv/bin/activate
uv pip install -r requirements.txt

- name: Run Tests
run: |
source .venv/bin/activate
if [[ "${{ inputs.ref-eager }}" == "true" ]]; then
HELION_INTERPRET=1 pytest
else
pytest
fi
90 changes: 10 additions & 80 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,83 +13,13 @@ concurrency:

jobs:
test:
name: test-cuda12.6-py${{ matrix.python-version }}-a10g

container:
image: nvidia/cuda:12.6.3-devel-ubuntu24.04
options: --gpus all

runs-on: linux.g5.4xlarge.nvidia.gpu

strategy:
matrix:
python-version: ["3.10", "3.12"]

defaults:
run:
shell: bash -l {0}

steps:
- name: Check out code
uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v6
with:
python-version: ${{ matrix.python-version }}
enable-cache: true

- name: Create virtual environment
run: |
uv venv --python ${{ matrix.python-version }}

- name: Get current month
id: date
run: echo "month=$(date +'%Y-%m')" >> $GITHUB_OUTPUT

- name: Cache dependencies
id: cache
uses: actions/cache@v4
with:
path: |
~/.cache/uv
~/.venv
key: ${{ runner.os }}-deps-${{ matrix.python-version }}-${{ hashFiles('.github/workflows/test.yml', 'requirements.txt') }}-${{ steps.date.outputs.month }}
restore-keys: |
${{ runner.os }}-deps-

- name: Install PyTorch
run: |
source .venv/bin/activate
uv pip install -U --pre torch --index-url https://download.pytorch.org/whl/nightly/cu126

- name: Install Triton
if: steps.cache.outputs.cache-hit != 'true'
run: |
set -x
source .venv/bin/activate
apt-get update
apt-get install -y git
apt-get install -y gcc-13 g++-13 zlib1g-dev
export CC=gcc-13
export CXX=g++-13
mkdir -p /tmp/$USER
cd /tmp/$USER
uv pip uninstall triton pytorch-triton || true
rm -rf triton/ || true
git clone https://github.com/triton-lang/triton.git
cd triton/
uv pip install -r python/requirements.txt
MAX_JOBS=$(nproc) TRITON_PARALLEL_LINK_JOBS=2 uv pip install .
cd /tmp/$USER
rm -rf triton/

- name: Install Requirements
run: |
source .venv/bin/activate
uv pip install -r requirements.txt

- name: Run Tests
run: |
source .venv/bin/activate
pytest
uses: ./.github/workflows/test-template.yml
with:
test-name: test
ref-eager: false

test-ref-eager:
uses: ./.github/workflows/test-template.yml
with:
test-name: test-ref-eager
ref-eager: true
2 changes: 2 additions & 0 deletions helion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
from .runtime import Kernel
from .runtime import kernel
from .runtime import kernel as jit # alias
from .runtime.settings import RefMode
from .runtime.settings import Settings
from .runtime.settings import set_default_settings

__all__ = [
"Config",
"Kernel",
"RefMode",
"Settings",
"cdiv",
"exc",
Expand Down
Loading
Loading