Skip to content

[DRAFT] Use object files in ROCm pipeline#12

Open
mrowan137 wants to merge 2 commits intoCEMeNT-PSAAP:mainfrom
mrowan137:rocm-compile-to-objects
Open

[DRAFT] Use object files in ROCm pipeline#12
mrowan137 wants to merge 2 commits intoCEMeNT-PSAAP:mainfrom
mrowan137:rocm-compile-to-objects

Conversation

@mrowan137
Copy link

This PR modifies the ROCm compilation pipeline for harmonize.so to link using object instead of bitcode files.
The change is aimed at addressing a linker error (described here: #7).

@mrowan137 mrowan137 changed the title Use object files in ROCm pipeline [DRAFT] Use object files in ROCm pipeline Feb 21, 2026
@mrowan137 mrowan137 force-pushed the rocm-compile-to-objects branch from d5f1eae to 2d70485 Compare February 21, 2026 02:29
@jpmorgan98
Copy link
Member

Hey @mrowan137 I finally had some time to test this out and am getting this linker error on Tuo. My build script dfor a python env is attached and I also have a pip and module list below. Let me know your thoughts. Thanks!

build_rocm.sh

(venv-tuo) [morgan83@tuolumne2151:slab_absorbium]$ HSA_XNACK=1 ROCR_VISIBLE_DEVICES=0 python input.py --mode=numba --target=gpu
error: Linking globals named '_ZN4mcdc6kernel12wrapping_addB3v16B103_8_2fAMcMtJTC_2fWQFJmm55WYWlipKOA5CVbcGjpKCBpt61WB7LUrRSMdRTUYZ4FckHG1gKDFy2mbUGpDiIMSVRIAqgJBSyhCQA_3dEyy': symbol multiply defined!
Traceback (most
 recent call last):
  File "/usr/WS1/morgan83/tuo_dep/MCDC/examples/fixed_source/slab_absorbium/input.py", line 48, in <module>
    mcdc.run()
  File "/usr/WS1/morgan83/tuo_dep/MCDC/mcdc/main.py", line 67, in run
    data_arr, mcdc_arr = prepare()
                         ^^^^^^^^^
  File "/usr/WS1/morgan83/tuo_dep/MCDC/mcdc/main.py", line 776, in prepare
    build_gpu_progs(input_deck, config.args)
  File "/usr/WS1/morgan83/tuo_dep/MCDC/mcdc/loop.py", line 856, in build_gpu_progs
    adapt.harm.RuntimeSpec.bind_specs()
  File "/usr/WS1/morgan83/tuo_dep/harmonize/harmonize/python/runtime.py", line 1252, in bind_specs
    subprocess.run(cmd.split(),shell=False,check=True)
  File "/collab/usr/gapps/python/toss_4_x86_64_ib/anaconda3-2023.09/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/opt/rocm-6.4.0/llvm/bin/llvm-link', '__harmonize_cache__/initialize_mcdc_precursor_event.bc', '__harmonize_cache__/step_mcdc_precursor_event.bc', '__harmonize_cache__/step_mcdc_source_event.bc', '__harmonize_cache__/make_work_mcdc_precursor_event.bc', '__harmonize_cache__/finalize_mcdc_precursor_event.bc', '__harmonize_cache__/finalize_mcdc_source_event.bc', '__harmonize_cache__//hipdevicelib.bc', '__harmonize_cache__/initialize_mcdc_source_event.bc', '__harmonize_cache__/make_work_mcdc_source_event.bc', '-o', '__harmonize_cache__/device_linked.bc']' returned non-zero exit status 1.

pip list

(venv-tuo) [morgan83@tuolumne2151:slab_absorbium]$ pip list
Package                       Version           Editable project location
----------------------------- ----------------- -----------------------------------
aiobotocore                   2.5.0
aiofiles                      22.1.0
aiohttp                       3.8.5
aioitertools                  0.7.1
aiosignal                     1.2.0
aiosqlite                     0.18.0
alabaster                     1.0.0
anaconda-anon-usage           0.4.2
anaconda-catalogs             0.2.0
anaconda-client               1.12.1
anaconda-cloud-auth           0.1.3
anaconda-navigator            2.5.0
anaconda-project              0.11.1
anyio                         3.5.0
appdirs                       1.4.4
argon2-cffi                   21.3.0
argon2-cffi-bindings          21.2.0
arrow                         1.3.0
astroid                       3.2.4
astropy                       5.1
asttokens                     2.4.1
async-timeout                 4.0.2
atlassian-python-api          3.41.2
atomicwrites                  1.4.1
attrs                         24.2.0
Automat                       20.2.0
autopep8                      2.0.4
babel                         2.16.0
backcall                      0.2.0
backports.functools-lru-cache 1.6.4
backports.tarfile             1.2.0
backports.tempfile            1.0
backports.weakref             1.0.post1
basemap                       1.3.7
basemap-data                  1.3.2
bcrypt                        3.2.0
beautifulsoup4                4.12.3
binaryornot                   0.4.4
biopython                     1.81
black                         24.8.0
bleach                        6.1.0
blosc2                        2.2.8
bokeh                         3.2.1
boltons                       23.0.0
botocore                      1.29.76
Bottleneck                    1.3.5
brotlipy                      0.7.0
build                         1.2.2.post1
Cartopy                       0.22.0
certifi                       2024.7.4
cffi                          1.17.0
cfgv                          3.4.0
cftime                        1.6.2
chardet                       5.2.0
charset-normalizer            3.3.2
clarabel                      0.10.0
click                         8.1.7
clingo                        5.6.2
cloudpickle                   3.0.0
clyent                        1.2.2
colorama                      0.4.6
colorcet                      3.0.1
comm                          0.2.2
conda                         23.9.0
conda-build                   3.26.1
conda-content-trust           0.2.0
conda_index                   0.3.0
conda-libmamba-solver         23.7.0
conda-pack                    0.6.0
conda-package-handling        2.2.0
conda_package_streaming       0.9.0
conda-repo-cli                1.0.75
conda-token                   0.4.0
conda-verify                  3.4.2
constantly                    15.1.0
contourpy                     1.0.5
cookiecutter                  2.6.0
cryptography                  43.0.0
cssselect                     1.1.0
cvxpy                         1.6.0
cycler                        0.11.0
Cython                        0.29.36
cytoolz                       0.12.0
daal4py                       2023.1.1
dask                          2023.6.0
datasets                      2.12.0
datashader                    0.15.2
datashape                     0.5.4
debugpy                       1.8.5
decorator                     5.1.1
defusedxml                    0.7.1
Deprecated                    1.2.14
diff-match-patch              20230430
dill                          0.3.8
distlib                       0.3.7
distributed                   2023.6.0
docstring-to-markdown         0.15
docutils                      0.21.2
entrypoints                   0.4
et-xmlfile                    1.1.0
executing                     2.0.1
fastjsonschema                2.20.0
filelock                      3.12.4
flake8                        7.0.0
Flask                         2.2.2
fonttools                     4.25.0
frozenlist                    1.3.3
fsspec                        2023.4.0
future                        0.18.3
gensim                        4.3.0
gist                          2.1.7
gitdb                         4.0.10
GitPython                     3.1.37
glob2                         0.7
gmpy2                         2.1.2
greenlet                      2.0.1
gym                           0.26.2
gym-notices                   0.0.8
h5py                          3.11.0
harmonize                     0.0.1             /usr/WS1/morgan83/tuo_dep/harmonize
healpy                        1.16.5
HeapDict                      1.0.1
hip-python                    6.4.0.549.36
hip-python-as-cuda            6.4.0.549.36
hjson                         3.1.0
holoviews                     1.17.1
huggingface-hub               0.15.1
hvplot                        0.8.4
hyperlink                     21.0.0
hypothesis                    6.87.1
identify                      2.6.6
idna                          3.7
imagecodecs                   2023.1.23
imageio                       2.31.1
imagesize                     1.4.1
imbalanced-learn              0.10.1
importlib_metadata            8.2.0
incremental                   21.3.0
inflection                    0.5.1
iniconfig                     1.1.1
intake                        0.6.8
intervaltree                  3.1.0
ipykernel                     6.29.5
ipython                       8.26.0
ipython-genutils              0.2.0
ipywidgets                    8.0.4
isort                         5.13.2
itemadapter                   0.3.0
itemloaders                   1.0.4
itsdangerous                  2.0.1
jaraco.classes                3.4.0
jaraco.context                5.3.0
jaraco.functools              4.0.2
jedi                          0.19.1
jeepney                       0.8.0
jellyfish                     1.1.0
Jinja2                        3.1.4
jinja2-time                   0.2.0
jmespath                      0.10.0
joblib                        1.2.0
json5                         0.9.6
jsonpatch                     1.32
jsonpointer                   2.1
jsonschema                    4.23.0
jsonschema-specifications     2023.12.1
jupyter                       1.0.0
jupyter_client                8.6.2
jupyter-console               6.6.3
jupyter_core                  5.7.2
jupyter-events                0.6.3
jupyter-server                1.23.4
jupyter_server_fileid         0.9.0
jupyter_server_ydoc           0.8.0
jupyter-ydoc                  0.2.4
jupyterlab                    3.6.3
jupyterlab_pygments           0.3.0
jupyterlab_server             2.22.0
jupyterlab-widgets            3.0.5
kaleido                       0.2.1
keras                         2.14.0
keyring                       25.3.0
kiwisolver                    1.4.4
lazy_loader                   0.2
lazy-object-proxy             1.6.0
libarchive-c                  2.9
libmambapy                    1.5.1
linkify-it-py                 2.0.0
lit                           17.0.2
llvmlite                      0.44.0
lmdb                          1.4.1
locket                        1.0.0
lxml                          4.9.3
lz4                           4.3.2
Markdown                      3.4.1
markdown-it-py                3.0.0
MarkupSafe                    2.1.5
matplotlib                    3.7.2
matplotlib-inline             0.1.7
mccabe                        0.7.0
mcdc                          0.11.1            /usr/WS1/morgan83/tuo_dep/MCDC
mdit-py-plugins               0.3.0
mdurl                         0.1.2
mistune                       3.0.2
mkl-fft                       1.3.8
mkl-random                    1.2.4
mkl-service                   2.4.0
more-itertools                10.4.0
mpi4py                        4.1.1+mpich.9.1.0
mpmath                        1.3.0
msgpack                       1.0.3
multidict                     6.0.2
multipledispatch              0.6.0
multiprocess                  0.70.14
munkres                       1.1.4
mypy                          1.5.1
mypy-extensions               1.0.0
navigator-updater             0.4.0
nbclassic                     0.5.5
nbclient                      0.10.0
nbconvert                     7.16.4
nbformat                      5.10.4
ndindex                       1.7
nest-asyncio                  1.6.0
netCDF4                       1.6.4
networkx                      3.1
nltk                          3.8.1
nodeenv                       1.9.1
nose                          1.3.7
notebook                      6.5.4
notebook_shim                 0.2.2
numba                         0.61.2
numba-hip                     0.1.6
numexpr                       2.8.4
numpy                         1.24.3
numpydoc                      1.8.0
oauthlib                      3.2.2
openpyxl                      3.0.10
osqp                          0.6.7.post3
packaging                     24.1
pandas                        2.0.3
pandocfilters                 1.5.1
panel                         1.2.3
param                         1.13.0
parsel                        1.6.0
parso                         0.8.4
partd                         1.4.0
pathlib                       1.0.1
pathspec                      0.12.1
patsy                         0.5.3
pep8                          1.7.1
periodictable                 1.6.1
pexpect                       4.9.0
pickleshare                   0.7.5
Pillow                        9.4.0
pip                           26.0.1
pkce                          1.0.3
pkgconfig                     1.5.5
pkginfo                       1.9.6
platformdirs                  3.11.0
plotly                        5.9.0
pluggy                        1.5.0
ply                           3.11
Pmw                           2.1.1
poyo                          0.5.0
pre_commit                    4.1.0
prometheus-client             0.14.1
prompt_toolkit                3.0.47
Protego                       0.1.16
psutil                        6.0.0
ptyprocess                    0.7.0
pure_eval                     0.2.3
py-cpuinfo                    8.0.0
pyarrow                       11.0.0
pyasn1                        0.4.8
pyasn1-modules                0.2.8
pybind11                      2.11.1
pycairo                       1.23.0
pycodestyle                   2.11.1
pycosat                       0.6.4
pycparser                     2.22
pyct                          0.5.0
pycurl                        7.45.2
pydantic                      1.10.8
PyDispatcher                  2.0.5
pydocstyle                    6.3.0
pydot                         1.4.2
pyerfa                        2.0.0
pyflakes                      3.2.0
Pygments                      2.18.0
PyGObject                     3.46.0
PyJWT                         2.4.0
pylint                        3.2.6
pylint-venv                   3.0.3
pyls-spyder                   0.4.0
pyodbc                        4.0.34
pyOpenSSL                     23.2.0
pyparsing                     3.0.9
pyproj                        3.4.1
pyproject_hooks               1.2.0
PyQt5                         5.15.11
PyQt5-Qt5                     5.15.14
PyQt5_sip                     12.15.0
PyQt6                         6.9.1
PyQt6-Qt6                     6.9.1
PyQt6_sip                     13.10.2
PyQtWebEngine                 5.15.7
PyQtWebEngine-Qt5             5.15.14
pyrsistent                    0.18.0
pyshp                         2.1.3
PySide2                       5.13.2
PySocks                       1.7.1
pytest                        7.4.0
python-dateutil               2.9.0.post0
python-dotenv                 0.21.0
python-json-logger            2.0.7
python-lsp-black              2.0.0
python-lsp-jsonrpc            1.1.2
python-lsp-server             1.11.0
python-slugify                8.0.4
python-snappy                 0.6.1
pytoolconfig                  1.3.1
pytz                          2023.3.post1
pyviz-comms                   2.3.0
PyWavelets                    1.4.1
pyxdg                         0.28
PyYAML                        6.0.2
pyzmq                         26.1.0
QDarkStyle                    3.2.3
qdldl                         0.1.7.post5
qstylizer                     0.2.3
QtAwesome                     1.3.1
qtconsole                     5.5.2
QtPy                          2.4.1
queuelib                      1.5.0
referencing                   0.35.1
regex                         2022.7.9
requests                      2.32.3
requests-file                 1.5.1
requests-oauthlib             1.3.1
requests-toolbelt             1.0.0
responses                     0.13.3
rfc3339-validator             0.1.4
rfc3986-validator             0.1.1
rich                          13.7.1
rocm-llvm-python              6.4.0.549.38
rope                          1.13.0
rpds-py                       0.20.0
Rtree                         1.3.0
ruamel.yaml                   0.17.21
ruamel-yaml-conda             0.17.21
s3fs                          2023.4.0
safetensors                   0.3.2
scikit-image                  0.20.0
scikit-learn                  1.3.0
scikit-learn-intelex          20230426.111612
scipy                         1.11.1
Scrapy                        2.8.0
scs                           3.2.7.post2
seaborn                       0.12.2
SecretStorage                 3.3.3
Send2Trash                    1.8.0
service-identity              18.1.0
setuptools                    82.0.0
shapely                       2.0.1
shiboken2                     5.13.2
sip                           6.6.2
six                           1.16.0
smart-open                    5.2.1
smmap                         5.0.1
sniffio                       1.2.0
snowballstemmer               2.2.0
sortedcontainers              2.4.0
soupsieve                     2.6
Sphinx                        8.0.2
sphinxcontrib-applehelp       2.0.0
sphinxcontrib-devhelp         2.0.0
sphinxcontrib-htmlhelp        2.1.0
sphinxcontrib-jsmath          1.0.1
sphinxcontrib-qthelp          2.0.0
sphinxcontrib-serializinghtml 2.0.0
spyder                        5.5.5
spyder-kernels                2.5.2
SQLAlchemy                    1.4.39
stack-data                    0.6.3
statsmodels                   0.14.0
sympy                         1.11.1
tables                        3.8.0
tabulate                      0.9.0
TBB                           0.2
tblib                         1.7.0
tenacity                      8.2.2
terminado                     0.17.1
text-unidecode                1.3
textdistance                  4.6.3
threadpoolctl                 2.2.0
three-merge                   0.1.1
tifffile                      2023.4.12
tinycss2                      1.3.0
tldextract                    3.2.0
tokenizers                    0.13.2
toml                          0.10.2
tomli                         2.0.1
tomlkit                       0.13.2
toolz                         0.12.0
tornado                       6.4.1
tqdm                          4.65.0
traitlets                     5.14.3
transformers                  4.32.1
truststore                    0.8.0
Twisted                       22.10.0
types-python-dateutil         2.9.0.20240316
typing_extensions             4.12.2
tzdata                        2023.3
uc-micro-py                   1.0.1
ujson                         5.10.0
Unidecode                     1.2.0
urllib3                       2.2.2
virtualenv                    20.24.5
w3lib                         1.21.0
watchdog                      4.0.2
wcwidth                       0.2.13
webencodings                  0.5.1
websocket-client              0.58.0
Werkzeug                      2.2.3
whatthepatch                  1.0.6
wheel                         0.45.1
widgetsnbextension            4.0.5
wrapt                         1.14.1
wurlitzer                     3.1.1
xarray                        2023.6.0
xxhash                        2.0.2
xyzservices                   2022.9.0
y-py                          0.5.9
yapf                          0.40.2
yarl                          1.8.1
ypy-websocket                 0.8.2
zict                          2.2.0
zipp                          3.20.0
zope.interface                5.4.0
zstandard                     0.19.0

module list

(venv-tuo) [morgan83@tuolumne2151:slab_absorbium]$ module list

Currently Loaded Modules:
  1) craype-x86-trento    3) libfabric/match_SHS      5) craype/2.7.35       7) flux_wrappers/0.1   9) StdEnv     (S)  11) cray-libsci/25.09.0  13) python/3.11.5
  2) craype-network-ofi   4) perftools-base/25.09.0   6) PrgEnv-cray/8.6.0   8) xpmem/2.6.5        10) cce/20.0.0      12) cray-mpich/9.0.1     14) rocm/6.4.0

  Where:
   S:  Module is Sticky, requires --force to unload or purge

 

@mrowan137 mrowan137 force-pushed the rocm-compile-to-objects branch from e0d6735 to c64854b Compare March 2, 2026 19:53
@mrowan137
Copy link
Author

@jpmorgan98 thank you for testing it out! Comparing with your packages, I found that my testing uses some older ones; these ones particularly:

numba                         0.60.0
numba-hip                     0.1.2
llvmlite                      0.43.0

When I upgraded to 0.61.2, 0.1.6, 0.44.0 as in your setup, I can reproduce the linker error you shared. I pushed one more change that will use llvm-link --override to resolve duplicate definitions instead of giving an error. Would you be able to test with the latest and see if this resolves the issue?

@jpmorgan98
Copy link
Member

jpmorgan98 commented Mar 3, 2026

The plot thickens

With your most recent updates and numba-hip[rocm-6-4-0] at version 0.1.6 (llvmlite 0.44.0 & numba==0.61.2)

I am unable to install numba-hip[rocm-6-4-0] at version 0.1.2 (llvmlite 0.43.0 & numba==0.60.0). It doesn't look like they tagged those old releases so I cant find them. If you know how to install those I can try that.

Thanks!

(venv-tuo) [morgan83@tuolumne2150:slab_absorbium]$ HSA_XNACK=1 ROCR_VISIBLE_DEVICES=0 flux run -N 1 -n 1 -g 1 -q pdebug -B cbronze python input.py --mode=numba --target=gpu
flux-job: f2tHcJpQxfRH started                                                                                                                                                          00:00:04
warning: overriding the module target triple with x86_64-unknown-linux-gnu [-Woverride-module]
1 warning generated.
lld: warning: WS1/morgan83/tuo_dep/harmonize/harmonize/python/../cpp/program/mod.h:66:0: failed to meet occupancy target given by 'amdgpu-waves-per-eu' in '_Z9_dev_execI12EventProgramI14mcdc_precursorEEvNT_13DeviceContextENS3_11DeviceStateEm': desired occupancy was 4, final occupancy is 3
lld: warning: WS1/morgan83/tuo_dep/harmonize/harmonize/python/../cpp/program/mod.h:66:0: failed to meet occupancy target given by 'amdgpu-waves-per-eu' in '_Z9_dev_execI12EventProgramI11mcdc_sourceEEvNT_13DeviceContextENS3_11DeviceStateEm': desired occupancy was 4, final occupancy is 3
:0:/longer_pathname_so_that_rpms_can_support_packaging_the_debug_info_for_all_os_profiles/src/clr/hipamd/src/hip_global.cpp:158 : 364374250279 us:  Module not initialized
Fatal Python error: Aborted

Current thread 0x000015555554c080 (most recent call first):
  File "/usr/WS1/morgan83/tuo_dep/MCDC/mcdc/main.py", line 1122 in prepare
  File "/usr/WS1/morgan83/tuo_dep/MCDC/mcdc/main.py", line 67 in run
  File "/usr/WS1/morgan83/tuo_dep/MCDC/examples/fixed_source/slab_absorbium/input.py", line 48 in <module>

Extension modules: mkl._mklinit, mkl._py_mkl_service, numpy.core._multiarray_umath, numpy.core._multiarray_tests, numpy.linalg._umath_linalg, numpy.fft._pocketfft_internal, numpy.random._common, numpy.random.bit_generator, numpy.random._bounded_integers, numpy.random._mt19937, numpy.random.mtrand, numpy.random._philox, numpy.random._pcg64, numpy.random._sfc64, numpy.random._generator, scipy._lib._ccallback_c, yaml._yaml, numba.core.typeconv._typeconv, numba._helperlib, numba._dynfunc, numba._dispatcher, numba.core.typing.builtins.itertools, numba.cpython.builtins.math, numba.core.runtime._nrt_python, numba.np.ufunc._internal, numba.experimental.jitclass._box, h5py._errors, h5py.defs, h5py._objects, h5py.h5, h5py.utils, h5py.h5t, h5py.h5s, h5py.h5ac, h5py.h5p, h5py.h5r, h5py._proxy, h5py._conv, h5py.h5z, h5py.h5a, h5py.h5d, h5py.h5ds, h5py.h5g, h5py.h5i, h5py.h5o, h5py.h5f, h5py.h5fd, h5py.h5pl, h5py.h5l, h5py._selector, gmpy2.gmpy2, mpi4py.MPI, matplotlib._c_internal_utils, PIL._imaging, matplotlib._path, kiwisolver._cext, matplotlib._image, numba.mviewbuf, hip._util.types, hip._hip_helpers, hip._util.posixloader, hip.chip, hip.hip, hip._hiprtc_helpers, hip.chiprtc, hip.hiprtc, hip.chipblas, hip.hipblas, hip.crccl, hip.rccl, hip.chiprand, hip.hiprand, hip.chipfft, hip.hipfft, hip.chipsparse, hip.hipsparse, hip.croctx, hip.roctx, hip.chipsolver, hip.hipsolver, cuda.nvrtc, cuda.cuda, cuda.cudart, rocm.llvm._util.types, rocm.llvm.c.types, rocm.llvm._util.posixloader, rocm.llvm.c.canalysis, rocm.llvm.c.analysis, rocm.llvm.c.cbitreader, rocm.llvm.c.bitreader, rocm.llvm.c.cbitwriter, rocm.llvm.c.bitwriter, rocm.llvm.c.cblake3, rocm.llvm.c.blake3, rocm.llvm.c.ccomdat, rocm.llvm.c.comdat, rocm.llvm.c.cerrorhandling, rocm.llvm.c.errorhandling, rocm.llvm.c.ccore, rocm.llvm.c.core, rocm.llvm.c.datatypes, rocm.llvm.c.cdebuginfo, rocm.llvm.c.debuginfo, rocm.llvm.c.deprecated, rocm.llvm.c.disassemblertypes, rocm.llvm.c.cdisassembler, rocm.llvm.c.disassembler, rocm.llvm.c.cerror, rocm.llvm.c.error, rocm.llvm.config.cllvm_config, rocm.llvm.config.llvm_config, rocm.llvm.c.ctarget, rocm.llvm.c.target, rocm.llvm.c.ctargetmachine, rocm.llvm.c.targetmachine, rocm.llvm.c.cexecutionengine, rocm.llvm.c.executionengine, rocm.llvm.c.cirreader, rocm.llvm.c.irreader, rocm.llvm.c.clinker, rocm.llvm.c.linker, rocm.llvm.c.corc, rocm.llvm.c.orc, rocm.llvm.c.clljit, rocm.llvm.c.lljit, rocm.llvm.c.clljitutils, rocm.llvm.c.lljitutils, rocm.llvm.c.clto, rocm.llvm.c.lto, rocm.llvm.c.cobject, rocm.llvm.c.object, rocm.llvm.c.corcee, rocm.llvm.c.orcee, rocm.llvm.c.cremarks, rocm.llvm.c.remarks, rocm.llvm.c.csupport, rocm.llvm.c.support, rocm.llvm.c.transforms.cpassbuilder, rocm.llvm.c.transforms.passbuilder, rocm.amd_comgr.camd_comgr, rocm.amd_comgr.amd_comgr, numba.cpython.mathimpl.math, numba.cpython.mathimpl.sys, numba.core.typing.cmathdecl.cmath, _cffi_backend, scipy.linalg._fblas, scipy.linalg._flapack, scipy.linalg.cython_lapack, scipy.linalg._cythonized_array_utils, scipy.linalg._solve_toeplitz, scipy.linalg._decomp_lu_cython, scipy.linalg._matfuncs_sqrtm_triu, scipy.linalg.cython_blas, scipy.linalg._matfuncs_expm, scipy.linalg._decomp_update, scipy.sparse._sparsetools, _csparsetools, scipy.sparse._csparsetools, scipy.sparse.linalg._isolve._iterative, scipy.sparse.linalg._dsolve._superlu, scipy.sparse.linalg._eigen.arpack._arpack, scipy.sparse.csgraph._tools, scipy.sparse.csgraph._shortest_path, scipy.sparse.csgraph._traversal, scipy.sparse.csgraph._min_spanning_tree, scipy.sparse.csgraph._flow, scipy.sparse.csgraph._matching, scipy.sparse.csgraph._reordering, scipy.linalg._flinalg, numba.types.itertools, numba.cpython.hashing.math, numba.cpython.hashing.sys, numba.cpython.numbers.math, numba.core.typing.mathdecl.math, numba.np.arraymath.math (total: 175)
flux-job: task(s) Abortedle      

@braxtoncuneo braxtoncuneo added the good first issue Good for newcomers label Mar 4, 2026
@braxtoncuneo
Copy link
Collaborator

Many thanks for the contributions - both past and present! @mrowan137 and @jpmorgan98

I think I have these changes working on tuolumne, though not with the exact same configuration.

Here is the script I used to set up the initial environment:

#!/bin/bash -x
cd

# =============================================================================
# Setups
# =============================================================================

# MC/DC and harmonize branches
MCDC_BRANCH="main"
HARMONIZE_BRANCH="global_array_fields"

# Name for the virtual environment
VENV_NAME="mcdc"

# ROCm and Python versions
ROCM_VERSION="6.0.0"
PYTHON_VERSION="3.11.5"

# MPI module
MPI_MODULE="cray-mpich/9.0.1"

# Paths
WORKSPACE="$HOME"
VENV_PATH="$WORKSPACE/new-tuo-venv"
ROCM_LLVM_PY_DIR="$WORKSPACE/rocm_llvm_py-new"
HARMONIZE_DIR="$WORKSPACE/harmonize"
MCDC_DIR="$WORKSPACE/MCDC"

# =============================================================================
# Preparation
# =============================================================================

# Load necessary modules
module load "python/$PYTHON_VERSION"
module load "rocm/$ROCM_VERSION"
module load "$MPI_MODULE"

# =============================================================================
# Create Python environment
# =============================================================================

# Remove any pre-existing instance of the environment
rm -rf "$VENV_PATH"

# Create the environment
"/usr/tce/packages/python/python-$PYTHON_VERSION/bin/virtualenv" "$VENV_PATH"

# Add ROCm paths to the environment (to help hip-numba later)
PATH_EXPORTS="""
export ROCM_PATH="/opt/rocm-$ROCM_VERSION"
export ROCM_HOME="/opt/rocm-$ROCM_VERSION"
"""
echo "$PATH_EXPORTS" >> "$VENV_PATH/bin/activate"

# Activate the venv
source "$VENV_PATH/bin/activate"

# Make sure we are working with a recent version of pip and setuptools
pip install --upgrade pip
pip install --upgrade setuptools

# =============================================================================
# Install ROCm-LLVM-Python
# =============================================================================

# Remove any pre-existing install
rm -rf "$ROCM_LLVM_PY_DIR"

# Clone in the repo
git clone https://github.com/ROCm/rocm-llvm-python "$ROCM_LLVM_PY_DIR"

# Enter the repo
cd $ROCM_LLVM_PY_DIR

# Get the branch for our preferred version of ROCM
git checkout "release/rocm-rel-$ROCM_VERSION"

# Build the package
./init.sh
sed -i "s/cimport *cpython.string/#cimport cpython.string/g" "$ROCM_LLVM_PY_DIR/rocm-llvm-python/rocm/llvm/_util/types.pyx"
./build_pkg.sh --post-clean -j 16

# Select a wheel with the preferred rocm version.
LATEST=$( ls -1 rocm-llvm-python/dist/rocm_llvm_python-${ROCM_VERSION}*.whl | tail -n 1 )
pip install --force-reinstall $LATEST
unset LATEST

###############################################################################
# Install HIP-Python
###############################################################################

pip install -i https://test.pypi.org/simple "hip-python~=$ROCM_VERSION"
pip install -i https://test.pypi.org/simple "hip-python-as-cuda~=$ROCM_VERSION"

###############################################################################
# Install HIP-Numba
###############################################################################

pip install numba==0.61.0
pip config set global.extra-index-url https://test.pypi.org/simple
#pip install --no-deps "git+https://github.com/ROCm/numba-hip.git@8098162162fb0babd77b56583b289d6dd6226151"
pip install --no-deps "git+https://github.com/ROCm/numba-hip.git"

###############################################################################
#  Install Harmonize and MC/DC
###############################################################################

# Harmonize
cd "$HARMONIZE_DIR"
git checkout "$HARMONIZE_BRANCH"
pip install -e .

# MC/DC
cd "$MCDC_DIR"
git checkout "$MCDC_BRANCH"
pip install -e .[dev]

# Install MPI4Py
CC=cc MPICC=cc pip install --no-binary=mpi4py mpi4py==4.0.0

# Install supported library versions
pip install cvxpy==1.7.0
pip install scipy==1.12
pip install numpy==1.24.3

This script switches the MCDC and harmonize branches, and so they would need to be switched back before continuing if you run this script out of the box. For MCDC, I had success with the original AMD interop commit, as it was merged into dev: 5350f16f29b21a21cb649c4d29dcce1476065356

There are some changes in harmonize/global_array_fields which would bring compatibility much closer to working with MCDC/dev, but it's probably best to get this merged in first.

@mrowan137
Copy link
Author

@jpmorgan98, the error is good news in a way-- we've passed the linker error, to a runtime error.

Initially, it seemed this could be due to some difference in our python packages, so I iteratively aligned package versions to the ones you shared. Surprisingly, even with identical package versions, the runtime error did not appear. After that, it seemed a remaining major difference was how we were running the reproducer: interactive mode (flux alloc ... --> python input.py ...), vs. under Flux (flux run ... python input.py ...). With the latter, the runtime error was appearing.

Upon further inspection of environment differences between those contexts, the runtime error appears to be due to unintended interaction with Spindle (which is on by default); disabling that, e.g. with:

  • -o spindle.level=off, or
  • -o fastload,
    the reproducer runs on my end without any error. Would you be able to test if either of these options work for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

good first issue Good for newcomers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants