[QUESTION] Support for ortools 9.4 solvers natively on MacOS with Silicon?
See original GitHub issueNOTE: This issue sounds similar to https://github.com/guillermo-navas-palencia/optbinning/issues/185 and I’ve opened https://github.com/google/or-tools/issues/3485 to get advice from that angle. It’s unclear to me if this is a bug, an incompatibility that should be addressed/documented, or simply a usage mistake.
Problem Description
My goal is to use optbinning
with the latest ortools
(9.4.1874
) on a MacOS Monterey machine with Apple Silicon and an arm64
python platform.machine()
architecture (no Rosetta2). I’m currently trying to use optbinning==0.15.0
.
I am using ContinuousOptimalBinning.fit()
, but when it eventually runs the optimizer.solve()
method, the code seems to silently fail shortly thereafter.
NOTE: Here is a minimal reproduction notebook file and titanic dataset. optimalBinnerRepro.zip
Minimal Reproduction Example
# %%
import pandas as pd
from optbinning import OptimalBinning, ContinuousOptimalBinning
# %%
df = pd.read_csv('./titanic.csv')
df.shape
# %%
missing_cols = df.columns[[df[col].isna().any() for col in df]].tolist()
missing_cols
# %%
dropped_idx = df['Age'][df['Age'].isnull()].index.tolist()
df = df.drop(dropped_idx, axis=0)
df.shape
# %%
# Initialize binner
continuousBinner = ContinuousOptimalBinning(max_n_bins=20, min_bin_size=0.05, split_digits=2)
# %%
# Continuous
y = df['Fare'].values
X = df['Age']
# The following line will result in a process crash.
age_binned_multiclass = continuousBinner.fit(X, y)
continuousBinner.splits
Once inside of ortools
code, execution seems to stop here:
https://github.com/google/or-tools/blob/82750ac12f1ee5354e1c7869894d9af3508778f2/ortools/sat/python/cp_model.py#L2190
My debugger is unable to catch any traceback or error from this series of invocations, so I don’t really know what’s going wrong. The trail goes cold here after invoking this method:
I suspected an architecture incompatibility issue, but this version of ortools
has a pre-built wheel for arm64, so I was inclined to trust it.
- Does
optbinning
work withortools==9.4.1874
on macos arm64? Is there any version combination where this would work? - Are there solver incompatibilities at play here?
- Any advice on how to better debug this situation?
Issue Analytics
- State:
- Created a year ago
- Reactions:10
- Comments:9 (4 by maintainers)
Top GitHub Comments
UPDATE: It works after clearing my venv and pip cache and installing only the packages necessary for the minimal repro I provided.
The minimal repro example also helped surface an exception from the crashing thread. When run with my original dependency lockfile from a standard python interpreter (not a jupyter notebook), I see this line get printed:
output of `pip freeze` in working example
output of `pip freeze` in broken example
I was able to further reduce the package version differences between those two examples so the issue doesn’t seem to be related to the versions of any of the dependencies. That leaves the possibility that the issue is related to the presence of one of the many “extra” packages in my original lockfile which are absent in the working minimal repro requirements. One other difference is that I currently have a work-around in place to allow
pyodbc
to be built form source on macos arm64.I’m going to try to continue eliminating variables to see where that gets me.
Thank you so much for your response, @guillermo-navas-palencia! I really appreciate the help investigating this.
I can confirm that
solver="mip"
did not result in a process crash.That’s really great to hear!
That makes it sound like this is more likely related to a problem on my end… I guess the first thing I’ll try is to clear my pip cache and start a fresh virtual environment and try again, focusing on my minimal repro example.