-
Notifications
You must be signed in to change notification settings - Fork 60
[ci] e2e kernel builder tests #416
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
Open
sayakpaul
wants to merge
25
commits into
main
Choose a base branch
from
e2e-kernel-builder-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
817f313
add e2e tests for kernel builder cli.
sayakpaul 14a258a
fix more.
sayakpaul da37bc9
fix cargo failure.
sayakpaul fe58258
empty
sayakpaul db6abc9
fix cachix.
sayakpaul 7abe3d8
up
sayakpaul 1031a96
up
sayakpaul 4af65e0
remove plan
sayakpaul d1152ff
up
sayakpaul 035577a
Apply suggestions from code review
sayakpaul 380bf24
use kernel-builder buil
sayakpaul 8a721f8
add
sayakpaul 87f57fc
Apply suggestions from code review
sayakpaul 13d5268
fix more
sayakpaul 0234a8c
more
sayakpaul 7b5eb82
remove repo-id from the upload command.
sayakpaul 35a022a
Merge branch 'main' into e2e-kernel-builder-tests
sayakpaul 82e9067
scope the token.
sayakpaul 9b0c983
Merge branch 'main' into e2e-kernel-builder-tests
sayakpaul 56beb52
upgrade forcefully.
sayakpaul a0f806e
check
sayakpaul 66795d1
switch to test_kernels runner
sayakpaul 46436ae
up
sayakpaul a82db5b
abi compilation issues.
sayakpaul b5eab64
up
sayakpaul File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| name: "E2E: kernel-builder init + build + upload + download" | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
| paths: | ||
| - "kernel-builder/**" | ||
| - "kernels/src/**" | ||
| - "nix-builder/**" | ||
| - "kernels-data/**" | ||
| - ".github/workflows/test_e2e.yaml" | ||
| workflow_dispatch: | ||
|
|
||
| env: | ||
| E2E_REPO_ID: kernels-test/kernels-upload-test | ||
| E2E_BRANCH: e2e-${{ github.event.pull_request.number || github.run_id }}-${{ github.run_attempt }} | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| init-build-upload: | ||
| name: Init, build, and upload kernel | ||
| runs-on: | ||
| group: aws-highmemory-32-plus-nix | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: DeterminateSystems/nix-installer-action@main | ||
| with: | ||
| extra-conf: | | ||
| max-jobs = 8 | ||
| cores = 12 | ||
| sandbox-fallback = false | ||
| - uses: cachix/cachix-action@v16 | ||
| with: | ||
| name: huggingface | ||
| authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" | ||
| env: | ||
| USER: runner | ||
|
|
||
| - name: Init kernel project | ||
| run: | | ||
| cd /tmp | ||
| nix run $GITHUB_WORKSPACE#kernel-builder -- init \ | ||
| --name ${{ env.E2E_REPO_ID }} \ | ||
| --backends cuda | ||
|
|
||
| - name: Validate scaffold | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Happy to remove this check but it's not adding much to the runtime. |
||
| run: | | ||
| cd /tmp/kernels-upload-test | ||
| test -f build.toml | ||
| test -f flake.nix | ||
| test -f torch-ext/kernels_upload_test/__init__.py | ||
| test -f torch-ext/torch_binding.cpp | ||
| test -f torch-ext/torch_binding.h | ||
| test -f kernels_upload_test_cuda/kernels_upload_test.cu | ||
| test -f tests/test_kernels_upload_test.py | ||
| test -f example.py | ||
| grep -q 'name = "kernels-upload-test"' build.toml | ||
| grep -q 'repo-id = "kernels-test/kernels-upload-test"' build.toml | ||
| grep -q 'backend = "cuda"' build.toml | ||
|
|
||
| - name: Patch flake.nix to use local nix-builder | ||
| run: | | ||
| cd /tmp/kernels-upload-test | ||
| sed -i 's|github:huggingface/kernels|path:'"$GITHUB_WORKSPACE"'|' flake.nix | ||
|
|
||
| - name: Build kernel | ||
| run: | | ||
| cd /tmp/kernels-upload-test | ||
| nix run $GITHUB_WORKSPACE#kernel-builder -- build-and-copy . -L | ||
|
|
||
| - name: Verify build artifacts | ||
| run: | | ||
| cd /tmp/kernels-upload-test | ||
| VARIANT_DIR=$(ls -d build/torch* | head -1) | ||
| echo "Built variant: $VARIANT_DIR" | ||
| test -f "$VARIANT_DIR/__init__.py" | ||
| test -f "$VARIANT_DIR/metadata.json" | ||
| ls "$VARIANT_DIR"/*.so | ||
|
|
||
| - name: Upload kernel to Hub | ||
| env: | ||
| HF_TOKEN: ${{ secrets.HF_TOKEN }} | ||
| run: | | ||
| nix run $GITHUB_WORKSPACE#kernel-builder -- upload /tmp/kernels-upload-test --branch ${{ env.E2E_BRANCH }} | ||
|
|
||
| download-and-test: | ||
| name: Download and test kernel via get_kernel | ||
| needs: init-build-upload | ||
| runs-on: | ||
| group: aws-g6-24xlarge | ||
| env: | ||
| UV_PYTHON_PREFERENCE: only-managed | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - name: Install uv and set Python version | ||
| uses: astral-sh/setup-uv@v7 | ||
| with: | ||
| python-version: "3.12" | ||
|
|
||
| - name: Install Python deps | ||
| working-directory: ./kernels | ||
| run: | | ||
| uv sync --all-extras --dev | ||
| uv pip install --upgrade torch | ||
| uv run --no-sync python -c "import torch; print(f'torch={torch.__version__}, cuda={torch.version.cuda}, cxx11_abi={torch.compiled_with_cxx11_abi()}')" | ||
|
|
||
| - name: Test get_kernel download and usage | ||
| working-directory: ./kernels | ||
| env: | ||
| HF_TOKEN: ${{ secrets.HF_TOKEN }} | ||
| run: | | ||
| uv run --no-sync python -c " | ||
| import torch | ||
| from kernels import get_kernel | ||
|
|
||
| kernel = get_kernel('${{ env.E2E_REPO_ID }}', revision='${{ env.E2E_BRANCH }}') | ||
|
|
||
| x = torch.randn(1024, 1024, dtype=torch.float32, device='cuda') | ||
| result = kernel.kernels_upload_test(x) | ||
| expected = x + 1.0 | ||
| torch.testing.assert_close(result, expected) | ||
| print('E2E test passed: get_kernel + correctness check') | ||
| " | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trigger on core changes.