Skip to content

Commit

Permalink
Merge pull request #24851 from isuruf/ensmallen_graph
Browse files Browse the repository at this point in the history
Ensmallen graph
  • Loading branch information
isuruf authored Jan 30, 2024
2 parents 413c16c + 955e6c2 commit bce8c02
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .azure-pipelines/azure-pipelines-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ jobs:
done
displayName: Manage disk space
- script: |
sudo fallocate -l 10GiB /swapfile || true
sudo chmod 600 /swapfile || true
sudo mkswap /swapfile || true
sudo swapon /swapfile || true
displayName: Create swap file
- script: |
# sudo pip install --upgrade pip
sudo pip install setuptools shyaml
Expand Down
26 changes: 26 additions & 0 deletions recipes/ensmallen/0001-No-zig.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
From 53b57c79a209cd3ce3cd486f0a5864d27f3f6f0e Mon Sep 17 00:00:00 2001
From: Isuru Fernando <[email protected]>
Date: Fri, 5 Jan 2024 17:23:52 +0530
Subject: [PATCH] No zig

---
bindings/python/build.py | 3 +++
1 file changed, 3 insertions(+)

diff --git a/bindings/python/build.py b/bindings/python/build.py
index 12c3ae73..73bf2840 100644
--- a/bindings/python/build.py
+++ b/bindings/python/build.py
@@ -117,6 +117,9 @@ def compile_target(target_name, target_settings, WHEELS_FOLDER, settings):
"CFLAGS": "-stdlib=libc++"
}

+ zig = ""
+ env = {}
+
env["RUSTFLAGS"] = env.get("RUST_FLAGS", "") + " " + rust_flags

environment = os.environ.copy()
--
2.42.0

41 changes: 41 additions & 0 deletions recipes/ensmallen/0001-Use-thin-lto.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
From ff396cead32151e3013d6f05124c0602ce8b3e9c Mon Sep 17 00:00:00 2001
From: Isuru Fernando <[email protected]>
Date: Thu, 18 Jan 2024 08:15:56 -0600
Subject: [PATCH] Use thin lto

When fat lto is used, the compiler takes too much memory and the OS
kills rustc. Thanks to @mbargull for the tip.
---
bindings/python/Cargo.toml | 2 +-
graph/Cargo.toml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/bindings/python/Cargo.toml b/bindings/python/Cargo.toml
index 8efa26b4..c241c6c4 100644
--- a/bindings/python/Cargo.toml
+++ b/bindings/python/Cargo.toml
@@ -60,7 +60,7 @@ opt-level = 3
# time.
# Perform "fat" LTO which attempts to perform optimizations across all crates
# within the dependency graph
-lto = "fat"
+lto = "thin"

# When a crate is split into multiple codegen units, LLVM is able to process
# them in parallel. Increasing parallelism may speed up compile times, but may
diff --git a/graph/Cargo.toml b/graph/Cargo.toml
index bd43fe40..345662b9 100644
--- a/graph/Cargo.toml
+++ b/graph/Cargo.toml
@@ -73,7 +73,7 @@ windows = { version = "0.32.0", features = ["alloc", "Win32_System_Memory", "Wi

[profile.release]
opt-level = 3
-lto = "fat"
+lto = "thin"
overflow-checks = false # Disable integer overflow checks.
debug = false # Include debug info.
debug-assertions = false # Enables debug assertions.
--
2.42.0

3 changes: 3 additions & 0 deletions recipes/ensmallen/conda-forge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
azure:
settings_linux:
swapfile_size: "10GiB"
2 changes: 2 additions & 0 deletions recipes/ensmallen/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
channel_sources:
- conda-forge/label/rust_dev,conda-forge
67 changes: 67 additions & 0 deletions recipes/ensmallen/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{% set version = "0.8.96" %}

package:
name: ensmallen_graph
version: {{ version }}

source:
# There's no github tag, but this is the commit used for PyPI publishing
# See https://github.com/AnacletoLAB/ensmallen/issues/226
url: https://github.com/AnacletoLAB/ensmallen/archive/b2492e02dfdb9a7a10ca087d53b3207aadca3b9c.tar.gz
sha256: 044e1ac0cd53f1ec39744f7984a341e27a6c7a80850e3d23934ff2a41e8159c4
patches:
- 0001-No-zig.patch
- 0001-Use-thin-lto.patch

build:
script:
- cd bindings/python
- cargo-bundle-licenses --format yaml --output ${SRC_DIR}/THIRDPARTY.yml
- {{ PYTHON }} ./build.py --skip-repair
- {{ PYTHON }} -m pip install wheels/*.whl
number: 0
skip: True # [not linux64]

requirements:
build:
- {{ compiler('c') }}
- {{ compiler('cxx') }}
- {{ compiler('rust') }}
- cargo-bundle-licenses
host:
- python
- maturin
- pip
run:
- python
- toml >=0.10.0
- downloaders >=1.0.15
- compress_json >=1.0.7
- userinput >=1.0.19
- cache_decorator >=2.1.11
- bioregistry >=0.5.65
- tqdm
- pandas
- py-cpuinfo
- environments_utils >=1.0.13

test:
imports:
- ensmallen
commands:
- pip check
requires:
- pip

about:
home: https://github.com/AnacletoLAB/ensmallen
summary: Ensmallen is the Rust/Python high-performance graph processing submodule of the GRAPE library.
license: MIT
license_file:
- LICENSE
- THIRDPARTY.yml

extra:
recipe-maintainers:
- isuruf
- dillonroach

0 comments on commit bce8c02

Please sign in to comment.