Skip to content

Remove various Core.Boxes being captured by closures in tests - #5965

Merged
giordano merged 6 commits into
mainfrom
mg/debox-couette
Sep 12, 2026
Merged

giordano merged 6 commits into
mainfrom
mg/debox-couette

Conversation

@giordano

@giordano giordano commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

I mentioned multiple times that reusing same label is problematic, now it's biting us 🙂
Taken out of #5799.

The stratified Couette flow validation script sets initial conditions via closures that reached into model.grid for the domain extents, and a nested print_progress function reassigned model, which turned the captured variable into a Core.Box. On KernelAbstractions 0.10 the CPU backend compiles kernels like GPU backends do, so these closures were rejected as non-bitstype kernel arguments:

KernelError: passing non-bitstype argument
  .ε is of type var"#ε#20" which is not isbits.
    .model is of type Core.Box which is not isbits.

Capture Lx and Lz as plain numbers instead, and stop reassigning model inside print_progress, so the closures only hold numbers and compile on every backend.

The stratified Couette flow validation script sets initial conditions
via closures that reached into `model.grid` for the domain extents, and
a nested `print_progress` function reassigned `model`, which turned the
captured variable into a `Core.Box`. On KernelAbstractions 0.10 the CPU
backend compiles kernels like GPU backends do, so these closures were
rejected as non-bitstype kernel arguments:

    KernelError: passing non-bitstype argument
      .ε is of type var"#ε#20" which is not isbits.
        .model is of type Core.Box which is not isbits.

Capture `Lx` and `Lz` as plain numbers instead, and stop reassigning
`model` inside `print_progress`, so the closures only hold numbers and
compile on every backend.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VHciC8x39gm97sABrSvBkt
@simone-silvestri

Copy link
Copy Markdown
Collaborator

I think all the validation scripts need to be refreshed, most of them are outdated

@giordano

giordano commented Sep 10, 2026 •

Copy link
Copy Markdown
Member Author

This is sufficient to make the scripts tests pass in #5799, so that's at least concrete improvement

giordano and others added 3 commits September 11, 2026 08:48
`z_immersed_boundary` had two methods, the second calling the first by
name. A local function that refers to its own name captures itself
through a `Core.Box`, so the closure is not isbits and cannot be a
kernel argument. `set!(field, func)` evaluates the function on the CPU,
which with KernelAbstractions 0.10 is a compiled backend with the same
isbits requirement as GPUs:

    KernelError: passing non-bitstype argument
      .func is of type var"#z_immersed_boundary#..." which is not isbits.
        .z_immersed_boundary is of type Core.Box which is not isbits.

Only the 3-argument method is called, so define that one alone.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VHciC8x39gm97sABrSvBkt
`bᵢ` captured the whole `grid` to read `grid.Lx`. On the GPU the grid
holds `CuArray`s, so the closure is not isbits and cannot be a kernel
argument. `set!(field, func)` evaluates the function on the CPU, which
with KernelAbstractions 0.10 is a compiled backend with the same isbits
requirement as GPUs:

    KernelError: passing non-bitstype argument
      .func is of type var"#bᵢ#bᵢ##0"{ImmersedBoundaryGrid{...}} which is not isbits.
        .grid is of type ImmersedBoundaryGrid{...} which is not isbits.

Capture the domain length as a number instead.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VHciC8x39gm97sABrSvBkt
@giordano giordano changed the title Keep couette flow initial-condition closures isbits Remove various Core.Boxes being captured by closures in tests Sep 11, 2026
@giordano

Copy link
Copy Markdown
Member Author

I cherry picked a few other changes from #5799 getting rid of Core.Boxes captured by closures in the tests, which resolve errors observed in that branch (they'll be more relevant with KernelAbstractions v0.10 because the CPU backend behaves a lot more like the GPU ones, with their limitations)

@glwagner glwagner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

happy for this!

giordano and others added 2 commits September 11, 2026 18:24
…ction

The immersed boundary function is called with `(x, z)` on grids with a
`Flat` y direction and with `(x, y, z)` otherwise:

    MethodError: no method matching (::var"#z_immersed_boundary#...")(::Float64, ::Float64)

Define both methods with independent bodies; unlike a method calling the
other by name, this keeps the closure isbits.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VHciC8x39gm97sABrSvBkt
@codecov

codecov Bot commented Sep 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.11%. Comparing base (9236b21) to head (7f94c35).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5965      +/-   ##
==========================================
+ Coverage   67.90%   74.11%   +6.20%     
==========================================
  Files         428      428              
  Lines       25517    26573    +1056     
==========================================
+ Hits        17327    19694    +2367     
+ Misses       8190     6879    -1311     
Flag Coverage Δ
buildkite 67.90% <ø> (-0.01%) ⬇️
julia 67.90% <ø> (-0.01%) ⬇️
reactant_1 6.10% <ø> (?)
reactant_2 13.91% <ø> (?)
reactant_3 9.13% <ø> (?)

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.

@giordano
giordano merged commit 7f779a0 into main Sep 12, 2026
78 checks passed
@giordano
giordano deleted the mg/debox-couette branch September 12, 2026 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants