Skip to content

compiler: Misc dtype lowering tweaks - #3090

Merged
FabioLuporini merged 10 commits into
mainfrom
next-gen
Oct 28, 2026
Merged

FabioLuporini merged 10 commits into
mainfrom
next-gen

Conversation

@FabioLuporini

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread devito/operator/operator.py Outdated
values = p._arg_values(estimate_memory=estimate_memory, **kwargs)
# A replacement may supply defaults for other arguments, such as
# a ConditionalDimension's factor. Explicit overrides take precedence
args.update({k: v for k, v in values.items()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is gonna get dropped

Comment thread devito/operator/operator.py Outdated
for p in overrides:
args.update(p._arg_values(estimate_memory=estimate_memory, **kwargs))
values = p._arg_values(estimate_memory=estimate_memory, **kwargs)
# A replacement may supply defaults for other arguments, such as

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 looks like a bug in _arg_values

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it probably is, but as I wrote yesterday, I'm dropping this line for now. I moving the logic in copilot directly.

the issue here is when one supplies a factor= override while the supplied saved TimeFunction overrides still have the old factor

Comment thread devito/symbolics/inspection.py Outdated
if not dtypes or not np.issubdtype(base, np.complexfloating):
dtypes.update({base} - {None})

dtypes = {dtypes_vector_mapper.get_base_dtype(i, i) for i in dtypes}

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.

second place it's like that, why not move it inside infer_dtype?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread devito/tools/dtypes_lowering.py Outdated
return max(dtypes, key=lambda i: np.dtype(i).itemsize, default=None)
dtype = max(dtypes, key=lambda i: np.dtype(i).itemsize, default=None)

return dtypes_vector_mapper[dtype, n] if n > 1 else dtype

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.

likely need .get for safety?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes

Comment thread devito/tools/dtypes_lowering.py Outdated
Extract the result dtype, retaining typed vector operands such as float2.
"""
# Arithmetic nodes may expose only their Functions' scalar precision
if not (expr.is_Add or expr.is_Mul or expr.is_Pow):

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.

so what does it leave? THis is an off check

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

@codecov

codecov Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.99248% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.45%. Comparing base (61a2745) to head (8741e35).

Files with missing lines Patch % Lines
devito/arch/archinfo.py 57.14% 1 Missing and 2 partials ⚠️
devito/tools/dtypes_lowering.py 94.73% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3090      +/-   ##
==========================================
+ Coverage   84.40%   84.45%   +0.04%     
==========================================
  Files         260      260              
  Lines       58153    58262     +109     
  Branches     4948     4956       +8     
==========================================
+ Hits        49086    49203     +117     
+ Misses       8245     8229      -16     
- Partials      822      830       +8     
Flag Coverage Δ
pytest-gpu-aomp-amdgpuX 68.43% <63.04%> (-0.02%) ⬇️
pytest-gpu-gcc- 79.16% <96.99%> (+0.07%) ⬆️
pytest-gpu-icx- 79.10% <96.99%> (+0.08%) ⬆️
pytest-gpu-nvc-nvidiaX 69.15% <63.04%> (+0.01%) ⬆️

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.

Comment thread devito/tools/dtypes_lowering.py Outdated
if dtype is not None:
return dtype

dtypes = {extract_dtype(i) for i in expr.args} - {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.

This pattern pops up in a few places I think? Make a helper function if so?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good catch added utility function

Comment thread tests/test_derivatives.py Outdated
@pytest.mark.parametrize('width', [1, 2])
@pytest.mark.parametrize('reuse', [False, True])
@pytest.mark.parametrize('initial', [0, 1])
def test_index_derivative_vector(self, width, reuse, initial, 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.

Do we need to use monkeypatching in this file? Perhaps we want to update the coding style skills, since agents love using monkeypatch so far as I can tell...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

@FabioLuporini
FabioLuporini merged commit 33633a0 into main Oct 28, 2026
42 checks passed
@FabioLuporini
FabioLuporini deleted the next-gen branch October 28, 2026 08:28
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