Skip to main content

Lightning Core: macOS-first CUDA-style runtime with Metal backend

Project description

Lightning Core

PyPI version PyPI downloads

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:

  1. Install and import-check
  2. Build and run one C API example
  3. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lightning_core-0.1.3.tar.gz (82.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lightning_core-0.1.3-cp312-cp312-macosx_14_0_arm64.whl (199.3 kB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

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

Hashes for lightning_core-0.1.3.tar.gz
Algorithm Hash digest
SHA256 00a651e0645e45df34cfe184818c472d5330a0b68fc72c82b0e45520b0c87d4e
MD5 0e8bfe489e76753941c776e8b9a91728
BLAKE2b-256 db4bafccc3749e1bb66f4898708e4b23676d9c99d1364eb80d802346d434eb90

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lightning_core-0.1.3-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for lightning_core-0.1.3-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 999dea2ebc636de36d9b2c107e5bad7a5bd014d0c8d46e088eae6d48242e9901
MD5 ac734fd26ae8444531b087cddf4833ea
BLAKE2b-256 4c20618454ac5738f7ffe068392759d7624653fbaa112325e5ed8e510649f102

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page