Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
21ad3a6
modernize sdfg performance analysis to support ControlFLowRegions
alexanderfluck Jun 17, 2026
56c3e6f
fix import bug
alexanderfluck Jun 17, 2026
2551003
fix neg int_floor
alexanderfluck Jun 17, 2026
d2b3d9d
Merge branch 'main' into modernize-performance-analysis
ThrudPrimrose Jun 18, 2026
afdc839
Merge branch 'main' into modernize-performance-analysis
ThrudPrimrose Jul 30, 2026
bba459a
Apply pre-commit formatting
ThrudPrimrose Jul 30, 2026
d05d910
Update pip install command in release.sh
ThrudPrimrose Jul 30, 2026
547ecd1
Merge branch 'main' into pr2407
ThrudPrimrose Jul 31, 2026
0ccc596
Count access-node copies, and compare work/depth by value
ThrudPrimrose Jul 31, 2026
8b087aa
Merge remote-tracking branch 'origin/main' into pr2407
ThrudPrimrose Jul 31, 2026
d21d977
Merge branch 'main' into pr2407
ThrudPrimrose Jul 31, 2026
9c2938d
Merge branch 'main' into pr2407
ThrudPrimrose Aug 4, 2026
2ee045c
Merge branch 'main' into pr2407
ThrudPrimrose Aug 5, 2026
72e2a3a
Include a symbol's dtype in its hash, so SymPy cannot alias two of th…
ThrudPrimrose Aug 5, 2026
37665f7
Revert "Include a symbol's dtype in its hash, so SymPy cannot alias t…
ThrudPrimrose Aug 6, 2026
bebb767
Merge remote-tracking branch 'origin/main' into pr2407
ThrudPrimrose Aug 6, 2026
0743968
Make symbolic deserialization immune to SymPy constructor cache pollu…
ThrudPrimrose Aug 6, 2026
53d68e2
Fix ExtUnparser attribute emission on Python 3.12+
ThrudPrimrose Aug 6, 2026
baf7047
Coerce Range.__setitem__ values to symbolic expressions
ThrudPrimrose Aug 6, 2026
cefc742
Merge remote-tracking branch 'origin/pr2407' into pr2407
ThrudPrimrose Aug 6, 2026
fba3090
Merge branch 'main' into pr2407
ThrudPrimrose Aug 6, 2026
6c0134e
Give each rank its own build cache root, under cache_distaware
ThrudPrimrose Aug 6, 2026
9512ca5
Delete tests/sdfg/work_depth_test_polybench.py
ThrudPrimrose Aug 10, 2026
369fcb5
style: bump copyright years to 2026
ThrudPrimrose Aug 10, 2026
3a903d1
Update default value for cache_distaware
ThrudPrimrose Aug 10, 2026
01704ee
Merge remote-tracking branch 'upstream/main' into feat/rank-aware-bui…
ThrudPrimrose Aug 10, 2026
20cb2c7
test: cover cache_distaware default flip in build folder tests
ThrudPrimrose Aug 10, 2026
c205df5
test: pin cache mode in the rank-default-split test
ThrudPrimrose Aug 10, 2026
16c5da2
Merge branch 'main' into feat/rank-aware-build-cache
ThrudPrimrose Aug 11, 2026
90d3c75
ci: pin xdist workers and MPI ranks to GPUs
ThrudPrimrose Aug 11, 2026
a4fa937
test: drop subsumed gpu pinning cases
ThrudPrimrose Aug 11, 2026
142d36c
Merge branch 'main' into ci/pin-gpu-workers
ThrudPrimrose Aug 11, 2026
87cd326
Merge branch 'main' into pr2407
ThrudPrimrose Aug 11, 2026
ab7fe7d
Merge remote-tracking branch 'origin/ci/pin-gpu-workers' into pr2407
ThrudPrimrose Aug 11, 2026
59c4562
Merge branch 'main' into pr2407
ThrudPrimrose Aug 11, 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
74 changes: 74 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Copyright 2019-2022 ETH Zurich and the DaCe authors. All rights reserved.
"""
Root pytest configuration file.
"""
import os
import subprocess

import pytest


def parse_worker_index(worker_id: str) -> int:
"""Parse the digits in a worker id or MPI rank string (e.g. 'gw3' -> 3, '12' -> 12).

Falls back to 0 for text with no digits (e.g. the non-xdist 'master' worker id).
"""
digits = ''.join(char for char in worker_id if char.isdigit())
return int(digits) if digits else 0


def list_cuda_devices() -> list:
"""Enumerate CUDA device indices via `nvidia-smi -L`, without touching CUDA in this process."""
try:
result = subprocess.run(['nvidia-smi', '-L'], capture_output=True, text=True, timeout=10)
except (OSError, subprocess.TimeoutExpired):
return []
if result.returncode != 0:
return []
device_lines = [line for line in result.stdout.splitlines() if line.startswith('GPU ')]
return [str(index) for index in range(len(device_lines))]


def pick_gpu_worker_device(worker_id: str, device_pool: list) -> str:
"""Round-robin a worker id (xdist worker or MPI rank) onto one device of device_pool."""
index = parse_worker_index(worker_id)
return device_pool[index % len(device_pool)]


def resolve_worker_id() -> str:
"""Id that places this process in a device rotation.

The pytest-xdist worker id if present, else the first set MPI/job-launcher rank env var
(dace.sdfg.sdfg.LAUNCHER_RANK_VARS, the same list dace itself reads for per-rank build
folders), else '' if this process is neither an xdist worker nor an MPI rank.
"""
xdist_worker = os.environ.get('PYTEST_XDIST_WORKER')
if xdist_worker is not None:
return xdist_worker
from dace.sdfg.sdfg import LAUNCHER_RANK_VARS
for var in LAUNCHER_RANK_VARS:
rank = os.environ.get(var)
if rank:
return rank
return ''


def pin_worker_to_gpu() -> None:
"""Pin this worker process (pytest-xdist or an MPI-launched rank) to a single GPU.

Without this, every worker/rank sees all GPUs and piles its CUDA context onto device 0, which
is the root cause of flaky 'invalid device ordinal' failures under high worker/rank counts.
"""
worker_id = resolve_worker_id()
if not worker_id:
return
preset = os.environ.get('CUDA_VISIBLE_DEVICES', '')
device_pool = [entry.strip() for entry in preset.split(',') if entry.strip()] if preset.strip() \
else list_cuda_devices()
if len(device_pool) <= 1:
return
os.environ['CUDA_VISIBLE_DEVICES'] = pick_gpu_worker_device(worker_id, device_pool)


def pytest_configure(config: pytest.Config) -> None:
pin_worker_to_gpu()
12 changes: 11 additions & 1 deletion dace/frontend/python/astutils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2025 ETH Zurich and the DaCe authors. All rights reserved.
# Copyright 2019-2026 ETH Zurich and the DaCe authors. All rights reserved.
""" Various AST parsing utilities for DaCe. """
import ast
import astunparse
Expand Down Expand Up @@ -216,6 +216,16 @@ def _Constant(self, t):
else:
super()._Constant(t)

def _Attribute(self, t):
self.dispatch(t.value)
# Special case: 3.__abs__() is a syntax error, so if t.value is an integer literal
# then we need to add an extra space to get 3 .__abs__(). astunparse checks this via
# ``ast.Num``, which was removed in Python 3.12; an int Constant is the same check.
if isinstance(t.value, ast.Constant) and isinstance(t.value.value, int):
self.write(" ")
self.write(".")
self.write(t.attr)

def _Subscript(self, t):
self.dispatch(t.value)
self.write('[')
Expand Down
56 changes: 30 additions & 26 deletions dace/sdfg/performance_evaluation/assumptions.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Copyright 2019-2023 ETH Zurich and the DaCe authors. All rights reserved.
# Copyright 2019-2026 ETH Zurich and the DaCe authors. All rights reserved.

import sympy as sp
from typing import Dict

from dace.symbolic import symbol


class UnionFind:
"""
Expand Down Expand Up @@ -112,7 +114,9 @@ def propagate_assumptions(x, y, condensed_assumptions):
condensed_assumptions[y] = Assumptions()
assum_y = condensed_assumptions[y]
for e in assum_x.equal:
if e is not sp.Symbol(y):
# Skip a self-reference (the symbol named ``y`` itself); compare by name because DaCe
# symbols, unlike sympy symbols, are not interned, so an ``is`` check would never match.
if not (isinstance(e, sp.Symbol) and e.name == y):
assum_y.add_equal(e)
for g in assum_x.greater:
assum_y.add_greater(g)
Expand Down Expand Up @@ -150,7 +154,7 @@ def propagate_assumptions_equal_symbols(condensed_assumptions):
for other in condensed_assumptions[sym].equal:
if isinstance(other, sp.Symbol):
propagate_assumptions(sym, uf.find(sym), condensed_assumptions)
equality_subs1.update({sym: sp.Symbol(uf.find(sym))})
equality_subs1.update({sym: symbol(uf.find(sym))})

equality_subs2 = {}
# In a second step, each symbol gets replaced with its equal number (if present)
Expand Down Expand Up @@ -221,37 +225,37 @@ def parse_assumptions(assumptions, array_symbols):
condensed_assumptions: Dict[str, Assumptions] = {}
for a in assumptions:
if '==' in a:
symbol, rhs = a.split('==')
if symbol not in condensed_assumptions:
condensed_assumptions[symbol] = Assumptions()
lhs, rhs = a.split('==')
if lhs not in condensed_assumptions:
condensed_assumptions[lhs] = Assumptions()
try:
condensed_assumptions[symbol].add_equal(int(rhs))
condensed_assumptions[lhs].add_equal(int(rhs))
except ValueError:
condensed_assumptions[symbol].add_equal(sp.Symbol(rhs))
condensed_assumptions[lhs].add_equal(symbol(rhs))
elif '>' in a:
symbol, rhs = a.split('>')
if symbol not in condensed_assumptions:
condensed_assumptions[symbol] = Assumptions()
lhs, rhs = a.split('>')
if lhs not in condensed_assumptions:
condensed_assumptions[lhs] = Assumptions()
try:
condensed_assumptions[symbol].add_greater(int(rhs))
condensed_assumptions[lhs].add_greater(int(rhs))
except ValueError:
condensed_assumptions[symbol].add_greater(sp.Symbol(rhs))
condensed_assumptions[lhs].add_greater(symbol(rhs))
# add the opposite, i.e. for x>y, we add y<x
if rhs not in condensed_assumptions:
condensed_assumptions[rhs] = Assumptions()
condensed_assumptions[rhs].add_lesser(sp.Symbol(symbol))
condensed_assumptions[rhs].add_lesser(symbol(lhs))
elif '<' in a:
symbol, rhs = a.split('<')
if symbol not in condensed_assumptions:
condensed_assumptions[symbol] = Assumptions()
lhs, rhs = a.split('<')
if lhs not in condensed_assumptions:
condensed_assumptions[lhs] = Assumptions()
try:
condensed_assumptions[symbol].add_lesser(int(rhs))
condensed_assumptions[lhs].add_lesser(int(rhs))
except ValueError:
condensed_assumptions[symbol].add_lesser(sp.Symbol(rhs))
condensed_assumptions[lhs].add_lesser(symbol(rhs))
# add the opposite, i.e. for x<y, we add y>x
if rhs not in condensed_assumptions:
condensed_assumptions[rhs] = Assumptions()
condensed_assumptions[rhs].add_greater(sp.Symbol(symbol))
condensed_assumptions[rhs].add_greater(symbol(lhs))

# Handle equal assumptions.
equality_subs = propagate_assumptions_equal_symbols(condensed_assumptions)
Expand All @@ -272,14 +276,14 @@ def parse_assumptions(assumptions, array_symbols):
for sym, assum in condensed_assumptions.items():
i = 0
for g in assum.greater:
replacement_symbol = sp.Symbol(f'_p_{sym}', positive=True, integer=True)
all_subs[i][0].update({sp.Symbol(sym): replacement_symbol + g})
all_subs[i][1].update({replacement_symbol: sp.Symbol(sym) - g})
replacement_symbol = symbol(f'_p_{sym}', nonnegative=True)
all_subs[i][0].update({symbol(sym): replacement_symbol + g})
all_subs[i][1].update({replacement_symbol: symbol(sym) - g})
i += 1
for l in assum.lesser:
replacement_symbol = sp.Symbol(f'_n_{sym}', negative=True, integer=True)
all_subs[i][0].update({sp.Symbol(sym): replacement_symbol + l})
all_subs[i][1].update({replacement_symbol: sp.Symbol(sym) - l})
replacement_symbol = symbol(f'_n_{sym}', negative=True)
all_subs[i][0].update({symbol(sym): replacement_symbol + l})
all_subs[i][1].update({replacement_symbol: symbol(sym) - l})
i += 1

return equality_subs, all_subs
Loading