Metadata-Version: 2.4
Name: qxgb
Version: 0.1.0
Summary: QXGBoost: Quantized XGBoost for FPGA deployment
Author-email: Chang Sun <chsun@cern.ch>
License: GNU Lesser General Public License v3 (LGPLv3)
Project-URL: repository, https://github.com/calad0i/qxgb
Keywords: gradient boosting,machine learning,quantization,xgboost
Classifier: Development Status :: 5 - Production/Stable
Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: alkaid
Requires-Dist: xgboost>=3
Provides-Extra: docs
Requires-Dist: myst-parser; extra == "docs"
Requires-Dist: pyparsing; extra == "docs"
Requires-Dist: sphinx; extra == "docs"
Requires-Dist: sphinx-rtd-theme; extra == "docs"
Dynamic: license-file

# qxgb

QXGBoost: quantized XGBoost Classifier for FPGA Deployment.

`qxgb` provides `QXGBClassifier` inheriting from `xgboost.XGBClassifier` with quantization aware training and registers the Alkaid tracer plugin for converting trained `(Q)XGBoost` boosters into RTL designs with [`Alkaid`](https://github.com/calad0i/alkaid).

## Installation

```bash
pip install qxgb
```

## Quick Start

```python
from qxgb import QXGBClassifier

model = QXGBClassifier(
    scale=4,
    bias=2,
    n_estimators=32,
    max_depth=3,
)

model.fit(X_train, y_train)
y_pred = model.predict(X_test)

hw_bst = model.ibooster() # Integer booster

from alkaid.converter import trace_model
from alkaid.trace import FVArray, trace

inp = FVArray.new(16).quantize(0, 8, 0).as_new()
_, out = trace_model(hw_bst, inputs=inp, mode='mux')
comb = trace(inp, out)

hw_pred = comb.predict(X_test) # == y_pred
```

## Examples

Notebook examples are in [`examples/`](examples/):

- `jsc.ipynb`
- `mnist.ipynb`
- `nid.ipynb`

## License

LGPLv3. See [`LICENSE`](LICENSE).
