{"id":27201,"library":"onemkl-sycl-sparse","title":"oneMKL SYCL Sparse","description":"Intel oneAPI Math Kernel Library (oneMKL) Sparse BLAS routines for SYCL devices. This package provides optimized sparse linear algebra operations (e.g., sparse matrix-vector multiply, sparse triangular solvers) on Intel GPUs and CPUs using SYCL. Current version: 2026.0.0. Released quarterly as part of Intel's oneAPI toolkit.","status":"active","version":"2026.0.0","language":"python","source_language":"en","source_url":"https://github.com/oneapi-src/oneMKL","tags":["sparse","blas","math","intel","sycl","gpu"],"install":[{"cmd":"pip install onemkl-sycl-sparse","lang":"bash","label":"PyPI"},{"cmd":"conda install -c intel onemkl-sycl-sparse","lang":"bash","label":"Conda"}],"dependencies":[{"reason":"Array compatibility and data type conversions","package":"numpy","optional":true},{"reason":"SYCL device management and USM allocation","package":"dpctl","optional":false},{"reason":"NumPy-like API on SYCL devices (optional, but recommended for ease of use)","package":"dpnp","optional":true}],"imports":[{"note":"The correct import uses the 'sparse' submodule; importing the top-level package gives no useful functions.","wrong":"import onemkl_sycl_sparse","symbol":"sparse","correct":"from onemkl_sycl_sparse import sparse"}],"quickstart":{"code":"import dpctl\nimport numpy as np\nfrom onemkl_sycl_sparse import sparse\n\n# Create a SYCL queue (device selector: 0 for gpu, 1 for cpu)\nqueue = dpctl.SyclQueue(\"gpu\")\n\n# Create a simple CSR matrix\nrow = np.array([0, 0, 1, 2], dtype=np.int64)\ncol = np.array([0, 1, 1, 2], dtype=np.int64)\nval = np.array([1.0, 2.0, 3.0, 4.0], dtype=np.float64)\nnrows, ncols = 3, 3\n\n# Allocate USM memory\nd_row = dpctl.tensor.usm_ndarray(row, dtype=row.dtype, queue=queue)\nd_col = dpctl.tensor.usm_ndarray(col, dtype=col.dtype, queue=queue)\nd_val = dpctl.tensor.usm_ndarray(val, dtype=val.dtype, queue=queue)\n\n# Create handle and perform operation\nhandle = sparse.create_handle(queue)\nsparse_matrix = sparse.init_csr_matrix(handle, nrows, ncols, d_row, d_col, d_val)\n\n# Sparse matrix-vector multiply\nx = np.array([1.0, 2.0, 3.0], dtype=np.float64)\nd_x = dpctl.tensor.usm_ndarray(x, dtype=x.dtype, queue=queue)\nd_y = dpctl.tensor.empty(3, dtype=np.float64, queue=queue)\nsparse.omatadd(handle, sparse_matrix, sparse_matrix, 1.0, 1.0, d_x, d_y)\ny = d_y.asnumpy()\nprint(y)\n\nsparse.destroy_handle(handle)","lang":"python","description":"Performs a sparse matrix-vector multiply using CSR format on a SYCL GPU device."},"warnings":[{"fix":"Use dpctl.tensor.usm_ndarray to allocate device memory and copy data.","message":"All input arrays (row, col, val) must be on the same SYCL device as the queue. Do not mix host memory (numpy) directly without copying to USM.","severity":"gotcha","affected_versions":"all"},{"fix":"Always pair sparse.create_handle with sparse.destroy_handle, ideally in a try-finally block or context manager (if available).","message":"Matrix handles must be explicitly created and destroyed. Forgetting sparse.destroy_handle leads to memory leaks.","severity":"gotcha","affected_versions":"all"},{"fix":"Pre-process CSR arrays to be in sorted column order per row (e.g., using scipy sparse CSR construction).","message":"The sparse module expects Fortran-style (column-major) ordering for some internal operations, but CSR arrays are typically row-major. Ensure row-index array is sorted and unique per row.","severity":"gotcha","affected_versions":"all"},{"fix":"Use 'from onemkl_sycl_sparse import sparse'.","message":"The old import path from 'oneapi.mkl' is deprecated and removed in 2026.0.0.","severity":"deprecated","affected_versions":"<2026.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install: pip install onemkl-sycl-sparse","cause":"Package not installed or wrong Python environment.","error":"ModuleNotFoundError: No module named 'onemkl_sycl_sparse'"},{"fix":"Use: from onemkl_sycl_sparse import sparse","cause":"Incorrect import. The correct import is 'from onemkl_sycl_sparse import sparse'.","error":"AttributeError: module 'onemkl_sycl_sparse' has no attribute 'sparse'"},{"fix":"Check Intel GPU/CPU drivers, install Intel oneAPI runtime, or use 'cpu' selector: dpctl.SyclQueue(\"cpu\")","cause":"No compatible SYCL device (GPU/CPU) found or driver issues.","error":"dpctl._sycl.SyclQueueCreationError: No device of requested type available"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}