Drop DLPack dependency; reorganize examples as perf benchmarks#67
Merged
Conversation
Replace the DLPack.jl-based numpy→Julia conversion in `numpy2jl` with a vendored zero-copy `PyArray` + `unsafe_wrap`, rooted through a `WeakKeyDict` for lifetime safety. Behavior and performance match DLPack (a genuine `DenseArray`, so BLAS/GPU fast paths are preserved), and as a bonus the GIL-finalizer deadlock is gone: PythonCall's deferred decref means a finalizer firing on a worker thread enqueues the pointer instead of re-acquiring the GIL. Removes the now-unmaintained DLPack dependency. Move the Flux MNIST/CIFAR-10 examples under `perf/` alongside `load_dataset/`, add a 2-worker Distributed row, run the loaders at `-t4`, and refresh both READMEs with fresh 10-epoch benchmark numbers (Threadripper CPU / RTX 5090 GPU). Update all example path references across the docs and READMEs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Summary
Two independent, docs-heavy changes bundled together:
1. Drop the DLPack.jl dependency
numpy2jlno longer routes through DLPack. Instead it wraps the numpy buffer as a genuineArrayvia a vendoredPyArray+unsafe_wrap, rooted through a module-levelWeakKeyDict(weak key = the wrapperArray, strong value = thePyArray) so the Python buffer stays alive exactly as long as the Julia array and is released when it's GC'd.<: DenseArray, so BLAS/GPU/fast-indexing paths are preserved (a barePyArraymisses all of these). Axis reversal and the read-only / non-contiguous copy guards are kept.parallel=trueworker thread enqueues the pointer rather than re-acquiring the GIL — so the thread-finalizer deadlock that DLPack's eager-decref finalizer could cause is gone.DLPackdep fromProject.tomland theusing DLPackimport.2. Reorganize the Flux examples as
perf/benchmarksexamples/flux_mnistandexamples/flux_cifar10underperf/(alongsideperf/load_dataset/) and delete the now-emptyexamples/. All doc/README path references updated.-t4(was-t8), and make the PyTorch scripts readEPOCHSfrom the env.map(copy, …)note in the MNIST README (the code uses[:]) and align the deadlock framing with the deferred-decref behavior.Testing
🤖 Generated with Claude Code