Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
53595cb
add gpu decorator (@gpu)
SousaTrashBin Mar 12, 2026
f5a6687
add some gpu helper functions such as Tensor_length
SousaTrashBin Mar 12, 2026
2e9a1b4
add some gpu tests (for now uses CPU but should work nonetheless)
SousaTrashBin Mar 12, 2026
637fee7
remove gpu tests, still need to verify if syntax will stay the same o…
SousaTrashBin Mar 13, 2026
21d0c43
add gpu subset code validation (including recursion checking)
SousaTrashBin Mar 13, 2026
4dd1947
add verification to types and ops (for now only supports builtins)
SousaTrashBin Mar 13, 2026
6131a23
add gpu subset ast representation as well as a way to convert between…
SousaTrashBin Mar 13, 2026
36a6560
not sure why this is needed (reminder to ask)
SousaTrashBin Mar 13, 2026
10cd390
add some gpu subset testing (still need to study a bit of llvm syntax…
SousaTrashBin Mar 13, 2026
4a06aad
eventually this will be the file that hosts the conversion between th…
SousaTrashBin Mar 13, 2026
14996ea
still need to add the generation of the kernel itself
SousaTrashBin Mar 13, 2026
842013e
fix, was using a raw str but should instead use the Name dataclass
SousaTrashBin Mar 13, 2026
8cfe97a
forgot to setup auto ruff
SousaTrashBin Mar 13, 2026
8d0fd05
add llvm decorator
SousaTrashBin Mar 18, 2026
d647c6d
remove unused files
SousaTrashBin Mar 18, 2026
5fa3671
add Vector library, technically we could use List, but in this way, t…
SousaTrashBin Mar 31, 2026
17d6bb1
add `CPULLVMPipeline` implementation, integrate function compilation …
SousaTrashBin Apr 1, 2026
72268f1
add gpu decorator (@gpu)
SousaTrashBin Mar 12, 2026
f5298c5
add some gpu helper functions such as Tensor_length
SousaTrashBin Mar 12, 2026
76b04dc
add some gpu tests (for now uses CPU but should work nonetheless)
SousaTrashBin Mar 12, 2026
67311bc
remove gpu tests, still need to verify if syntax will stay the same o…
SousaTrashBin Mar 13, 2026
1b79599
add gpu subset code validation (including recursion checking)
SousaTrashBin Mar 13, 2026
4035bd8
add verification to types and ops (for now only supports builtins)
SousaTrashBin Mar 13, 2026
c76d6dd
add gpu subset ast representation as well as a way to convert between…
SousaTrashBin Mar 13, 2026
2a6891c
not sure why this is needed (reminder to ask)
SousaTrashBin Mar 13, 2026
50a6d60
add some gpu subset testing (still need to study a bit of llvm syntax…
SousaTrashBin Mar 13, 2026
27a9265
eventually this will be the file that hosts the conversion between th…
SousaTrashBin Mar 13, 2026
82adb86
still need to add the generation of the kernel itself
SousaTrashBin Mar 13, 2026
083f1fe
fix, was using a raw str but should instead use the Name dataclass
SousaTrashBin Mar 13, 2026
29886d9
forgot to setup auto ruff
SousaTrashBin Mar 13, 2026
3f2b5cf
remove unused files
SousaTrashBin Mar 18, 2026
3ac5f3e
add Vector library, technically we could use List, but in this way, t…
SousaTrashBin Mar 31, 2026
70b5580
fix(llvm): only compile @llvm targets; align tests with master
alcides Apr 18, 2026
329f8eb
feat(llvm): add new llvm backend pipeline class `MultiBackendPipeline…
SousaTrashBin Apr 20, 2026
447131b
feat(temp): add way to skip elaboration/type checking just to test op…
SousaTrashBin Apr 20, 2026
fccb20a
add gpu decorator (@gpu)
SousaTrashBin Mar 12, 2026
f684736
add some gpu helper functions such as Tensor_length
SousaTrashBin Mar 12, 2026
5b5a18b
add some gpu tests (for now uses CPU but should work nonetheless)
SousaTrashBin Mar 12, 2026
20c9934
remove gpu tests, still need to verify if syntax will stay the same o…
SousaTrashBin Mar 13, 2026
359e71d
add gpu subset code validation (including recursion checking)
SousaTrashBin Mar 13, 2026
f2e9044
add verification to types and ops (for now only supports builtins)
SousaTrashBin Mar 13, 2026
706b065
add gpu subset ast representation as well as a way to convert between…
SousaTrashBin Mar 13, 2026
0fd84fc
not sure why this is needed (reminder to ask)
SousaTrashBin Mar 13, 2026
ae67771
add some gpu subset testing (still need to study a bit of llvm syntax…
SousaTrashBin Mar 13, 2026
b28147e
eventually this will be the file that hosts the conversion between th…
SousaTrashBin Mar 13, 2026
4b57768
still need to add the generation of the kernel itself
SousaTrashBin Mar 13, 2026
d2d073e
fix, was using a raw str but should instead use the Name dataclass
SousaTrashBin Mar 13, 2026
92e96b5
forgot to setup auto ruff
SousaTrashBin Mar 13, 2026
224a9fb
fix validate method signature; now receives a list of valid function …
SousaTrashBin Mar 18, 2026
baf88a4
remove unused files
SousaTrashBin Mar 18, 2026
ec99507
update some LLVM AST types and terms data, also add some str represen…
SousaTrashBin Mar 18, 2026
1cc5f1c
update last test to represent another step of the verification pipeli…
SousaTrashBin Mar 18, 2026
6ac154b
add another verification step (Full Application);
SousaTrashBin Mar 18, 2026
237a1ab
fix some type signature bugs
SousaTrashBin Mar 18, 2026
f94b837
done some changes to ensure lowering works even with anf partial appl…
SousaTrashBin Mar 27, 2026
dc3a2b2
ruff linting
SousaTrashBin Mar 27, 2026
7482291
add Vector library, technically we could use List, but in this way, t…
SousaTrashBin Mar 31, 2026
9720cba
extend `llvm ast` with vector operations, and add new LLVM term repre…
SousaTrashBin Apr 1, 2026
9dc0457
add `CPULLVMPipeline` implementation, integrate function compilation …
SousaTrashBin Apr 1, 2026
6eabff9
add `LLVMCast` term, improve vector operation handling in IR generati…
SousaTrashBin Apr 1, 2026
86623af
extend LLVM lowering with vector operation handling and built-in func…
SousaTrashBin Apr 1, 2026
4fad6e0
refactor validation and lowering in LLVM backend
SousaTrashBin Apr 13, 2026
94d6b54
add `to_ir` methods for LLVM types and `accept` methods for LLVM term…
SousaTrashBin Apr 13, 2026
c96cdf3
refactor according to mypy and ruff
SousaTrashBin Apr 13, 2026
947af82
fix rebase-introduced duplicate LLVM definitions
alcides Apr 22, 2026
3335bec
feat(cuda): add some cuda examples, histogram (which is not still wor…
SousaTrashBin Apr 27, 2026
d2e00dd
feat: add cupy-cuda12 as an optional dependency for the gpu/cuda kern…
SousaTrashBin Apr 27, 2026
07955d9
feat: improve type conversion/casting
SousaTrashBin Apr 27, 2026
2e1bf14
feat: improve/simplify cuda conversion
SousaTrashBin Apr 27, 2026
eee3e9f
feat: add optimization pass to llvm_ir execution
SousaTrashBin Apr 27, 2026
7ecebf9
feat: simplify cuda executor
SousaTrashBin Apr 27, 2026
a4661a6
feat: add some extra decorator metadata (maybe some are not needed su…
SousaTrashBin Apr 27, 2026
3688c35
feat: expand decorator metadata to include target, opt_level, and log…
SousaTrashBin Apr 27, 2026
c7d2cda
feat: fix some minor issues relative to the llvm pipeline
SousaTrashBin Apr 27, 2026
3632192
feat: implement find_calls method for LLVM terms and simplify CUDA co…
SousaTrashBin Apr 28, 2026
7ce660d
feat(cpu): migrate LLVM decorators to CPU decorators and enhance back…
SousaTrashBin Apr 28, 2026
c67a55b
fix(cuda): add verification to LLVM module before target machine crea…
SousaTrashBin Apr 28, 2026
7bf013b
fix(cuda): specify speed level
SousaTrashBin Apr 28, 2026
ce6a70e
feat(cpu): add `Vector_size` implementation, add header-based size ma…
SousaTrashBin Apr 28, 2026
c19ece6
feat(llvm): add some CPU and GPU simple tests that execute on the CI/…
SousaTrashBin Apr 28, 2026
1c1a89e
fix: change func name
SousaTrashBin Apr 28, 2026
65a24d8
fix: remove ';' from imports
SousaTrashBin Apr 28, 2026
5859259
feat(llvm): improve backend execution robustness and error logging
SousaTrashBin Apr 28, 2026
b74e4bb
feat(llvm): fix infinite recursion fallback for CPU/GPU execution
SousaTrashBin Apr 28, 2026
c2d3fe1
fix(cpu): prevent redundant block creation in function conversion
SousaTrashBin Apr 28, 2026
dc71683
fix(llvm): some fixes according to ruff and mypy
SousaTrashBin Apr 28, 2026
cd2749e
feat(cpu): add some cpu test examples
SousaTrashBin Apr 28, 2026
49166f2
feat(llvm): add `LLVMVector` class to handle pointer-based vector ope…
SousaTrashBin Apr 28, 2026
94fd754
feat(llvm): add back the gpu busy example
SousaTrashBin Apr 28, 2026
33d0943
fix: use full parameter list for partial application resolution in lo…
alcides Apr 29, 2026
2dbc106
fix: post-rebase fixes for mypy, import syntax, and missing LLVM AST …
alcides Apr 30, 2026
75fc079
fix: register @llvm as backward-compatible alias for @cpu decorator
alcides Apr 30, 2026
7c6499c
fix: add Vector.size to Vector library for evaluator fallback
alcides Apr 30, 2026
6e59205
feat(llvm): squash cuda/cpu backend development commits
SousaTrashBin Apr 30, 2026
93b3985
fix: remove debug print, upgrade fallback logs to warning, add missin…
alcides May 1, 2026
bfffb3b
chore: remove dead CPULLVMPipeline (superseded by MultiBackendPipeline)
alcides May 1, 2026
dcf69f3
refactor(llvm): clean up function names, make `invoke` function clean…
SousaTrashBin May 1, 2026
bf44b74
feat(llvm): add debug LLVM IR/PTX file writing
SousaTrashBin May 6, 2026
0474b2e
feat(core): add `Vector` type support and remove GPU/Tensor-related code
SousaTrashBin May 6, 2026
1001175
refactor(core): remove unused `Vector` type definition (now it's a bu…
SousaTrashBin May 6, 2026
05473ec
feat(llvm): improve type validation and resolution
SousaTrashBin May 6, 2026
6cbcd30
feat(llvm): add raw vector runtime helpers
SousaTrashBin May 12, 2026
9b3abef
refactor(llvm): simplify backend metadata
SousaTrashBin May 12, 2026
5cac56e
feat(llvm): add planned CUDA vector execution
SousaTrashBin May 12, 2026
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
7 changes: 7 additions & 0 deletions aeon/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ def _parse_common_arguments(parser: ArgumentParser):

parser.add_argument("-n", "--no-main", action="store_true", help="Disables introducing hole in main")

parser.add_argument(
"--skip-elaboration",
action="store_true",
help="Skip the elaboration step",
)

parser.add_argument(
"-s",
"--synthesizer",
Expand Down Expand Up @@ -142,6 +148,7 @@ def main() -> None:
timings=args.timings,
no_main=args.no_main,
synthesis_format=SynthesisFormat.from_string(args.synthesis_format),
skip_elaboration=args.skip_elaboration,
)
driver = AeonDriver(cfg)

Expand Down
50 changes: 29 additions & 21 deletions aeon/backend/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

from typing import Any

from aeon.core.terms import Abstraction, RefinementAbstraction, RefinementApplication, TypeAbstraction, TypeApplication
from aeon.core.terms import (
Abstraction,
RefinementApplication,
TypeAbstraction,
TypeApplication,
RefinementAbstraction,
)
from aeon.core.terms import Annotation
from aeon.core.terms import Application
from aeon.core.terms import Hole
Expand All @@ -12,9 +18,9 @@
from aeon.core.terms import Rec
from aeon.core.terms import Term
from aeon.core.terms import Var
from aeon.utils.name import Name
from aeon.decorators.api import Metadata
from aeon.llvm.core import LLVMPipeline
from aeon.utils.name import Name

real_eval = eval

Expand Down Expand Up @@ -87,32 +93,34 @@ def eval(t: Term, ctx: EvaluationContext = EvaluationContext()) -> Any:
case Let(var_name, var_value, body):
return eval(body, ctx.with_var(var_name, eval(var_value, ctx)))
case Rec(var_name, _, var_value, body, _, _):
found_llvm = False
if ctx.pipeline and ctx.metadata:
name_str = var_name.name
for k, v in ctx.metadata.items():
k_name = k.name if isinstance(k, Name) else str(k)
if k_name == name_str and v.get("llvm"):
found_llvm = True
break

if found_llvm:
try:
v = ctx.pipeline.get_curried_function(var_name)
if v is not None:
return eval(body, ctx.with_var(var_name, v))
except Exception:
pass

if isinstance(var_value, Abstraction):
fun = var_value

def v(x):
def v_py(x):
return eval(
fun.body,
ctx.with_var(var_name, v).with_var(fun.var_name, x),
ctx.with_var(var_name, v_py).with_var(fun.var_name, x),
)

v = v_py

if ctx.pipeline and ctx.metadata:
name_str = var_name.name
found_llvm = False
for k, meta in ctx.metadata.items():
k_name = k.name if isinstance(k, Name) else str(k)
if k_name == name_str and (meta.get("cpu") or meta.get("gpu")):
found_llvm = True
break

if found_llvm:
try:
v_llvm = ctx.pipeline.get_curried_function(var_name, native_fallback=v_py)
if v_llvm is not None:
v = v_llvm
except Exception:
v = v_py
pass
else:
v = eval(var_value, ctx)
return eval(body, ctx.with_var(var_name, v))
Expand Down
2 changes: 1 addition & 1 deletion aeon/core/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def simple_t(self, args):
n = str(args[0])
if n == "Top":
return top
elif n in ["Unit", "Int", "Bool", "Float", "String"]:
elif n in ["Unit", "Int", "Bool", "Float", "String", "Vector", "Set"]:
return TypeConstructor(Name(n, 0))
else:
return TypeVar(Name(n))
Expand Down
5 changes: 2 additions & 3 deletions aeon/core/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,10 @@ def __hash__(self) -> int:
t_int = TypeConstructor(Name("Int", 0), [])
t_float = TypeConstructor(Name("Float", 0), [])
t_string = TypeConstructor(Name("String", 0), [])
t_vector = TypeConstructor(Name("Vector", 0), [])
t_set = TypeConstructor(Name("Set", 0), [])
t_tensor = TypeConstructor(Name("Tensor", 0), [])
t_gpu_config = TypeConstructor(Name("GpuConfig", 0), [])

builtin_core_types = [t_unit, t_bool, t_int, t_float, t_string, t_set, t_tensor, t_gpu_config]
builtin_core_types = [t_unit, t_bool, t_int, t_float, t_string, t_vector, t_set]

top = Top()

Expand Down
25 changes: 18 additions & 7 deletions aeon/facade/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class AeonConfig:
timings: bool = False
no_main: bool = False
synthesis_format: SynthesisFormat = SynthesisFormat.DEFAULT
skip_elaboration: bool = False


class AeonDriver:
Expand Down Expand Up @@ -71,9 +72,18 @@ def parse(self, filename: str = None, aeon_code: str = None) -> Iterable[AeonErr
)
metadata: Metadata = desugared.metadata

from aeon.decorators.api import CORE_DECORATOR_QUEUE_META_KEY

auto_skip_elaboration = self.cfg.skip_elaboration or (
CORE_DECORATOR_QUEUE_META_KEY in metadata and len(metadata[CORE_DECORATOR_QUEUE_META_KEY]) > 0
)

try:
with RecordTime("Elaboration"):
sterm: STerm = elaborate(desugared.elabcontext, desugared.program, st_top)
if auto_skip_elaboration:
sterm: STerm = desugared.program
else:
with RecordTime("Elaboration"):
sterm = elaborate(desugared.elabcontext, desugared.program, st_top)
except AeonError as e:
return [e] # TODO: Support multiple errors

Expand All @@ -85,11 +95,12 @@ def parse(self, filename: str = None, aeon_code: str = None) -> Iterable[AeonErr
with RecordTime("ANF conversion"):
core_ast_anf = ensure_anf(core_ast)

with RecordTime("TypeChecking"):
type_errors = check_type_errors(typing_ctx, core_ast_anf, top)
# TODO
if type_errors:
return type_errors
if not auto_skip_elaboration:
with RecordTime("TypeChecking"):
type_errors = check_type_errors(typing_ctx, core_ast_anf, top)
# TODO
if type_errors:
return type_errors

with RecordTime("CorePhaseDecorators"):
metadata = apply_core_decorators_phase(typing_ctx, core_ast_anf, metadata)
Expand Down
44 changes: 44 additions & 0 deletions aeon/llvm/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from __future__ import annotations

from enum import Enum
from typing import Any, Mapping


class LLVMBackendName(str, Enum):
CPU = "cpu"
CUDA = "cuda"


class LLVMMetadataKey(str, Enum):
CPU_ENABLED = "cpu"
CPU_OPT_LEVEL = "cpu_opt_level"
GPU_ENABLED = "gpu"
GPU_DEVICE = "gpu_device"
GPU_OPT_LEVEL = "gpu_opt_level"
GPU_DEBUG = "gpu_debug"
GPU_BLOCK_SIZE = "gpu_block_size"
GPU_ARCH = "gpu_arch"
GPU_KERNEL_PLAN = "gpu_kernel_plan"
GPU_NO_DEVICE_ALLOC = "gpu_no_device_alloc"
SIZE = "size"


class VectorOperation(str, Enum):
MAP = "map"
REDUCE = "reduce"
IMAP = "imap"
FILTER = "filter"
ZIP_WITH = "zipWith"
COUNT = "count"
SIZE = "size"


VECTOR_OPERATION_NAMES: frozenset[str] = frozenset(op.value for op in VectorOperation)


def metadata_get(metadata: Mapping[str, Any], key: LLVMMetadataKey, default: Any = None) -> Any:
return metadata.get(key.value, default)


def metadata_has(metadata: Mapping[str, Any], key: LLVMMetadataKey) -> bool:
return key.value in metadata
28 changes: 26 additions & 2 deletions aeon/llvm/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
LLVMVectorFilter,
LLVMVectorZipWith,
LLVMVectorCount,
LLVMVectorGet,
LLVMVectorSet,
LLVMVectorSize,
)
else:
LLVMTerm = Any
Expand All @@ -48,6 +51,9 @@
LLVMVectorFilter = Any
LLVMVectorZipWith = Any
LLVMVectorCount = Any
LLVMVectorGet = Any
LLVMVectorSet = Any
LLVMVectorSize = Any


class LLVMBackendError(Exception):
Expand Down Expand Up @@ -108,7 +114,13 @@ def optimize(self, llvm_ir: str, opt_level: int = 3) -> str:
class LLVMExecutionEngine(ABC):
@abstractmethod
def execute(
self, llvm_ir: str, func_name: str, args: List[Any], arg_types: List[LLVMType], ret_type: LLVMType
self,
llvm_ir: str,
func_name: str,
args: List[Any],
arg_types: List[LLVMType],
ret_type: LLVMType,
metadata: dict[str, Any] | None = None,
) -> Any:
pass

Expand All @@ -126,7 +138,7 @@ def compile(self, program: Term) -> None:
pass

@abstractmethod
def get_curried_function(self, name: Name) -> Any:
def get_curried_function(self, name: Name, native_fallback: Any = None) -> Any:
pass

@abstractmethod
Expand Down Expand Up @@ -206,3 +218,15 @@ def visit_vector_zipwith(self, node: LLVMVectorZipWith) -> Any:
@abstractmethod
def visit_vector_count(self, node: LLVMVectorCount) -> Any:
pass

@abstractmethod
def visit_vector_get(self, node: LLVMVectorGet) -> Any:
pass

@abstractmethod
def visit_vector_set(self, node: LLVMVectorSet) -> Any:
pass

@abstractmethod
def visit_vector_size(self, node: LLVMVectorSize) -> Any:
pass
Loading
Loading