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

feat[next]: Enable GTIR dace backend in feature tests #1705

Merged
merged 30 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e73cf43
updates to GTIR dace backend
edopao Oct 23, 2024
a3c02e4
fix pre-commit
edopao Oct 23, 2024
6c9b3c5
Merge remote-tracking branch 'origin/main' into dace-gtir-backend
edopao Oct 24, 2024
4ffb5f7
Merge remote-tracking branch 'origin/main' into dace-gtir-backend
edopao Oct 25, 2024
2ea0417
remove extra call to domain inference
edopao Oct 25, 2024
cc24240
fix pre-commit
edopao Oct 25, 2024
df636ab
Review comments
edopao Oct 25, 2024
d71b67f
Merge remote-tracking branch 'origin/main' into dace-gtir-backend
edopao Oct 25, 2024
58b97f1
Merge branch 'main' into dace-gtir-backend
edopao Oct 29, 2024
50cd2ce
Merge remote-tracking branch 'origin/main' into dace-gtir-backend
edopao Nov 4, 2024
5b4d2bf
enable tests
edopao Nov 4, 2024
1ad3621
make dace.gtir backend non-cached
edopao Nov 4, 2024
21997ad
Merge remote-tracking branch 'origin/main' into dace-gtir-backend
edopao Nov 4, 2024
489869c
fix pytest marker
edopao Nov 4, 2024
27e5b90
fix pytest marker (1)
edopao Nov 4, 2024
445b782
fix parsing of tuple program args
edopao Nov 4, 2024
83b7c25
cleanup gtir tests
edopao Nov 4, 2024
ef82b1f
fix for zero-dimensional arrays on gpu
edopao Nov 4, 2024
b885e74
Merge remote-tracking branch 'origin/main' into dace-gtir-backend
edopao Nov 4, 2024
0f3fd38
fix pre-commit
edopao Nov 4, 2024
a91ba4f
fix for zero-dimensional arrays on gpu (1)
edopao Nov 4, 2024
88e27a2
fix for zero-dimensional arrays on gpu (2)
edopao Nov 4, 2024
8036125
try removing simplify pass for gpu errors
edopao Nov 4, 2024
66d3be7
Run simplify before gpu transformations
edopao Nov 4, 2024
ef1df14
fix for array symbols
edopao Nov 4, 2024
02a9391
ADd pytest marker for failing gpu tests
edopao Nov 4, 2024
6fcd8da
Revert "ADd pytest marker for failing gpu tests"
edopao Nov 4, 2024
9ffc665
Keep gpu tests disabled
edopao Nov 4, 2024
d4973f5
edit code comments
edopao Nov 5, 2024
1afb1cb
remove extra call to gt_simplify
edopao Nov 5, 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
21 changes: 19 additions & 2 deletions src/gt4py/next/program_processors/runners/dace.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@

import factory

from gt4py._core import definitions as core_defs
from gt4py.next import allocators as next_allocators, backend
from gt4py.next.ffront import foast_to_gtir, past_to_itir
from gt4py.next.ffront import foast_to_gtir, foast_to_past, past_to_itir
from gt4py.next.program_processors.runners.dace_fieldview import workflow as dace_fieldview_workflow
from gt4py.next.program_processors.runners.dace_iterator import workflow as dace_iterator_workflow
from gt4py.next.program_processors.runners.gtfn import GTFNBackendFactory
Expand Down Expand Up @@ -47,10 +48,26 @@ class Params:

gtir_cpu = backend.Backend(
name="dace.gtir.cpu",
executor=dace_fieldview_workflow.DaCeWorkflowFactory(),
executor=dace_fieldview_workflow.DaCeWorkflowFactory(device_type=core_defs.DeviceType.CPU),
allocator=next_allocators.StandardCPUFieldBufferAllocator(),
transforms=backend.Transforms(
past_to_itir=past_to_itir.past_to_itir_factory(to_gtir=True),
foast_to_itir=foast_to_gtir.adapted_foast_to_gtir_factory(cached=True),
field_view_op_to_prog=foast_to_past.operator_to_program_factory(
foast_to_itir_step=foast_to_gtir.adapted_foast_to_gtir_factory(cached=True)
),
),
)

gtir_gpu = backend.Backend(
name="dace.gtir.gpu",
executor=dace_fieldview_workflow.DaCeWorkflowFactory(device_type=core_defs.DeviceType.CUDA),
allocator=next_allocators.StandardGPUFieldBufferAllocator(),
transforms=backend.Transforms(
past_to_itir=past_to_itir.past_to_itir_factory(to_gtir=True),
foast_to_itir=foast_to_gtir.adapted_foast_to_gtir_factory(cached=True),
field_view_op_to_prog=foast_to_past.operator_to_program_factory(
foast_to_itir_step=foast_to_gtir.adapted_foast_to_gtir_factory(cached=True)
),
),
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,19 @@

import dace
import factory
from dace.transformation.auto import auto_optimize as dace_autoopt

from gt4py._core import definitions as core_defs
from gt4py.next import common, config
from gt4py.next import allocators as gtx_allocators, common, config
from gt4py.next.iterator import ir as itir, transforms as itir_transforms
from gt4py.next.otf import languages, recipes, stages, step_types, workflow
from gt4py.next.otf.binding import interface
from gt4py.next.otf.languages import LanguageSettings
from gt4py.next.program_processors.runners.dace_common import workflow as dace_workflow
from gt4py.next.program_processors.runners.dace_fieldview import gtir_sdfg
from gt4py.next.type_system import type_translation as tt
from gt4py.next.program_processors.runners.dace_fieldview import (
gtir_sdfg,
transformations as gtx_transformations,
)


@dataclasses.dataclass(frozen=True)
Expand All @@ -33,7 +36,8 @@ class DaCeTranslator(
],
step_types.TranslationStep[languages.SDFG, languages.LanguageSettings],
):
device_type: core_defs.DeviceType = core_defs.DeviceType.CPU
device_type: core_defs.DeviceType
auto_optimize: bool

def _language_settings(self) -> languages.LanguageSettings:
return languages.LanguageSettings(
Expand All @@ -45,9 +49,18 @@ def generate_sdfg(
ir: itir.Program,
offset_provider: common.OffsetProvider,
column_axis: Optional[common.Dimension],
auto_opt: bool,
on_gpu: bool,
) -> dace.SDFG:
ir = itir_transforms.apply_fieldview_transforms(ir, offset_provider=offset_provider)
return gtir_sdfg.build_sdfg_from_gtir(ir=ir, offset_provider=offset_provider)
sdfg = gtir_sdfg.build_sdfg_from_gtir(ir, offset_provider=offset_provider)

if auto_opt:
return gtx_transformations.gt_auto_optimize(sdfg, gpu=on_gpu)
edopao marked this conversation as resolved.
Show resolved Hide resolved
elif on_gpu:
dace_autoopt.apply_gpu_storage(sdfg)
edopao marked this conversation as resolved.
Show resolved Hide resolved

return sdfg

def __call__(
self, inp: stages.CompilableProgram
Expand All @@ -60,11 +73,13 @@ def __call__(
program,
inp.args.offset_provider,
inp.args.column_axis,
auto_opt=self.auto_optimize,
on_gpu=(self.device_type == gtx_allocators.CUPY_DEVICE),
)

param_types = tuple(
interface.Parameter(param, tt.from_value(arg))
for param, arg in zip(sdfg.arg_names, inp.args.args)
interface.Parameter(param, arg_type)
for param, arg_type in zip(sdfg.arg_names, inp.args.args)
)

module: stages.ProgramSource[languages.SDFG, languages.LanguageSettings] = (
Expand Down Expand Up @@ -98,10 +113,12 @@ class Params:
cmake_build_type: config.CMakeBuildType = factory.LazyFunction(
lambda: config.CMAKE_BUILD_TYPE
)
auto_optimize: bool = False

translation = factory.SubFactory(
DaCeTranslationStepFactory,
device_type=factory.SelfAttribute("..device_type"),
auto_optimize=factory.SelfAttribute("..auto_optimize"),
)
bindings = _no_bindings
compilation = factory.SubFactory(
Expand Down
2 changes: 2 additions & 0 deletions tests/next_tests/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class OptionalProgramBackendId(_PythonObjectIdMixin, str, enum.Enum):
DACE_CPU = "gt4py.next.program_processors.runners.dace.itir_cpu"
DACE_GPU = "gt4py.next.program_processors.runners.dace.itir_gpu"
GTIR_DACE_CPU = "gt4py.next.program_processors.runners.dace.gtir_cpu"
GTIR_DACE_GPU = "gt4py.next.program_processors.runners.dace.gtir_gpu"


class ProgramFormatterId(_PythonObjectIdMixin, str, enum.Enum):
Expand Down Expand Up @@ -175,6 +176,7 @@ class ProgramFormatterId(_PythonObjectIdMixin, str, enum.Enum):
OptionalProgramBackendId.DACE_CPU: DACE_SKIP_TEST_LIST,
OptionalProgramBackendId.DACE_GPU: DACE_SKIP_TEST_LIST,
OptionalProgramBackendId.GTIR_DACE_CPU: GTIR_DACE_SKIP_TEST_LIST,
OptionalProgramBackendId.GTIR_DACE_GPU: GTIR_DACE_SKIP_TEST_LIST,
ProgramBackendId.GTFN_CPU: GTFN_SKIP_TEST_LIST
+ [(USES_SCAN_NESTED, XFAIL, UNSUPPORTED_MESSAGE)],
ProgramBackendId.GTFN_CPU_IMPERATIVE: GTFN_SKIP_TEST_LIST
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,16 @@ def __gt_allocator__(
next_tests.definitions.OptionalProgramBackendId.DACE_CPU,
marks=pytest.mark.requires_dace,
),
pytest.param(
next_tests.definitions.OptionalProgramBackendId.DACE_GPU,
marks=(pytest.mark.requires_dace, pytest.mark.requires_gpu),
),
pytest.param(
next_tests.definitions.OptionalProgramBackendId.GTIR_DACE_CPU,
marks=pytest.mark.requires_dace,
),
pytest.param(
next_tests.definitions.OptionalProgramBackendId.DACE_GPU,
next_tests.definitions.OptionalProgramBackendId.GTIR_DACE_GPU,
marks=(pytest.mark.requires_dace, pytest.mark.requires_gpu),
),
],
Expand Down
Loading