Repository navigation
Move FEEC assembly kernels into kernel folders - #725
Draft
max-models wants to merge 6 commits into
Draft
max-models wants to merge 6 commits into
max-models wants to merge 6 commits into
Conversation
The 16 entry kernels of feec/mass_kernels.py and feec/basis_projection_kernels.py (used by WeightedMassOperator, StencilMatrixFreeMassOperator, L2Projector, BoundaryMassOperator and BasisProjectionOperator) move into one folder each under feec/kernels/<name>/ with <name>_kernels.py and an __init__.py declaring the cunumpy Kernel. Call sites import the kernels instead of wrapping PyccelKernel(getattr(module, name)). The function bodies are unchanged. The kernels have no CUDA version yet and are declared with missing_cuda="fallback", which keeps the former PyccelKernel behaviour on the CuPy backend. Solves #411. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lders Stack the PR on #724. Conflicts in CUDA_STRATEGY.md: checklist entries in PR order, kept the notes of every PR; the kernel-folder row counts the 16 FEEC assembly folders, 4 spline evaluation folders and the 18 kernels with a CUDA version. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lders Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lders Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
max-models
added a commit
that referenced
this pull request
Oct 7, 2026
Stack the PR on #725. Conflicts: feec/mass.py, boundary_mass.py, basis_projection_ops.py (took #725's kernel folders; their outputs moved into the folders), test_cuda_emulation.py (#723's argument_arrays check on top of the tests added below), CUDA_STRATEGY.md (kept both notes). Semantic fixes for the PRs below: - OUTPUTS for the 16 FEEC assembly folders of #725 (same arguments as the former PyccelKernel(outputs=...) wraps, plus kernel_*d_vec and surface_kernel_3d_vec) and for eval_spline_mpi_tensor_product_fixed (#724). - OUTPUTS of eval_spline_mpi_markers/matrix/sparse_meshgrid point at values in the SplineArguments signatures of #721 (3, 5, 5). - argument_arrays (cuda_parity_cases.py) knows CudaSplineArguments (#721). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
max-models
added a commit
that referenced
this pull request
Oct 7, 2026
Pulls in the two follow-up fixes of #724 (already resolved identically in the previous merge). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 8, 2026
Draft
max-models
added this pull request to stack #728
October 8, 2026 05:45
max-models
removed this pull request from stack #728
October 8, 2026 06:00
max-models
added this pull request to stack #729
October 8, 2026 06:00
max-models
marked this pull request as draft
October 8, 2026 09:13
7 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack: part 12 of 14, based on #724 (merge that first), next: #723. Full order: #709 → #708 → #711 → #712 → #705 → #713 → #714 → #718 → #720 → #721 → #724 → #725 → #723 → #722.
Solves the following issue(s):
Solves #411, tracked in #650. The FEEC assembly kernels are the last entry kernels that were still called as
PyccelKernel(getattr(module, name))from shared modules. They now follow the folder rule ofCUDA_STRATEGY.md, like the pusher, accumulation and geometry kernels. This is a pure restructuring: no numerical change.Core changes:
feec/mass_kernels.pyandfeec/basis_projection_kernels.pyeach move intofeec/kernels/<name>/, which holds<name>_kernels.pyand an__init__.pydeclaring<name> = Kernel.from_folder(__name__, structs=CUDA_STRUCTS, missing_cuda="fallback"). There is no.cufile, because none of these kernels has a CUDA port yet. Both old modules are removed.mass_kernels.py:kernel_{1,2,3}d_mat,kernel_{1,2,3}d_vec,kernel_{1,2,3}d_eval,kernel_3d_matrixfree,kernel_3d_diag,surface_kernel_3d_mat,surface_kernel_3d_vecbasis_projection_kernels.py:assemble_dofs_for_weighted_basisfuns_{1,2,3}ddevel. Each file imports only what it uses (numpy as npand/orshape).feec/mass.py,feec/boundary_mass.pyandfeec/basis_projection_ops.pyimport the kernels. For kernels that depend on the dimension, they pick the right one from a small module-level dict (_MAT_KERNELS[ldim],_EVAL_KERNELS,_MATRIXFREE_KERNELS,_DIAG_KERNELS,_ASSEMBLY_KERNELS) instead ofgetattron a module. The direct pyccel calls ofmass_kernels.kernel_3d_vecinL2Projectoralso go through theKernelnow.missing_cuda="fallback": on the CuPy backend these kernels keep the behaviour of the formerPyccelKernelcalls: they run on host copies of the arrays, with a warning the first time. With the default ("raise"), FEEC setups that currently assemble mass matrices on CuPy would start to fail. When a kernel is ported, its port removes the fallback for that kernel.collect_kernel_files()picks up the new files with no change, since their names containkernels. It now lists 142 files, 17 of them underfeec/kernels.test_catalog_signaturesexpects 17 kernels infeec.kernels(was 1).feec.kernelswas already intest_cuda_parity.PACKAGES, so the new folders get the signature check and the folder-declaration check.Model-specific changes:
None.
Documentation changes:
feec/kernels/__init__.py: the docstring lists the assembly kernels and the fallback.CUDA_STRATEGY.md:<name>_cuda.cuand parity cases, then drop the fallback)Testing (macOS, no GPU; pyccel kernels compiled in the worktree with GNU/Fortran; GPU tests not run; following the agreed scope, I ran only a few directly relevant tests, and CI covers the rest):
feec/tests/test_mass_reassembly.py: 2 passedfeec/tests/test_basis_ops.py::test_some_basis_opsand::test_transposed_update_weights_drops_zero_blocks: passedfeec/tests/test_boundary_integrals.py -k "unit_cube_constant or hcurl_per_face": 12 passedfeec/tests/test_utilities_kernels.py,pic/tests/test_kernel_backends.py::test_catalog_signatures,pic/tests/test_cuda_parity.py::test_folders_declare_their_kernels: passedM0–M3dotagree with the assembled operators to about 1e-15 relative (kernel_3d_matrixfreeagainstkernel_3d_mat).diagonal()agree exactly (kernel_3d_diag).L2Projector.get_dofs(kernel_3d_vec) andeval_quad(kernel_3d_eval) run.Not run locally: the full test suites,
test_mass_matrices.py(32³ and 48³ grids, slow) and MPI runs. No MPI code changed.🤖 Generated with Claude Code