Skip to content

Commit 73f38aa

Browse files
committed
init: hello world fluence v2!
I have the traditional compute scheduling working with PodGroup (kubernetes 1.36.1) and am thinking about how to model the quantum resource request next. Stay tuned! Signed-off-by: vsoch <vsoch@users.noreply.github.com>
0 parents  commit 73f38aa

31 files changed

Lines changed: 2339 additions & 0 deletions

.devcontainer/Dockerfile

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
FROM fluxrm/flux-core:noble
2+
3+
LABEL maintainer="Vanessasaurus <@vsoch>"
4+
5+
# Match the default user id for a single system so we aren't root
6+
ARG USERNAME=vscode
7+
ARG USER_UID=1000
8+
ARG USER_GID=1000
9+
ENV USERNAME=${USERNAME}
10+
ENV USER_UID=${USER_UID}
11+
ENV USER_GID=${USER_GID}
12+
USER root
13+
14+
# Install extra buildrequires for flux-sched:
15+
RUN sudo apt-get update && \
16+
sudo apt-get -qq install -y --no-install-recommends \
17+
libboost-graph-dev \
18+
libboost-system-dev \
19+
libboost-filesystem-dev \
20+
libboost-regex-dev \
21+
python3-yaml \
22+
libyaml-cpp-dev \
23+
libedit-dev \
24+
ninja-build \
25+
cmake \
26+
curl
27+
28+
# Assuming installing to /usr/local
29+
ENV LD_LIBRARY_PATH=/usr/lib:/usr/local/lib
30+
31+
# Install Go 19 for TBA bindings (if Go bindings desired)
32+
RUN wget https://go.dev/dl/go1.26.0.linux-amd64.tar.gz && tar -xvf go1.26.0.linux-amd64.tar.gz && \
33+
mv go /usr/local && rm go1.26.0.linux-amd64.tar.gz
34+
ENV PATH=$PATH:/usr/local/go/bin:/home/vscode/go/bin
35+
36+
# extra interactive utilities
37+
RUN sudo apt-get update \
38+
&& sudo apt-get -qq install -y --no-install-recommends \
39+
fd-find \
40+
less \
41+
bats \
42+
ripgrep \
43+
libczmq-dev
44+
45+
46+
# --- Rust (for building QRMI) --------------------------------------------
47+
# Installed system-wide so it is available regardless of the active user.
48+
# QRMI pins its toolchain via rust-toolchain.toml (currently 1.91); rustup will
49+
# fetch that automatically during the build below.
50+
ENV RUSTUP_HOME=/usr/local/rustup \
51+
CARGO_HOME=/usr/local/cargo \
52+
PATH=/usr/local/cargo/bin:$PATH
53+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
54+
| sh -s -- -y --no-modify-path --profile minimal --default-toolchain 1.91 \
55+
&& chmod -R a+rwX /usr/local/rustup /usr/local/cargo
56+
57+
# --- QRMI native library (the bindings' cgo dependency) ------------------
58+
# Pin QRMI_REF to a tag/commit for reproducibility if you like; defaults to main.
59+
ARG QRMI_REPO=https://github.com/qiskit-community/qrmi
60+
ARG QRMI_REF=main
61+
RUN git clone ${QRMI_REPO} /opt/qrmi \
62+
&& cd /opt/qrmi \
63+
&& git checkout ${QRMI_REF} \
64+
&& cargo build --locked --release \
65+
&& install -d /usr/local/include /usr/local/lib \
66+
&& install -m 0644 qrmi.h /usr/local/include/qrmi.h \
67+
&& install -m 0644 target/release/libqrmi.a /usr/local/lib/libqrmi.a \
68+
&& install -m 0755 target/release/libqrmi.so /usr/local/lib/libqrmi.so \
69+
&& ldconfig
70+
71+
# Add the group and user that match our ids
72+
RUN groupadd -g ${USER_GID} ${USERNAME} && \
73+
adduser --disabled-password --uid ${USER_UID} --gid ${USER_GID} --gecos "" ${USERNAME} && \
74+
echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers
75+
76+
# This branch of flux-sched has the bindings we need!
77+
RUN ln -s /usr/local/go/bin/go /usr/bin/go && \
78+
git clone https://github.com/flux-framework/flux-sched /opt/flux-sched && \
79+
cd /opt/flux-sched && \
80+
export WITH_GO=yes && \
81+
./configure --prefix=/usr && \
82+
mkdir build && \
83+
cd build && \
84+
cmake ../ && \
85+
cd ../ && \
86+
make && make install
87+
88+
ENV LD_LIBRARY_PATH=/usr/lib:/opt/flux-sched/resource:/opt/flux-sched/resource/reapi/bindings:/opt/flux-sched/resource/libjobspec
89+
USER $USERNAME

.devcontainer/Dockerfile.old

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
FROM fluxrm/flux-core:bookworm
2+
3+
LABEL maintainer="Vanessasaurus <@vsoch>"
4+
5+
# Match the default user id for a single system so we aren't root
6+
ARG USERNAME=vscode
7+
ARG USER_UID=1000
8+
ARG USER_GID=1000
9+
ENV USERNAME=${USERNAME}
10+
ENV USER_UID=${USER_UID}
11+
ENV USER_GID=${USER_GID}
12+
USER root
13+
14+
# Install extra buildrequires for flux-sched:
15+
RUN sudo apt-get update
16+
RUN sudo apt-get -qq install -y --no-install-recommends \
17+
libboost-graph-dev \
18+
libboost-system-dev \
19+
libboost-filesystem-dev \
20+
libboost-regex-dev \
21+
python3-yaml \
22+
libyaml-cpp-dev \
23+
libedit-dev \
24+
ninja-build \
25+
curl
26+
27+
# Assuming installing to /usr/local
28+
ENV LD_LIBRARY_PATH=/usr/lib:/usr/local/lib
29+
30+
RUN curl -s -L https://github.com/Kitware/CMake/releases/download/v3.26.4/cmake-3.26.4-linux-$(uname -m).sh > cmake.sh ;\
31+
sudo bash cmake.sh --prefix=/usr/local --skip-license ;\
32+
rm cmake.sh
33+
34+
# Install Go 19 for TBA bindings (if Go bindings desired)
35+
RUN wget https://go.dev/dl/go1.19.10.linux-amd64.tar.gz && tar -xvf go1.19.10.linux-amd64.tar.gz && \
36+
mv go /usr/local && rm go1.19.10.linux-amd64.tar.gz
37+
ENV PATH=$PATH:/usr/local/go/bin:/home/vscode/go/bin
38+
39+
# extra interactive utilities
40+
RUN apt-get update \
41+
&& apt-get -qq install -y --no-install-recommends \
42+
fd-find \
43+
less \
44+
bats \
45+
ripgrep
46+
47+
# Add the group and user that match our ids
48+
RUN groupadd -g ${USER_GID} ${USERNAME} && \
49+
adduser --disabled-password --uid ${USER_UID} --gid ${USER_GID} --gecos "" ${USERNAME} && \
50+
echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers
51+
52+
# This branch of flux-sched has the bindings we need!
53+
RUN git clone -b lib-updates https://github.com/milroy/flux-sched /opt/flux-sched && \
54+
cd /opt/flux-sched && \
55+
export WITH_GO=yes && \
56+
./configure --prefix=/usr && \
57+
mkdir build && \
58+
cd build && \
59+
cmake ../ && \
60+
cd ../ && \
61+
make && make install
62+
63+
USER $USERNAME

.devcontainer/devcontainer.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "Fluxion (Fluence) with Quantum",
3+
"dockerFile": "Dockerfile",
4+
"context": "../",
5+
6+
"customizations": {
7+
"vscode": {
8+
"settings": {
9+
"terminal.integrated.defaultProfile.linux": "bash"
10+
},
11+
"extensions": [
12+
"ms-vscode.cmake-tools",
13+
"golang.go"
14+
]
15+
}
16+
},
17+
"postStartCommand": "git config --global --add safe.directory /workspaces/fluence"
18+
}

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
bin/
2+
.git/
3+
*.tar.gz

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
vendor
2+
bin

COPYRIGHT

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Intellectual Property Notice
2+
----------------------------
3+
4+
HPCIC DevTools is licensed under the MIT license (LICENSE).
5+
6+
Copyrights and patents in this project are retained by
7+
contributors. No copyright assignment is required to contribute to
8+
HPCIC DevTools.
9+
10+
SPDX usage
11+
------------
12+
13+
Individual files contain SPDX tags instead of the full license text.
14+
This enables machine processing of license information based on the SPDX
15+
License Identifiers that are available here: https://spdx.org/licenses/

Dockerfile

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Multi-stage build for the fluence scheduler.
2+
#
3+
# The scheduler binary cgo-links flux-sched (Fluxion) for resource matching.
4+
# It does NOT depend on QRMI — quantum job submission is a separate workload
5+
# (github.com/converged-computing/qrmi-sampler). So this image needs only
6+
# flux-sched, no Rust/QRMI. Mirrors the .devcontainer build.
7+
8+
# ---------- builder ----------
9+
FROM fluxrm/flux-core:noble AS builder
10+
11+
USER root
12+
ENV LD_LIBRARY_PATH=/usr/lib:/usr/local/lib
13+
ENV DEBIAN_FRONTEND=noninteractive
14+
15+
RUN apt-get update && apt-get install -y --no-install-recommends \
16+
libboost-graph-dev libboost-system-dev libboost-filesystem-dev \
17+
libboost-regex-dev libyaml-cpp-dev libedit-dev libczmq-dev \
18+
python3-yaml ninja-build cmake curl git wget ca-certificates \
19+
&& rm -rf /var/lib/apt/lists/*
20+
21+
# Go toolchain
22+
RUN wget -q https://go.dev/dl/go1.26.0.linux-amd64.tar.gz \
23+
&& tar -C /usr/local -xzf go1.26.0.linux-amd64.tar.gz && rm go1.26.0.linux-amd64.tar.gz
24+
ENV PATH=$PATH:/usr/local/go/bin
25+
26+
# flux-sched (Fluxion) with the Go reapi bindings -> /usr; build tree at /opt/flux-sched
27+
RUN git clone https://github.com/flux-framework/flux-sched /opt/flux-sched \
28+
&& cd /opt/flux-sched && export WITH_GO=yes && ./configure --prefix=/usr \
29+
&& mkdir build && cd build && cmake ../ && cd ../ && make -j"$(nproc)" && make install
30+
ENV FLUX_SCHED_ROOT=/opt/flux-sched
31+
32+
# Build the scheduler
33+
WORKDIR /src
34+
COPY go.mod go.sum* ./
35+
RUN go mod download || true
36+
COPY . .
37+
RUN CGO_ENABLED=1 \
38+
CGO_CFLAGS="-I/opt/flux-sched" \
39+
CGO_LDFLAGS="-L/opt/flux-sched/resource -L/opt/flux-sched/resource/libjobspec -L/opt/flux-sched/resource/reapi/bindings -lresource -ljobspec_conv -lreapi_cli -lflux-idset -lstdc++ -lczmq -ljansson -lhwloc -lboost_system -lflux-hostlist -lboost_graph -lyaml-cpp" \
40+
go build -ldflags '-w' -o /bin/fluence ./cmd/fluence
41+
42+
FROM fluxrm/flux-core:noble AS runtime
43+
44+
USER root
45+
ENV LD_LIBRARY_PATH=/usr/lib:/opt/flux-sched/resource:/opt/flux-sched/resource/reapi/bindings:/opt/flux-sched/resource/libjobspec
46+
47+
RUN apt-get update && apt-get install -y --no-install-recommends \
48+
libboost-graph1.83.0 libboost-system1.83.0 libyaml-cpp0.8 libczmq4 libjansson4 libhwloc15 \
49+
&& rm -rf /var/lib/apt/lists/*
50+
51+
COPY --from=builder /opt/flux-sched/resource /opt/flux-sched/resource
52+
COPY --from=builder /usr/lib/libresource.so* /usr/lib/
53+
COPY --from=builder /usr/lib/libreapi_cli.so* /usr/lib/
54+
COPY --from=builder /usr/lib/libjobspec_conv.so* /usr/lib/
55+
RUN ldconfig
56+
57+
COPY --from=builder /bin/fluence /bin/fluence
58+
ENTRYPOINT ["/bin/fluence"]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022-2023 LLNS, LLC and other HPCIC DevTools Developers.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# fluence — Kubernetes scheduler plugin backed by Fluxion (flux-sched), with
2+
# optional quantum resources modeled in the resource graph.
3+
#
4+
# The scheduler only schedules. It links flux-sched (the matcher) and does NOT
5+
# depend on QRMI — quantum job submission lives in a separate workload container
6+
# (github.com/converged-computing/qrmi-sampler), not here.
7+
8+
FLUX_SCHED_ROOT ?= /opt/flux-sched
9+
IMG ?= ghcr.io/converged-computing/fluence:latest
10+
11+
# cgo flags for the scheduler binary: flux-sched only.
12+
CGO_CFLAGS = -I$(FLUX_SCHED_ROOT)
13+
CGO_LDFLAGS = -L$(FLUX_SCHED_ROOT)/resource \
14+
-L$(FLUX_SCHED_ROOT)/resource/libjobspec \
15+
-L$(FLUX_SCHED_ROOT)/resource/reapi/bindings \
16+
-lresource -ljobspec_conv -lreapi_cli -lflux-idset \
17+
-lstdc++ -lczmq -ljansson -lhwloc -lboost_system \
18+
-lflux-hostlist -lboost_graph -lyaml-cpp
19+
20+
.PHONY: build
21+
build: ## Build the fluence scheduler binary (needs flux-sched)
22+
CGO_ENABLED=1 CGO_CFLAGS="$(CGO_CFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" \
23+
go build -o bin/fluence ./cmd/fluence
24+
25+
.PHONY: test
26+
test: ## Pure-Go unit tests (no flux, no k8s scheduler libs, no cluster)
27+
go test ./pkg/jgf/... ./pkg/cluster/... ./pkg/jobspec/... ./pkg/placement/... ./pkg/quantum/...
28+
29+
.PHONY: test-graph
30+
test-graph: ## Matcher tests (needs flux-sched)
31+
CGO_ENABLED=1 CGO_CFLAGS="$(CGO_CFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" \
32+
go test ./pkg/graph/...
33+
34+
.PHONY: image
35+
image: ## Build the scheduler container image
36+
docker build -t $(IMG) .
37+
38+
.PHONY: deploy
39+
deploy: ## Install RBAC + scheduler into kube-system
40+
kubectl apply -f deploy/fluence.yaml
41+
42+
.PHONY: help
43+
help:
44+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
45+
awk 'BEGIN{FS=":.*?## "}{printf " %-14s %s\n", $$1, $$2}'

NOTICE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
This work was produced under the auspices of the U.S. Department of
2+
Energy by Lawrence Livermore National Laboratory under Contract
3+
DE-AC52-07NA27344.
4+
5+
This work was prepared as an account of work sponsored by an agency of
6+
the United States Government. Neither the United States Government nor
7+
Lawrence Livermore National Security, LLC, nor any of their employees
8+
makes any warranty, expressed or implied, or assumes any legal liability
9+
or responsibility for the accuracy, completeness, or usefulness of any
10+
information, apparatus, product, or process disclosed, or represents that
11+
its use would not infringe privately owned rights.
12+
13+
Reference herein to any specific commercial product, process, or service
14+
by trade name, trademark, manufacturer, or otherwise does not necessarily
15+
constitute or imply its endorsement, recommendation, or favoring by the
16+
United States Government or Lawrence Livermore National Security, LLC.
17+
18+
The views and opinions of authors expressed herein do not necessarily
19+
state or reflect those of the United States Government or Lawrence
20+
Livermore National Security, LLC, and shall not be used for advertising
21+
or product endorsement purposes.

0 commit comments

Comments
 (0)