Skip to content

compiler: Misc tweaks to fully support FP16 storage/compute across all backends - #3109

Open
FabioLuporini wants to merge 13 commits into
mainfrom
fix/fp16-wdr-storage
Open

FabioLuporini wants to merge 13 commits into
mainfrom
fix/fp16-wdr-storage

Conversation

@FabioLuporini

Copy link
Copy Markdown
Contributor

No description provided.

@codecov

codecov Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.75472% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.24%. Comparing base (1eb54aa) to head (6d18720).

Files with missing lines Patch % Lines
devito/symbolics/extended_sympy.py 66.66% 3 Missing and 1 partial ⚠️
devito/ir/iet/visitors.py 50.00% 1 Missing and 1 partial ⚠️
devito/symbolics/unevaluation.py 84.61% 1 Missing and 1 partial ⚠️
devito/passes/iet/definitions.py 92.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3109      +/-   ##
==========================================
+ Coverage   84.20%   84.24%   +0.04%     
==========================================
  Files         260      260              
  Lines       59481    59664     +183     
  Branches     5023     5030       +7     
==========================================
+ Hits        50085    50265     +180     
- Misses       8561     8563       +2     
- Partials      835      836       +1     
Flag Coverage Δ
pytest-gpu-aomp-amdgpuX 68.28% <56.80%> (-0.05%) ⬇️
pytest-gpu-gcc- 79.01% <95.75%> (+0.06%) ⬆️
pytest-gpu-icx- 78.96% <95.75%> (+0.07%) ⬆️
pytest-gpu-nvc-nvidiaX 69.08% <56.80%> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@FabioLuporini
FabioLuporini force-pushed the fix/fp16-wdr-storage branch 3 times, most recently from 9645b9a to d500a13 Compare November 16, 2026 14:58
Comment thread devito/mpi/routines.py Outdated
f = alias or self.target.c0
neighborhood = f.grid.distributor.neighborhood
# Internal Arrays may retain a serialized, non-distributed Grid
neighborhood = args.grid.distributor.neighborhood

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gets rehashed in #3108 . Also pretty sure this is undoing a functions on subdomains bug that got patched...

def _eval_is_integer(self):
dtype = extract_dtype(self.value)
if (self.value.is_integer or
isinstance(dtype, type) and issubclass(dtype, np.integer)):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would dtype not be a type?

Comment thread devito/types/misc.py
return self._dtype
ctype = self.dtype_base
if isinstance(ctype, CustomDtype):
return CustomDtype(ctype.name, ctype.template, ctype.modifier + self.stars)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that this is returning a new CustomDtype, does this property need caching to avoid duplication?

Comment thread tests/test_operator.py
op = Operator(Eq(f, f + 1), sym_opt=options)

assert op._sym_options['arithm-mode'] == mode
assert 'half-arith' not in op._sym_options

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems a bit redundant to check the old name isn't in there?

Comment thread tests/test_operator.py
assert options == {'arithm-mode': mode}

@pytest.mark.parametrize('mode', [None, False, True, 1, 'float16', {}, []])
def test_invalid_arithmetic_mode(self, mode):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably an overkill test?

Comment thread tests/test_operator.py
assert op1._soname == op2._soname

@pytest.mark.parametrize('mode', ['default', 'fp16'])
def test_jit_compiler_abi(self, mode, monkeypatch):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to avoid monkeypatching?

FabioLuporini and others added 13 commits November 20, 2026 14:24
Copilot now supplies saved Function replacements with matching ConditionalDimension factors, so the broad override filter is unnecessary.
Use arithm-mode throughout symbolic lowering and include generated source and compiler ABI in every Operator signature. Preserve scalar component and cast-pointer result types for ordinary packed accesses.

Validate focused CPU typing, JIT identity and serialization checks, plus the dependent PRO GPU arithmetic checks.
Store the picklable pointee type and indirection in standard reconstruction
metadata, deriving the full ctype on demand. Remove the custom ctypes pointer
reducer and cover pointer depth, equality, scope and serialization.
Resolve MPI neighbors from the execution Grid so reconstructed internal Arrays communicate between decoupler workers. Also wrap the overlong symbolic-test imports.
Return a conservative result for C-only types such as size_t instead of passing NumPy's TypeError through FP16 code generation. Cover numeric ctypes and opaque dtypes in scalar and mixed argument queries.

Validation: 9 targeted OSS symbolic tests, 12 CUDA regression and adjacent tests, isort, Flake8, and Ruff.
Select the RHS precision before creating an exact-precision printer and forward normalized Operator options to dtype-specific lowering passes.
Keep marked sums and products opaque to CSE and factorization, and
preserve their stored operand order when printing. Dedicated uxreplace
handlers retain the existing scalar reconstruction semantics.

Cover FP16/FP32 printing, substitutions and Operator factorization.
Allow make_callable to instantiate a semantic Callable subclass and expose
known cast access widths through cached metadata. Represent inline device
helpers as DeviceFunctions alongside kernels.

Validated with OSS symbolic regressions and PRO CPU/CUDA Operator tests.
return expr.func(*args)


@_uxreplace_handle.register(OrderedAdd)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes no sense OrderedAdd is an Add why doesn't the dispatch already do that

Comment thread devito/types/basic.py
def __getstate__(self):
state = dict(self.__dict__)
# Recreate process-local ctypes classes from the Function's dtype
state.pop('_C_ctype', None)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be better if Pickable implementent something like _ignored_state so that don't need to add __getstate__ everywhere and just

_ignored_state = '_C_ctype`.

would extend to a bunch of place wehre we have stuff like that

Comment thread tests/test_iet.py

def test_dereference_base_plus_off():
ptr = Pointer(name='p', dtype=np.float32)
ptr = Pointer(name='p', dtype_base=c_float)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would we used lowered ctypes instead of the numpy dtype and lower it like for everything else?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants