Skip to content

Repository files navigation

shapport

z/OS port of shap — "A unified approach to explain the output of any machine learning model."

Status: blocked on two dependency releases, not yet buildable

This repo holds the patch that makes shap's Python code numba-free on z/OS (patches/shap-zos/), plus a buildenv that drives shap's real scikit-build-core/CMake build. It is not wired into CI yet, because two hard runtime dependencies exist as zopencommunity port repos but have not published a release:

  • scipyscipyport exists and is under active development (32+ commits, currently fixing LAPACK pkg-config linkage) but has not published a release.
  • scikit-learnscikit-learnport exists (one commit, builds against numpy/scipy without OpenMP) but has not published a release either.

The toolchain gap that used to block this — no cmake/ninja on z/OS, so scikit-build-core (shap's build backend) could not drive its C++ build — has since closed:

  • cmakeport and ninjaport both have released binaries on z/OS.
  • In practice ninja isn't even required: scikit-build-core's own ninja.make-fallback setting (on by default) drives CMake's "Unix Makefiles" generator with gmake (makeport) when ninja is absent — the same generator cmakeport itself is bootstrapped with. Confirmed directly: cmake --help on a z/OS build machine reports "Unix Makefiles" as the starred default generator, and gmake (from makeport) is on PATH there.
  • nanobind and scikit-build-core are both pure-Python (py3-none-any) wheels on PyPI — no port needed for either.

So the build system is ready; only the two runtime dependencies remain.

What has been verified

On z/OS 2.5, Python 3.12, with pandas, slicer, tqdm, cloudpickle installed from the zopen wheel index and scipy/scikit-learn stubbed out for import-only testing:

  • shap's two native extensions (_cext, a plain C extension, and _cutils, a nanobind extension) both compile with IBM Open XL C/C++ and import successfully. (Compiled by hand at the time, before cmake was available as a zopen port — see patches/shap-zos/README.md. The buildenv in this repo now drives the same compiler through scikit-build-core/CMake instead.)
  • With patches/shap-zos/shap-remove-numba-zos.patch applied, import shap succeeds end to end, registering all built-in explainers (TreeExplainer, KernelExplainer, PartitionExplainer, ExactExplainer, GPUTreeExplainer, etc.).
  • The de-numba'd functions (shap.links.identity/logit, shap.explainers._partition.lower_credit, shap.utils._masked_model._build_fixed_single_output, mask-building helpers) were smoke-tested against synthetic inputs and produce correct output.

See patches/shap-zos/README.md for full details, exact compiler/linker flags, and links to the upstream numba-removal effort (shap#4327).

What buildenv does

Modeled on scikit-learnport's and pandasport's Python buildenvs:

  • Builds one wheel per interpreter (3.12/3.13/3.14) via python -m build --wheel --no-isolation, so pip never resolves its own copy of scikit-build-core, nanobind, numpy, scipy, or scikit-learn from PyPI behind our back.
  • Installs numpy, scipy, scikit-learn, pandas from the zopen wheel index into the build venv (PyPI has no wheel for this platform for any of them); nanobind/scikit-build-core/slicer/tqdm/cloudpickle straight from PyPI, since all five are pure Python.
  • Leaves the CMake generator to scikit-build-core's own default detection (Unix Makefiles + gmake, no -G/CMAKE_GENERATOR override needed) — see the buildenv's comments for why.
  • zopen_python_test exercises the public API without needing any of the heavy ML frameworks (torch, tensorflow, xgboost, lightgbm, catboost, transformers) that ~45% of shap's own test suite references behind pytest.importorskip: link functions, KernelExplainer and TreeExplainer on scikit-learn models, PartitionExplainer (which exercises the de-numba'd lower_credit), and the nanobind _cutils extension directly.

Next steps

  1. Wait for scipyport and scikit-learnport to each publish a release.
  2. Run zopen-build here for real and fix whatever the dry-run analysis in buildenv got wrong — it has not executed end to end, because it needs scipy/scikit-learn wheels this system cannot yet produce.
  3. Wire up GitHub Actions and Jenkins CI once (1) and (2) are done.

Installation

Not yet available. Once unblocked:

zopen install shap

About

A unified approach to explain the output of any machine learning model

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages