Skip to main content
Panther Logo

Panther: Faster & Cheaper Computations with RandNLA

Why Panther?

Panther makes it incredibly easy to accelerate your existing PyTorch models with minimal code changes. Simply replace standard layers with Panther's sketched equivalents to get significant speedups and memory reductions.

🚀 Quick Example: Drop-in Replacement

Standard PyTorch With Panther (2-3x faster)
import torch.nn as nn

class StandardModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.fc1 = nn.Linear(8192, 8192)
import torch.nn as nn
import panther as pr

class PantherModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.fc1 = pr.nn.SKLinear(8192, 8192, 
            num_terms=1, low_rank=16)

Result: 2-3x speedup with minimal code changes on the example hyperparameters above.

🤖 Automatic Optimization with AutoTuner

For complex models like BERT, Panther can automatically find optimal configurations:

from transformers import BertForMaskedLM
from panther.tuner import SKAutoTuner, LayerConfig, TuningConfigs

# Load pre-trained BERT
model = BertForMaskedLM.from_pretrained("bert-base-uncased")

# Configure automatic layer discovery and tuning
config = LayerConfig(
    layer_names={"type": "Linear"},
    params="auto",  # Automatic search space
    separate=True,  # Optimize each layer independently
    copy_weights=True  # Preserve trained weights
)

# Create tuner with a quality metric constraint
tuner = SKAutoTuner(
    model=model,
    configs=TuningConfigs([config]),
    accuracy_eval_func=eval_quality,
    accuracy_threshold=thresh,  # Based on eval_quality
    optmization_eval_func=speed_eval_func,
    search_algorithm=OptunaSearch(n_trials=10)
)

# Search and apply optimal configuration
tuner.tune()
optimized_model = tuner.apply_best_params()

Result: Up to 75% memory reduction while maintaining model quality.

📊 Try It Yourself


Table of Contents


Installation

Panther ships pre-built wheels for Linux x86_64, Windows x64, and macOS Apple Silicon (arm64) targeting Python 3.12. CPU and CUDA variants are available.

Step 1 — Install PyTorch

Install PyTorch before panther-ml. Choose the variant that matches your hardware:

# CPU only (all platforms)
pip install torch==2.6.0 torchvision==0.21.0 --extra-index-url https://download.pytorch.org/whl/cpu

# CUDA 11.8 (Linux / Windows)
pip install torch==2.6.0+cu118 torchvision==0.21.0+cu118 --extra-index-url https://download.pytorch.org/whl/cu118

# CUDA 12.4 (Linux / Windows)
pip install torch==2.6.0+cu124 torchvision==0.21.0+cu124 --extra-index-url https://download.pytorch.org/whl/cu124

Step 2 — Install panther-ml

CPU wheel (PyPI — Linux, Windows, macOS):

pip install panther-ml

CUDA wheels are attached to each GitHub Release as direct-download assets. Install the wheel that matches your platform and CUDA version:

# Example: Linux x86_64, CUDA 12.4
pip install https://github.com/FahdSeddik/panther/releases/download/v0.1.3/panther_ml-0.1.3+cu124-cp312-cp312-manylinux_2_28_x86_64.whl

# Example: Linux x86_64, CUDA 11.8
pip install https://github.com/FahdSeddik/panther/releases/download/v0.1.3/panther_ml-0.1.3+cu118-cp312-cp312-manylinux_2_28_x86_64.whl

# Example: Windows x64, CUDA 12.4
pip install https://github.com/FahdSeddik/panther/releases/download/v0.1.3/panther_ml-0.1.3+cu124-cp312-cp312-win_amd64.whl

# Example: macOS Apple Silicon (arm64), CPU
pip install https://github.com/FahdSeddik/panther/releases/download/v0.1.3/panther_ml-0.1.3+cpu-cp312-cp312-macosx_12_0_arm64.whl

Platform matrix

Platform CPU CUDA 11.8 CUDA 12.4
Linux x86_64 ✅ PyPI ✅ Release ✅ Release
Windows x64 ✅ PyPI — ✅ Release
macOS arm64 ✅ PyPI — —

Using Docker

A pre-built Docker image with all dependencies is available for GPU systems:

docker pull fahdseddik/panther-dev

Building from Source (Contributors)

Use this path if you are contributing to panther-ml or need to modify the native backend.

Prerequisites

  • Python 3.12+
  • Poetry (pip install poetry)
  • C++ compiler (GCC on Linux, MSVC on Windows, Clang on macOS)
  • CUDA Toolkit (optional — CPU-only build works without it)

Linux

# System libraries
sudo apt-get update && sudo apt-get install -y libopenblas-dev liblapacke-dev

# Clone and install Python deps
git clone https://github.com/FahdSeddik/panther.git && cd panther
poetry install

# Build the native extension in-place
cd pawX && python setup.py build_ext --inplace && cd ..

# Install the panther package in editable mode
pip install -e .

Windows

# Clone and install Python deps
git clone https://github.com/FahdSeddik/panther.git; cd panther
poetry install

# Build the native extension in-place (bundled OpenBLAS is used automatically)
cd pawX; python setup.py build_ext --inplace; cd ..

pip install -e .

macOS

# Homebrew OpenBLAS
brew install openblas

# Clone and install Python deps
git clone https://github.com/FahdSeddik/panther.git && cd panther
poetry install

# Build the native extension in-place
cd pawX && python setup.py build_ext --inplace && cd ..

pip install -e .

After building, verify the extension loaded correctly:

python -c "import torch; import pawX; t = pawX.scaled_sign_sketch(4, 4); print('OK:', t.shape)"

Running Panther

To use panther in your python code, simply import the package:

import torch
import panther as pr
# Example usage
A = torch.randn(1000, 1000)
Q, R, J = pr.linalg.cqrrpt(A)
print(Q.shape, R.shape, J.shape)

Running Tests

Ensure your native backend is built, panther package is installed, and your Python environment is active. Then run:

pytest tests/
# or with poetry:
poetry run pytest tests/

This will execute unit tests and any Jupyter-based benchmarks.


Generating Documentation (Optional)

Panther uses Sphinx for API docs located in docs/. To rebuild HTML docs:

cd docs
# On Windows:
.\make.bat clean
.\make.bat html
# On Linux/macOS:
make clean
make html

Open docs/_build/html/index.html in your browser.


Project Structure

panther/          # Python package
├── linalg/       # Core linear algebra routines
├── nn/           # Neural network layers
├── sketch/       # Sketching algorithms
├── utils/        # AutoTuner & Helper functions
pawX/             # Native C++/CUDA backend
├── setup.py      # Extension build script
scripts/          # Release utilities (wheel renaming)
tests/            # Unit tests, notebooks & benchmarks
docs/             # Sphinx documentation sources
.github/workflows/build-wheels.yml  # CI: multi-platform wheel build & publish

Pre-commit Hooks (Optional)

To enforce code style and formatting, install pre-commit hooks:

poetry run pre-commit install

Acknowledgments

Panther's implementation of sparse sketching operators and the CQRRPT algorithm are derived from the RandBLAS and RandLAPACK libraries, respectively. We gratefully acknowledge the RandBLAS and RandLAPACK teams for their foundational work in randomized numerical linear algebra. These libraries are distributed under the BSD-3-Clause license, and portions of our pawX/ backend retain their copyright notices as required.

📜 Citation

If you use this code, please cite our paper:

@misc{seddik2026pantherfastercheapercomputations,
      title={Panther: Faster and Cheaper Computations with Randomized Numerical Linear Algebra}, 
      author={Fahd Seddik and Abdulrahman Elbedewy and Gaser Sami and Mohamed Abdelmoniem and Yahia Zakaria},
      year={2026},
      eprint={2601.15473},
      archivePrefix={arXiv},
      primaryClass={cs.LG},
      url={https://arxiv.org/abs/2601.15473}, 
}

For more details, browse the source code and in-line documentation in each module.

Metadata

Release files for panther-ml 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for panther-ml 0.1.3
File Interpreter ABI Platform Actions
panther_ml-0.1.3-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for panther_ml-0.1.3-cp312-cp312-win_amd64.whl
panther_ml-0.1.3-cp312-cp312-manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64 Details for panther_ml-0.1.3-cp312-cp312-manylinux_2_28_x86_64.whl
panther_ml-0.1.3-cp312-cp312-macosx_12_0_arm64.whl CPython 3.12 CPython 3.12 macOS 12.0+ ARM64 Details for panther_ml-0.1.3-cp312-cp312-macosx_12_0_arm64.whl

Total release size: 138.4 MB

Release files / panther_ml-0.1.3-cp312-cp312-win_amd64.whl

Download URL panther_ml-0.1.3-cp312-cp312-win_amd64.whl
Size 40.8 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
d2f51b79f92c773da397c305db980ee9ce07fe3ed552f1a17139f65eae852762
BLAKE2b-256 checksum
How to use checksums
53ff81567c5effeb2724d418f87d0a57f1ebd2793c4e4ed5c2e74b52ae796543
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / panther_ml-0.1.3-cp312-cp312-manylinux_2_28_x86_64.whl

Download URL panther_ml-0.1.3-cp312-cp312-manylinux_2_28_x86_64.whl
Size 56.4 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
2be67a9ae7989e93b22fcfc54b332c6d1be03ee0750874837945ab894c715797
BLAKE2b-256 checksum
How to use checksums
6cf813480d1d049a39b6bb0ee4dc5fe3737bc0c0edb8c7130aa01bae55a7a562
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / panther_ml-0.1.3-cp312-cp312-macosx_12_0_arm64.whl

Download URL panther_ml-0.1.3-cp312-cp312-macosx_12_0_arm64.whl
Size 41.2 MB
Tags CPython 3.12 macOS 12.0+ ARM64
SHA-256 checksum
How to use checksums
aa10ae1cfb58235f51d2603b6310dfcd84b1c7a74ae05faa4b7638e6617bbfa9
BLAKE2b-256 checksum
How to use checksums
644b3d7005641abd9a8c0ebc6d85313a3dccdf76d19d240779a04ec825181d81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Security for panther-ml 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.3 This release

3 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page