Lightning Core: macOS-first CUDA-style runtime with Metal backend
Project description
Lightning Core
Lightning Core is a macOS-first CUDA-style runtime focused on custom attention training/inference paths.
Why This Project Exists
Deep learning tooling is often CUDA-centric, while many local development environments are macOS + Apple Silicon. This project was created to provide a practical, CUDA-style runtime experience on macOS with a Metal backend, so custom attention and tensor/ops experiments can be built, profiled, and tuned without changing the entire workflow.
In short, Lightning Core targets the gap between:
- familiar CUDA-like execution mental model
- native Metal execution path on macOS
- fast iteration loop with both C++ and Python APIs
Why Lightning Core
| Point | What it gives you |
|---|---|
| Metal-first runtime path | Optimized execution flow on Apple Silicon/macOS |
| Attention fastpath focus | Practical tuning path for custom attention workloads |
| Resident session policy | Reduced upload/download/sync overhead in repeated runs |
| C++ + Python workflow | Native core with pybind11 module for quick iteration |
Core Architecture
flowchart LR
A[Python API: lightning_core] --> B[pybind11 bindings]
C[C++ API: lightning_core/*] --> D[Runtime Core]
B --> D
D --> E[Tensor and Ops]
E --> F[Metal Backend]
E --> G[CPU Fallback]
D --> H[Benchmark and Profile Artifacts]
Performance Checkpoints
| Checkpoint | Command | Artifact |
|---|---|---|
| Attention shape sweep | ./build/benchmarks/bench_attention with sweep env vars |
build/benchmarks/attention_shape_sweep.csv |
| Vector add crossover | ./build/benchmarks/bench_vector_add with sweep mode |
build/benchmarks/vector_add_crossover.csv |
| Matrix ops sweep | ./benchmarks/sweep_matrix_ops.sh |
build/benchmarks/matrix_ops_sweep.csv |
See docs/advanced.md for full benchmark and tuning flow.
Install and Use
Install from PyPI:
python -m pip install -U lightning-core
Install from source:
git clone https://github.com/wnsgus00114-droid/lightning-core.git
cd lightning-core
python -m pip install .
Quick Python usage:
import numpy as np
import lightning_core as lc
print(lc.backend_name())
a = np.arange(8, dtype=np.float32)
b = np.arange(8, dtype=np.float32)
out = lc.vector_add(a, b, "metal")
print(out)
Quick Start (Beginner)
Documentation entrypoint:
- docs/index.md
Use this path first:
- Install and import-check
- Build and run one C API example
- Run tests
python3 -m pip install .
python -c "import lightning_core; print(lightning_core.backend_name())"
cmake -S . -B build -DCJ_ENABLE_METAL=ON -DCJ_BUILD_TESTS=ON -DCJ_BUILD_PYTHON=ON -DCJ_BUILD_EXAMPLES=ON
cmake --build build -j
cmake --build build --target lightning_core_c_api_example -j
./build/lightning_core_c_api_example
ctest --test-dir build --output-on-failure
Detailed beginner guide:
- docs/quickstart.md
Scope (Current)
This project is an optimization-focused runtime prototype, not a full deep learning framework.
- Core focus: runtime, attention path, selected matrix/vector ops
- Model-family wrappers are advanced policy/fastpath helpers, not full model implementations
- API and internals are still actively evolving
Identity and Naming
- Public package/module: lightning-core / lightning_core
- Public C++ include path/namespace: lightning_core/* and lightning_core::...
- Internal canonical headers: include/lightning_core/core/*
- Legacy include/cudajun/* remains as compatibility shim
Advanced Topics
For advanced usage and operations, see:
- docs/advanced.md
For contributor workflow and coding conventions, see:
- docs/contributor.md
Includes:
- benchmark sweeps and generated artifacts
- resident session and policy tuning
- model-family wrapper examples and caveats
- runtime profile/env tuning
- release and publishing workflow notes
- repository rename transition operations
Build Targets
Useful targets:
- library: lightning_core::lightning_core
- python module: lightning_core
- c api example: lightning_core_c_api_example
Repository
Current GitHub repository URL:
If you still have an older local clone URL, use:
./scripts/sync_remote_after_repo_rename.sh --dry-run
./scripts/sync_remote_after_repo_rename.sh
The script automatically checks target repository availability and skips safely when rename is not ready.
Project Layout
- include/lightning_core: public wrappers
- include/lightning_core/core: canonical internal headers
- include/cudajun: compatibility shims for legacy integrations
- src: runtime + tensor + ops implementation
- tests: C++ unit tests
- benchmarks: benchmark binaries and sweep scripts
- python: pybind11 bindings
- docs: split docs (index/quickstart/advanced/contributor)
Author
- Junhyeon Baeg (Kwangwoon University)
License
This project is licensed under the Kwangwoon University License 1.0 (KWU-1.0).
See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lightning_core-0.1.3.tar.gz.
File metadata
- Download URL: lightning_core-0.1.3.tar.gz
- Upload date:
- Size: 82.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00a651e0645e45df34cfe184818c472d5330a0b68fc72c82b0e45520b0c87d4e
|
|
| MD5 |
0e8bfe489e76753941c776e8b9a91728
|
|
| BLAKE2b-256 |
db4bafccc3749e1bb66f4898708e4b23676d9c99d1364eb80d802346d434eb90
|
Provenance
The following attestation bundles were made for lightning_core-0.1.3.tar.gz:
Publisher:
python-wheel-publish.yml on wnsgus00114-droid/lightning-core
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lightning_core-0.1.3.tar.gz -
Subject digest:
00a651e0645e45df34cfe184818c472d5330a0b68fc72c82b0e45520b0c87d4e - Sigstore transparency entry: 1191468515
- Sigstore integration time:
-
Permalink:
wnsgus00114-droid/lightning-core@4079eb4facad712602717d37aa49c081997bf260 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/wnsgus00114-droid
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-wheel-publish.yml@4079eb4facad712602717d37aa49c081997bf260 -
Trigger Event:
push
-
Statement type:
File details
Details for the file lightning_core-0.1.3-cp312-cp312-macosx_14_0_arm64.whl.
File metadata
- Download URL: lightning_core-0.1.3-cp312-cp312-macosx_14_0_arm64.whl
- Upload date:
- Size: 199.3 kB
- Tags: CPython 3.12, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
999dea2ebc636de36d9b2c107e5bad7a5bd014d0c8d46e088eae6d48242e9901
|
|
| MD5 |
ac734fd26ae8444531b087cddf4833ea
|
|
| BLAKE2b-256 |
4c20618454ac5738f7ffe068392759d7624653fbaa112325e5ed8e510649f102
|
Provenance
The following attestation bundles were made for lightning_core-0.1.3-cp312-cp312-macosx_14_0_arm64.whl:
Publisher:
python-wheel-publish.yml on wnsgus00114-droid/lightning-core
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lightning_core-0.1.3-cp312-cp312-macosx_14_0_arm64.whl -
Subject digest:
999dea2ebc636de36d9b2c107e5bad7a5bd014d0c8d46e088eae6d48242e9901 - Sigstore transparency entry: 1191468518
- Sigstore integration time:
-
Permalink:
wnsgus00114-droid/lightning-core@4079eb4facad712602717d37aa49c081997bf260 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/wnsgus00114-droid
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-wheel-publish.yml@4079eb4facad712602717d37aa49c081997bf260 -
Trigger Event:
push
-
Statement type: