Skip to content

Shim new streaming backend#212

Open
nclack wants to merge 113 commits into
acquire-project:mainfrom
nclack:shim
Open

Shim new streaming backend#212
nclack wants to merge 113 commits into
acquire-project:mainfrom
nclack:shim

Conversation

@nclack
Copy link
Copy Markdown
Member

@nclack nclack commented Mar 31, 2026

chucky is a new streaming backend for acquire.

It adds support for gpu acceleration and there are some improvements to cpu-based streaming as well.

Getting it in is going to take a few steps.

I'm starting with this PR by creating a "shim". The shim is a thin layer implementing the public c api of acquire using chucky. I will use that to gradually walk through acquire-zarr's tests, changing chucky as necessary.

This should allow us to make some standalone libraries/wheels we can test for a bit and identify when to switch the back-ends more permanently.

@nclack
Copy link
Copy Markdown
Member Author

nclack commented Apr 6, 2026

Added almost all functionality. I'm trying very hard to maintain existing acquire-zarr behavior. One thing that will have to change is some of the downsampling behavior.

acquire-zarr treats x and y in a special way, where chucky does not. This impacts some rules determining when to stop downsampling certain dimensions as we get to higher (coarser) levels of detail (lod).

If the user doesn't want to allow the aspect of ratios of dimensions to change, then we must stop downsampling as soon as any dimension becomes too small; "Too small" means it's one chuck or fewer in that dimension.

If aspect ratios can change, then we just stop downsampling dimensions that are too small and continue with the others until there are no dimensions left - everything fits in one chunk.

This is almost what acquire-zarr does. The aspect ratio of x and y are held fixed, but the others can change. Chunk sizes also vary.

In chucky, variable chunk size causes all kinds of headaches - so I'll constrain to a constant chunk size. I'll add an option letting a user select whether they want a variable aspect ratio or not. I've already got a max lod parameter. The lod's will be computed until any/all dimensions are 1 or fewer chunks wide or the max lod is hit.

@nclack nclack marked this pull request as draft April 21, 2026 03:35
@nclack nclack marked this pull request as ready for review May 10, 2026 00:40
Copy link
Copy Markdown
Member

@aliddell aliddell left a comment

Choose a reason for hiding this comment

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

Couple of things need looking at.

Comment thread .github/workflows/test.yml
assert np.array_equal(array, data)


@pytest.mark.timeout(300)
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.

Still needed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

not when things are working :D I vote for keeping it.

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.

lol fair enough

Comment thread python/tests/test_stream.py
Comment thread .gitmodules Outdated
Comment thread .gitignore
.idea
.vscode
.vs
.claude
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.

.claude is already on line 87

Comment thread shim/shim_log.c Outdated
Comment thread shim/README.md
Comment thread shim/plan.md
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.

This is going to get out of date very quickly (if it isn't already) and it probably won't be relevant after merge. Consider deleting this file and moving the contents to the PR description instead.

Comment thread shim/shim.c
const char* metadata_key,
const char* metadata)
{
if (!stream || !metadata_key || !metadata) {
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.

Rejecting NULL-valued metadata_key is a behavior change. It should be accepted if and only if we have just the one array.

Comment thread shim/shim_settings.c
const ZarrArraySettings* as = &settings->arrays[index];
if (!as->output_key) {
*key = NULL;
return ZarrStatusCode_Success;
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.

Seems wrong to return Success with a NULL-valued *key.

On closer inspection, the original code dedupes and regularizes the keys, so the behavior is changed here.

nclack and others added 3 commits May 14, 2026 15:53
Co-authored-by: Alan Liddell <[email protected]>
Co-authored-by: Alan Liddell <[email protected]>
Co-authored-by: Alan Liddell <[email protected]>
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.

2 participants