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

Enable more tests for CPU in CI #51

Closed
wants to merge 56 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
1ab0593
Short preamble for the README, explaining why this clone exists
bertmaher Apr 17, 2024
b4369d0
OSS Automated Fix: Addition of Code of Conduct (#1)
facebook-github-bot May 1, 2024
5fb04c1
[BACKEND][CPU] Initial plumbing for cpu backend (#2)
minjang May 2, 2024
ae4908e
[BACKEND][CPU] Create TritonCPU and conversion dialects (#3)
minjang May 6, 2024
427a4ee
Update README.md
minjang May 6, 2024
a3af436
Convert tt.func and tt.return (#4)
minjang May 13, 2024
1eee916
[BACKEND][CPU] Convert tt.get_program_id and tt.print (Hello World) (#1)
minjang May 14, 2024
4bcc918
Quick patches to make it work after rebasing (#3)
minjang May 16, 2024
9c523f6
Support basic lowering through vector dialect in CPU backend.
ienkovich May 2, 2024
df024dd
Revert unreviewed changes. (#5)
shanenay May 17, 2024
c2d2b4e
Add a workaround for LLVM bug in codegen for bf16 vector cast. (#4)
ienkovich May 17, 2024
e8fbb8a
Prototype of the Triton CPU backend with basic compilation and execut…
ienkovich May 24, 2024
6480563
Add support for tl.cat operation. (#9)
ienkovich May 28, 2024
0419e8f
[BACKEND][CPU] Make it buildable and runnable in a different environm…
minjang May 28, 2024
08eff50
Add support for simple reductions. (#10)
ienkovich May 29, 2024
fd49147
Support tl.histogram for CPU. (#12)
ienkovich May 29, 2024
e4eeea8
Fix merge and compile errors (#13)
minjang May 30, 2024
193a0b6
[CPU] Support flexible active driver + update vector-add tutorial (#11)
minjang May 31, 2024
b78ddce
Added a simple workflow to run on self-hosted intel runner (#16)
gshimansky Jun 7, 2024
0b18898
Fixed build and test workflow for intel self-hosted runner (#17)
gshimansky Jun 9, 2024
74f111f
[CPU] Add an OpenMP-based CPU launcher (#15)
minjang Jun 10, 2024
0f9a0cf
Support generic reduction and scan cases. (#14)
ienkovich Jun 10, 2024
975c640
[CPU] Dump human-readable asm code in TRITON_CACHE_DIR (#19)
minjang Jun 11, 2024
3ff6130
Added g++ installation after switching to ubuntu-22.04 (#21)
gshimansky Jun 11, 2024
d36444e
Support atomic ops for CPU. (#20)
ienkovich Jun 11, 2024
a11dae4
[TUTORIAL] Add unmasked matrix multiply example to triton-cpu (#23)
Kuigesi Jun 14, 2024
d39ed0f
Update matrix-multiplication-cpu tutorial, use preallocated output bu…
Kuigesi Jun 15, 2024
1eb05d3
Fixes for x86 CI workflow (#26)
ienkovich Jun 18, 2024
1b9997c
Use static compilation for kernels. (#29)
ienkovich Jun 20, 2024
f3093c3
Move byte manipulation ops from elwise ops conversion. (#28)
ienkovich Jun 20, 2024
d9fd0d5
[TUTORIAL] Add the non-persistent softmax and make it for CPU (#22)
minjang Jun 20, 2024
ef0d178
Enable few more core tests for CPU. (#31)
ienkovich Jun 20, 2024
3cfb1e5
Support tt.split for CPU. (#30)
ienkovich Jun 20, 2024
4a1171a
[BACKEND][CPU] Make the CPU backend buildable and runnable in Mac M1.…
Kuigesi Jun 25, 2024
f5b94d3
[CPU] Add conversion for unsupported BF16 ops via target-specific sta…
ienkovich Jun 25, 2024
0cc42d7
Enabled simple build&test workflow, disabled old Integration Tests wo…
gshimansky Jun 25, 2024
e806fbb
[BACKEND][CPU] Specify CPU target to native for GNU/Linux Arm (#34)
Kuigesi Jun 25, 2024
4641be5
Add conversions for mixed precision matmuls. (#32)
ienkovich Jul 2, 2024
296c11d
[Op support] Support 'get_num_programs' (#39)
Devjiu Jul 3, 2024
ad40105
Add fast-math option: allow fp reduction reassociation in MLIR vector…
Kuigesi Jul 8, 2024
282d51d
Change the lowering option for vector.multi_reduction from InnerParal…
Kuigesi Jul 8, 2024
c9575d8
Merge pull request #41 from Kuigesi/fast-math
embg Jul 9, 2024
ff4c64b
Fix: TrapUnreachable is not controled by fast-math, we set it uncondi…
Kuigesi Jul 9, 2024
9dd5387
Merge pull request #47 from Kuigesi/lower-reduction
embg Jul 12, 2024
38ea470
Merge pull request #48 from Kuigesi/fast-math-fix
embg Jul 12, 2024
447860a
[cpu] Add test_compile_errors.py to CI
int3 Jul 15, 2024
5bcb00c
[cpu] Fix preload device key + make test_cache.py concurrent-safe & a…
int3 Jul 15, 2024
e135f1c
[cpu] Add test_launch.py to CI
int3 Jul 15, 2024
f92ae07
[cpu] Add test_bindings.py to CI
int3 Jul 15, 2024
8301cff
[cpu] Add test_conversions.py to CI
int3 Jul 15, 2024
fa06c02
[cpu] Run CI tests as a batched command
int3 Jul 15, 2024
319143b
[cpu] Add test_annotations.py to CI
int3 Jul 15, 2024
d5130b1
[cpu] Add pytest.mark.cpu to a few more core tests
int3 Jul 16, 2024
9c51c95
[cpu] Add test_subproc.py to CI
int3 Jul 16, 2024
78a55d3
[cpu] Enable test_debug_dump.py in CI
int3 Jul 16, 2024
ceb1f88
[cpu] Add test_standard.py and test_decorator.py to CI
int3 Jul 16, 2024
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
92 changes: 92 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Build and test
run-name: ${{ inputs.run_name }}

on:
workflow_dispatch:
pull_request:
branches:
- main
# You can name your branch dev-foo to get CI runs.
- 'dev-**'
push:
branches:
- main

jobs:
pre-commit:
name: Pre-commit checks
runs-on:
- glados
- intel
- x86
steps:
- name: Print inputs
run: |
echo "${{ toJSON(github.event.inputs) }}"
echo INSTALL_IPEX=${{ env.INSTALL_IPEX }}

- name: Checkout repository
uses: actions/checkout@v4

- name: Install Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Run pre-commit checks
run: |
pip install --upgrade pre-commit

# TODO: ignore the first yapf failure until https://github.com/google/yapf/issues/1164 is fixed
python3 -m pre_commit run --all-files --verbose yapf &> /dev/null || true
# If first run of yapf worked and made changes reset the tree to the original state
git reset --hard

python3 -m pre_commit run --show-diff-on-failure --color=always --all-files --verbose

build-test:
name: Build and test
runs-on:
- glados
- intel
- x86
strategy:
matrix:
python: ['3.11']
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}

- name: Install pip and apt dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install wheel cmake==3.24 ninja pytest-xdist lit
sudo apt-get update
sudo apt-get install -y zlib1g-dev g++
pip install torch==2.1.2

- name: Install Triton
run: |
echo "PATH is '$PATH'"
cd python
python3 -m pip install --no-build-isolation -vvv '.[tests]'

- name: Run python unit tests
run: |
python -m pytest -s -n 32 --device cpu python/test/unit/language/test_core.py -m cpu
python -m pytest -s -n 32 --device cpu \
python/test/unit/language/test_annotations.py \
python/test/unit/language/test_compile_errors.py \
python/test/unit/language/test_conversions.py \
python/test/unit/language/test_decorator.py \
python/test/unit/language/test_standard.py \
python/test/unit/runtime/test_bindings.py \
python/test/unit/runtime/test_cache.py \
python/test/unit/runtime/test_launch.py \
python/test/unit/runtime/test_subproc.py \
python/test/unit/test_debug_dump.py
17 changes: 9 additions & 8 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
name: Integration Tests
on:
workflow_dispatch:
pull_request:
# You can name your branch dev-foo to get CI runs.
branches: [main, 'dev-**']
merge_group:
branches: [main, 'dev-**']
types: [checks_requested]
push:
branches: [main]
# Disabled automatic triggers because tests in this workflow fail to run.
# pull_request:
# # You can name your branch dev-foo to get CI runs.
# branches: [main, 'dev-**']
# merge_group:
# branches: [main, 'dev-**']
# types: [checks_requested]
# push:
# branches: [main]
concurrency:
group: ${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
Expand Down
18 changes: 10 additions & 8 deletions .github/workflows/integration-tests.yml.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ name: Integration Tests

on:
workflow_dispatch:
pull_request:
# You can name your branch dev-foo to get CI runs.
branches: [main, 'dev-**']
merge_group:
branches: [main, 'dev-**']
types: [checks_requested]
push:
branches: [main]

# Disabled automatic triggers because tests in this workflow fail to run.
# pull_request:
# # You can name your branch dev-foo to get CI runs.
# branches: [main, 'dev-**']
# merge_group:
# branches: [main, 'dev-**']
# types: [checks_requested]
# push:
# branches: [main]

concurrency:
group: ${{ github.ref }}
Expand Down
80 changes: 80 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to make participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies within all project spaces, and it also applies when
an individual is representing the project or its community in public spaces.
Examples of representing a project or community include using an official
project e-mail address, posting via an official social media account, or acting
as an appointed representative at an online or offline event. Representation of
a project may be further defined and clarified by project maintainers.

This Code of Conduct also applies outside the project spaces when there is a
reasonable belief that an individual's behavior may have a negative impact on
the project or its community.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at <[email protected]>. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
# Triton-CPU

A long-lived development branch to build an experimental CPU backend for [Triton](https://github.com/openai/triton).

This repository clones the main Triton repository, but we intend to minimize
divergences in the core (and ideally upstream anything that needs to change and
isn't too CPU-specific). Most of the CPU work should be in a backend
subdirectory (similar to how GPU vendors are supported today). We're starting
with a clone to give ourselves maximum development flexibility as this project
gets off the ground!

# How to use it?

Build it like a normal Triton, but just pass TRITON_CPU_BACKEND=1 to use the CPU backend over a GPU backend, if any.

```
TRITON_CPU_BACKEND=1 python3 tutorials/01-vector-add.py
```

**NOTE: It's still work in progress.**

---

# Upstream README

<div align="center">
<img src="https://cdn.openai.com/triton/assets/triton-logo.png" alt="Triton logo" width="88" height="100">
</div>
Expand Down
28 changes: 21 additions & 7 deletions bin/RegisterTritonDialects.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once
#include "third_party/nvidia/include/Dialect/NVGPU/IR/Dialect.h"
#include "triton/Dialect/Triton/IR/Dialect.h"
#include "triton/Dialect/TritonCPU/IR/Dialect.h"
#include "triton/Dialect/TritonGPU/IR/Dialect.h"
#include "triton/Dialect/TritonNvidiaGPU/IR/Dialect.h"

Expand All @@ -13,6 +14,9 @@
#include "triton/Dialect/TritonGPU/Transforms/Passes.h"
#include "triton/Dialect/TritonNvidiaGPU/Transforms/Passes.h"

#include "cpu/include/TritonCPUToLLVM/Passes.h"
#include "cpu/include/TritonCPUTransforms/Passes.h"
#include "cpu/include/TritonToTritonCPU/Passes.h"
#include "nvidia/include/NVGPUToLLVM/Passes.h"
#include "nvidia/include/TritonNVIDIAGPUToLLVM/Passes.h"
#include "triton/Conversion/TritonGPUToLLVM/Passes.h"
Expand Down Expand Up @@ -59,12 +63,22 @@ inline void registerTritonDialects(mlir::DialectRegistry &registry) {
mlir::registerTritonAMDGPUReorderInstructions();
mlir::registerTritonAMDGPUStreamPipeline();

// CPU passes
mlir::triton::cpu::registerTritonToTritonCPUPasses();
mlir::triton::cpu::registerTritonToTritonCPUPipeline();
mlir::triton::cpu::registerTritonCPUTransformsPasses();
mlir::triton::cpu::registerTritonCPUToLLVMPasses();
mlir::triton::cpu::registerTritonCPUToLLVMPipeline();

// TODO: register Triton & TritonGPU passes
registry.insert<mlir::triton::TritonDialect, mlir::cf::ControlFlowDialect,
mlir::triton::nvidia_gpu::TritonNvidiaGPUDialect,
mlir::triton::gpu::TritonGPUDialect, mlir::math::MathDialect,
mlir::arith::ArithDialect, mlir::scf::SCFDialect,
mlir::gpu::GPUDialect, mlir::LLVM::LLVMDialect,
mlir::NVVM::NVVMDialect, mlir::triton::nvgpu::NVGPUDialect,
mlir::ROCDL::ROCDLDialect>();
registry
.insert<mlir::triton::TritonDialect, mlir::cf::ControlFlowDialect,
mlir::triton::cpu::TritonCPUDialect,
mlir::triton::nvidia_gpu::TritonNvidiaGPUDialect,
mlir::triton::gpu::TritonGPUDialect, mlir::math::MathDialect,
mlir::arith::ArithDialect, mlir::scf::SCFDialect,
mlir::memref::MemRefDialect, mlir::vector::VectorDialect,
mlir::tensor::TensorDialect, mlir::gpu::GPUDialect,
mlir::LLVM::LLVMDialect, mlir::NVVM::NVVMDialect,
mlir::triton::nvgpu::NVGPUDialect, mlir::ROCDL::ROCDLDialect>();
}
1 change: 1 addition & 0 deletions include/triton/Analysis/Utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "mlir/Analysis/SliceAnalysis.h"
#include "mlir/Support/LLVM.h"
#include "triton/Dialect/Triton/IR/Dialect.h"
#include "triton/Dialect/TritonCPU/IR/Dialect.h"
#include "triton/Dialect/TritonGPU/IR/Dialect.h"

namespace mlir {
Expand Down
3 changes: 3 additions & 0 deletions include/triton/Conversion/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# TODO(minjang): I will remove these scratches soon.
# add_subdirectory(TritonCPUToLLVM)
add_subdirectory(TritonGPUToLLVM)
# add_subdirectory(TritonToTritonCPU)
add_subdirectory(TritonToTritonGPU)
3 changes: 3 additions & 0 deletions include/triton/Conversion/TritonCPUToLLVM/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set(LLVM_TARGET_DEFINITIONS Passes.td)
mlir_tablegen(Passes.h.inc -gen-pass-decls --name TritonCPUToLLVM)
add_public_tablegen_target(TritonCPUToLLVMConversionPassIncGen)
22 changes: 22 additions & 0 deletions include/triton/Conversion/TritonCPUToLLVM/CPUTargetInfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef TRITON_CONVERSION_TRITONCPU_TO_LLVM_TARGETINFOBASE_H
#define TRITON_CONVERSION_TRITONCPU_TO_LLVM_TARGETINFOBASE_H

#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "triton/Conversion/MLIRTypes.h"

namespace mlir::triton::cpu {
class CPUTargetInfo {
public:
// Note: we may revisit for different CPU ISAs like AVX and Neon.
CPUTargetInfo() {}

Value programId(ConversionPatternRewriter &rewriter, Location loc,
LLVM::LLVMFuncOp funcOp, int axis) const;

void printf(ConversionPatternRewriter &rewriter, Value formatStrStart,
int formatStrByteCount, ValueRange args) const;

~CPUTargetInfo() {}
};
} // namespace mlir::triton::cpu
#endif // TRITON_CONVERSION_TRITONCPU_TO_LLVM_TARGETINFOBASE_H
29 changes: 29 additions & 0 deletions include/triton/Conversion/TritonCPUToLLVM/Passes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef TRITONCPU_CONVERSION_TRITONCPUTOLLVM_PASSES_H
#define TRITONCPU_CONVERSION_TRITONCPUTOLLVM_PASSES_H

#include "mlir/Conversion/LLVMCommon/TypeConverter.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Transforms/DialectConversion.h"

#include <memory>

namespace mlir {

class ModuleOp;
template <typename T> class OperationPass;

namespace triton {

#define GEN_PASS_DECL
#include "triton/Conversion/TritonCPUToLLVM/Passes.h.inc"

std::unique_ptr<OperationPass<ModuleOp>> createConvertTritonCPUToLLVMPass();

#define GEN_PASS_REGISTRATION
#include "triton/Conversion/TritonCPUToLLVM/Passes.h.inc"

} // namespace triton

} // namespace mlir

#endif
25 changes: 25 additions & 0 deletions include/triton/Conversion/TritonCPUToLLVM/Passes.td
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef TRITONCPU_CONVERSION_PASSES
#define TRITONCPU_CONVERSION_PASSES

include "mlir/Pass/PassBase.td"

def ConvertTritonCPUToLLVM : Pass<"convert-triton-cpu-to-llvm", "mlir::ModuleOp"> {
let summary = "Convert TritonCPU to LLVM";
let description = [{

}];
let constructor = "mlir::triton::createConvertTritonCPUToLLVMPass()";

let dependentDialects = ["mlir::arith::ArithDialect",
"mlir::LLVM::LLVMDialect",
"mlir::math::MathDialect",
"mlir::scf::SCFDialect",
"mlir::tensor::TensorDialect",
"mlir::triton::cpu::TritonCPUDialect",
"mlir::triton::TritonDialect"];

let options = [
];
}

#endif
Loading
Loading