←
Asterisk Labs

karu

Stateless byte-range transport

karu02 / 12

Karu is one layer of the Asterisk stack for AI

training datasets files codecs bytes PyTorch, JAX, TensorFlow your model, fed tensors through DLPack on a CPU or a GPU TACO AI-ready datasets, one sample per example cozip a ZIP you open like a table Rumi tensors read by window, band and time GeoZL Earth observation codecs, on OpenZL Karu batched byte-range reads from files, HTTP, S3, GCS, Azure, Hugging Face and Source Cooperative holds
karu03 / 12

Remote reads are bound by round trips, not bytes

An example with four separate ranges. Karu keeps up to 64 remote transfers in flight by default.

karu04 / 12

Give Karu every range you know

// six tiles of one remote scenestd::array<karu::Read, 6> reads;for (int i = 0; i < 6; ++i)    reads[i] = {.object = &scene, .offset = off[i],        .destination = tile[i], .tag = &tile[i]}; auto batch = client.submit(reads).value(); for (;;) {    auto ev = batch.next().value();    if (ev.state == karu::BatchState::end) break;    // each event: tag, status, bytes_read}
submit time next() now tile[0] tile[1] tile[2] tile[3] tile[4] tile[5] 3 5 0 1 4 2

Describe every read up front, each with a tag of your own.

submit queues all six and returns at once, without waiting for any bytes.

next() hands back each read as it finishes, with its tag and its own status.

karu05 / 12

Which ranges merge

Gap 1 MiB

KARU_COALESCE_GAP

The next read joins the request when the hole before it is at most 1 MiB.

Ratio 16×

KARU_COALESCE_AMPLIFICATION

The next read joins only if the request then fetches at most 16 times the bytes asked.

You only pass each read's offset and size. Karu measures the holes and ratios itself, with its defaults.

karu06 / 12

How big one request gets

Span 64 MiB

KARU_COALESCE_LIMIT

A request covers at most 64 MiB, from its first byte to its last.

Parts 1024

KARU_COALESCE_PARTS

A request carries at most 1024 reads, even when they touch.

Holes not to scale. Local files merge only ranges that touch, and a gap of 0 turns merging off.

karu07 / 12

One contract, seven backends

point at a backend

one readoffset 1048576length 65536
karu08 / 12

What a streaming DataLoader needs

forks its workers

one process per worker, so no shared threads

a new engine in each worker

pid checked on every call

shuffles across files

a batch takes windows from many objects

one submit spans every object

nearby ranges merged per object

decodes on the CPU

while the GPU trains on the last batch

each window as soon as it lands

batch.next()

fills preallocated buffers

one per batch tensor, reused every step

bytes land in your buffer

no extra copy for remote ranges

runs for days

millions of requests, tokens that expire

retries, resumes, refreshes tokens

KARU_MAX_ATTEMPTS 8

reads a live dataset

files can be rewritten mid-epoch

a replaced file fails with 412

Read::if_match

Streaming means training reads its samples straight from object storage, with no local copy of the dataset.

karu09 / 12

Why not object_store?

Karu C++23, used by Rumi, TACO and cozip object_store Rust, Apache Arrow after fork() in a DataLoader worker main fork worker builds a new engine, threads and connections main fork worker a tokio runtime started before fork() has no threads results four reads in flight each read is yours the moment it lands get_ranges returns them all when the last ends objects a DataLoader batch a.rumib.rumic.rumisubmit one batch takes reads from every object a.rumib.rumic.rumiget_rangesget_rangesget_ranges one get_ranges per object, you gather them

Both merge nearby ranges, but get_ranges takes no If-Match: pinning a version means one get_opts per range.

karu10 / 12

Four I/O threads keep 64 transfers in flight

your threads engine one per client, rebuilt after fork() storage caller 1 caller 2 caller 3 any number submit next queue KARU_IO_THREADS 4, in parallel waiting bytes time → I/O thread 1 libcurl multi 16 in flight I/O thread 2 I/O thread 3 I/O thread 4 KARU_CONCURRENCY 64, 16 per thread warm connections, TLS shared shared by every batch credentials 4 workers cached, refreshed lazily DNS answers off the I/O threads kept 60 s, rotated CA certificates hashed directory first else a cached bundle object storage S3, GCS, Azure, HTTP, Hugging Face, Source Cooperative Batch::stats() example batch 1 batch 2 transfers 256 256 retries 0 0 throttled 0 0 new_connections 64 0

A thread waits on its 16 transfers at once and takes the next one the moment a slot frees. Reuse one client.

karu11 / 12

Karu can also download large objects

new in 0.5.0
client.download(object, "scene.rumi")
Objectremote, one version Memoryparallelism 8 Temporary filebeside the destination Destinationscene.rumi first 1 MiB chunk_size 8 MiB ETag "5d41402a" replaced, ETag "7e2b19c0" 412, ETag changed scene.rumi.karu.part.<pid>.<n> deleted not visible yet scene.rumi nothing published atomic publish 200 MiB example size 1 MiB probe buffer 64 MiB at most, 8 × 8 MiB 1 MiB progress callback or progress returns 0 200 MiB in one step

One read of up to 1 MiB returns the first bytes, the size and the ETag. Each range asks for that ETag with If-Match and is written at its offset when it lands. The destination appears only after every range has landed, and an existing file is not replaced by default. A changed ETag or a cancel deletes the temporary file, so no partial destination ever appears.

Asterisk Labs

Thank you