Repository navigation
compiler: Misc tweaks to fully support FP16 storage/compute across all backends - #3109
FabioLuporini wants to merge 13 commits into
Conversation
Codecov Report❌ Patch coverage is 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
9645b9a to
d500a13
Compare
| 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 |
There was a problem hiding this comment.
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)): |
There was a problem hiding this comment.
Why would dtype not be a type?
| return self._dtype | ||
| ctype = self.dtype_base | ||
| if isinstance(ctype, CustomDtype): | ||
| return CustomDtype(ctype.name, ctype.template, ctype.modifier + self.stars) |
There was a problem hiding this comment.
Given that this is returning a new CustomDtype, does this property need caching to avoid duplication?
| op = Operator(Eq(f, f + 1), sym_opt=options) | ||
|
|
||
| assert op._sym_options['arithm-mode'] == mode | ||
| assert 'half-arith' not in op._sym_options |
There was a problem hiding this comment.
Seems a bit redundant to check the old name isn't in there?
| assert options == {'arithm-mode': mode} | ||
|
|
||
| @pytest.mark.parametrize('mode', [None, False, True, 1, 'float16', {}, []]) | ||
| def test_invalid_arithmetic_mode(self, mode): |
There was a problem hiding this comment.
Probably an overkill test?
| assert op1._soname == op2._soname | ||
|
|
||
| @pytest.mark.parametrize('mode', ['default', 'fp16']) | ||
| def test_jit_compiler_abi(self, mode, monkeypatch): |
There was a problem hiding this comment.
Try to avoid monkeypatching?
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.
ec48742 to
6d18720
Compare
| return expr.func(*args) | ||
|
|
||
|
|
||
| @_uxreplace_handle.register(OrderedAdd) |
There was a problem hiding this comment.
Makes no sense OrderedAdd is an Add why doesn't the dispatch already do that
| def __getstate__(self): | ||
| state = dict(self.__dict__) | ||
| # Recreate process-local ctypes classes from the Function's dtype | ||
| state.pop('_C_ctype', None) |
There was a problem hiding this comment.
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
|
|
||
| def test_dereference_base_plus_off(): | ||
| ptr = Pointer(name='p', dtype=np.float32) | ||
| ptr = Pointer(name='p', dtype_base=c_float) |
There was a problem hiding this comment.
Why would we used lowered ctypes instead of the numpy dtype and lower it like for everything else?
No description provided.