Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Files that don't need to be in the Docker build context
.git
target/
.github/
docs/
*.md
*.png
*.svg
*.pdf

# Python artefacts
__pycache__/
*.pyc
*.pyo
.venv/
venv/

# Editor / OS
.DS_Store
*.swp
*.swo
64 changes: 63 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,71 @@ jobs:
- name: Run PHY Level-2 baseline comparison tests
run: cargo test -p sixg-phy --features=baseline-comparison

# ── Feature matrix: verify every tier builds cleanly ─────────────────────
matrix-features:
name: Feature matrix (${{ matrix.features }})
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
matrix:
features:
- "" # default (core tier — no features)
- "baseline-comparison"
- "plotting"
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Build with features "${{ matrix.features }}"
run: |
if [ -z "${{ matrix.features }}" ]; then
cargo build --workspace
else
cargo build --workspace --features "${{ matrix.features }}"
fi
- name: Test with features "${{ matrix.features }}"
run: |
if [ -z "${{ matrix.features }}" ]; then
cargo test --workspace
else
cargo test --workspace --features "${{ matrix.features }}"
fi

# ── Docker build (core tier) — publish to ghcr.io on push to main ────────
docker-build:
name: Docker build (core tier)
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build (and push on main)
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
tags: |
ghcr.io/${{ github.repository }}:latest
ghcr.io/${{ github.repository }}:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max

final-check:
name: Final Check (format + doc-sync)
runs-on: ubuntu-latest
needs: [test, clippy, fmt, doc-sync, dep-graph, baseline-comparison]
needs: [test, clippy, fmt, doc-sync, dep-graph, baseline-comparison, matrix-features]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
Expand All @@ -91,3 +152,4 @@ jobs:
run: cargo fmt --all -- --check
- name: Verify doc-code sync
run: python3 scripts/check_doc_sync.py

17 changes: 17 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ license.workspace = true
name = "sixg"
path = "src/main.rs"

[[bin]]
name = "sixg-bench"
path = "src/bin/bench.rs"

[[example]]
name = "exp_001_dfrc_pareto_frontier"
path = "experiments/exp_001_dfrc_pareto_frontier/run.rs"
Expand Down Expand Up @@ -61,6 +65,19 @@ tracing-subscriber.workspace = true
serde.workspace = true
serde_json.workspace = true

[features]
## Core tier: zero native dependencies. Always enabled.
default = []
## Baseline tier: enable Level-2 CSV baseline comparison tests in 6g-phy.
## Activate with: cargo build --features=baseline-comparison
baseline-comparison = ["sixg-phy/baseline-comparison"]
## ONNX tier: gate real ort-based ONNX sentence-transformer inference.
## Requires libonnxruntime and a model file. See install.sh --onnx.
onnx = ["sixg-ai/onnx", "sixg-semantic/onnx"]
## Plotting tier: compile-time marker enabling CSV / JSON artefact output.
## Python plots are handled separately via scripts/plot_*.py.
plotting = []

[workspace]
resolver = "2"
members = [
Expand Down
47 changes: 47 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# ── Stage 1: builder ──────────────────────────────────────────────────────────
# Uses the official Rust slim image so cargo + rustc are pre-installed.
FROM rust:1.87-slim AS builder

WORKDIR /build

# Cache dependency downloads before copying source.
COPY Cargo.toml Cargo.lock ./
COPY crates/ crates/
COPY src/ src/
COPY experiments/ experiments/

# Build the sixg-bench binary and all example experiment binaries.
RUN cargo build --release \
&& cargo build --release --examples

# ── Stage 2: runtime ──────────────────────────────────────────────────────────
# Minimal Debian image — no Rust toolchain, only the compiled artefacts.
FROM debian:bookworm-slim AS runtime

LABEL org.opencontainers.image.title="sixg-bench" \
org.opencontainers.image.description="Standalone 6G simulation bench" \
org.opencontainers.image.source="https://github.com/j143/6g" \
org.opencontainers.image.licenses="Apache-2.0"

RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /bench

# Copy the bench binary.
COPY --from=builder /build/target/release/sixg-bench /usr/local/bin/sixg-bench

# Copy all pre-built experiment binaries.
COPY --from=builder /build/target/release/examples/ /bench/target/release/examples/

# Copy experiment config files (read by the bench at runtime).
COPY experiments/ /bench/experiments/

# Copy bundled baseline CSV files.
COPY baselines/ /bench/baselines/

ENV SIXG_BASELINES=/bench/baselines

ENTRYPOINT ["sixg-bench"]
CMD ["--help"]
56 changes: 56 additions & 0 deletions Dockerfile.onnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# ── Stage 1: builder (ONNX tier) ─────────────────────────────────────────────
FROM rust:1.87-slim AS builder

# ort (ONNX Runtime Rust bindings) requires libonnxruntime.
# The build-time auto-download fetches it into /usr/local/lib.
ENV ORT_DYLIB_PATH=/usr/local/lib
ENV LIBONNXRUNTIME_URL=https://github.com/microsoft/onnxruntime/releases/download/v1.18.0/onnxruntime-linux-x64-1.18.0.tgz

RUN apt-get update && apt-get install -y --no-install-recommends \
curl tar pkg-config libssl-dev \
&& rm -rf /var/lib/apt/lists/* \
&& curl -fsSL "$LIBONNXRUNTIME_URL" -o /tmp/ort.tgz \
&& tar -xzf /tmp/ort.tgz -C /tmp \
&& cp /tmp/onnxruntime-linux-x64-*/lib/libonnxruntime.so* /usr/local/lib/ \
&& ldconfig \
&& rm -rf /tmp/ort.tgz /tmp/onnxruntime-linux-x64-*

WORKDIR /build

COPY Cargo.toml Cargo.lock ./
COPY crates/ crates/
COPY src/ src/
COPY experiments/ experiments/

# Build with the full onnx feature tier.
RUN cargo build --release --features=onnx \
&& cargo build --release --examples --features=onnx

# ── Stage 2: runtime (ONNX tier) ─────────────────────────────────────────────
FROM debian:bookworm-slim AS runtime

LABEL org.opencontainers.image.title="sixg-bench (ONNX tier)" \
org.opencontainers.image.description="6G bench with real ONNX sentence-transformer" \
org.opencontainers.image.source="https://github.com/j143/6g" \
org.opencontainers.image.licenses="Apache-2.0"

RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates libgomp1 \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /bench

COPY --from=builder /usr/local/lib/libonnxruntime.so* /usr/local/lib/
RUN ldconfig

COPY --from=builder /build/target/release/sixg-bench /usr/local/bin/sixg-bench
COPY --from=builder /build/target/release/examples/ /bench/target/release/examples/
COPY experiments/ /bench/experiments/
COPY baselines/ /bench/baselines/

ENV SIXG_BASELINES=/bench/baselines
# Mount your .onnx model file at this path to enable real inference:
ENV SIXG_ONNX_MODEL=/bench/models/all-MiniLM-L6-v2.onnx

ENTRYPOINT ["sixg-bench"]
CMD ["--help"]
65 changes: 60 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,50 @@
A Rust skeleton for a 6G wireless system stack, inspired by
[Qualcomm's 6G System Architecture research](https://www.qualcomm.com/research/6g/system-architecture).

## Quickstart (30 seconds)

```bash
git clone https://github.com/j143/6g && cd 6g
./install.sh # installs Rust if needed, builds the bench
./target/release/sixg-bench list # list all experiments
./target/release/sixg-bench run --all # run all 9 experiments
./target/release/sixg-bench validate # run all Validate checks
```

### With optional packages

```bash
./install.sh --baselines # + Level-2 CSV baseline comparisons
./install.sh --plotting # + Python matplotlib plots
./install.sh --onnx # + real ONNX sentence-transformer inference
./install.sh --all # everything above
```

### Docker (zero-install)

```bash
# Core bench
docker run --rm ghcr.io/j143/6g sixg-bench run --all

# With baseline comparisons
docker-compose run bench-baselines

# With ONNX inference (place models/all-MiniLM-L6-v2.onnx in repo root first)
docker-compose run bench-onnx
```

### Plotting

```bash
pip install -r requirements-plot.txt
python3 scripts/plot_phy.py # PHY: path loss + BER curves
python3 scripts/plot_mac.py # MAC: Jain fairness + HARQ rounds
python3 scripts/plot_isac.py # ISAC: DFRC Pareto frontier
python3 scripts/plot_semantic.py # Semantic: compression vs task success
```

---

## Architecture

The workspace is organised as a set of Cargo crates, each representing a
Expand Down Expand Up @@ -83,18 +127,29 @@ Cross-cutting subsystems

### Prerequisites

* Rust 1.70 or later (`rustup update stable`)
* Rust 1.70 or later (the `install.sh` script installs it automatically if absent)

### One-command setup

```bash
./install.sh
./target/release/sixg-bench --help
```

### Build
### Manual build

```bash
cargo build
cargo build --release
./target/release/sixg-bench list
```

### Run
### Run experiments

```bash
cargo run
cargo run --example exp_001_dfrc_pareto_frontier
cargo run --example exp_002_phy_baseline_comparison
# … or run all via the bench:
./target/release/sixg-bench run --all
```

### Test
Expand Down
6 changes: 6 additions & 0 deletions crates/6g-ai/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@ license.workspace = true
sixg-common = { path = "../6g-common" }
thiserror.workspace = true
serde.workspace = true

[features]
## ONNX tier: enable real ort-based ONNX inference.
## Requires libonnxruntime.so and a model file; see install.sh --onnx.
## Without this feature the built-in deterministic simulation is used.
onnx = []
23 changes: 12 additions & 11 deletions crates/6g-ai/src/onnx_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@
//! a 128-dimensional word-hash feature vector to a 32-dimensional L2-normalised
//! semantic embedding.
//!
//! ## Why simulate rather than use the ONNX runtime?
//! ## Simulation vs real ONNX runtime
//!
//! The `ort` crate requires a native `libonnxruntime` shared library and a
//! pre-trained model file — both are infeasible to bundle in a pure-Rust
//! workspace CI. This module implements the same **interface** as a real ONNX
//! model so that:
//! **Without `--features=onnx`** (default): the built-in deterministic MLP
//! simulation is used — no native library or model file is required.
//!
//! 1. The API is stable and ready to swap in `ort::Session` when the runtime
//! and model file are available (see `docs/6g-ai.md`).
//! 2. The closed-form approximation produces semantically-informed embeddings
//! (similar texts → similar embeddings via shared word-hash features) without
//! a runtime dependency.
//! **With `--features=onnx`**: the `onnx` feature flag is set, and
//! `cfg!(feature = "onnx")` is `true` at runtime. Callers that want to
//! swap in `ort::Session` (the real ONNX Runtime) should check this flag
//! and load the model file from the path in `SIXG_ONNX_MODEL`. The
//! public API ([`OnnxModel::forward`], [`AiModel::predict`]) is identical
//! in both modes so downstream code needs no changes.
//!
//! ## Mathematical model
//! See `install.sh --onnx` and `docs/6g-ai.md` for the setup steps.
//!
//! ## Mathematical model (simulation)
//!
//! ```text
//! x ← 128-dim L2-normalised word-hash feature vector (f32)
Expand Down
4 changes: 2 additions & 2 deletions crates/6g-core/src/nrf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ impl Nrf {
.values()
.filter(|p| p.nf_type == nf_type && p.active)
.collect();
matches.sort_by(|a, b| b.capacity.cmp(&a.capacity));
matches.sort_by_key(|b| std::cmp::Reverse(b.capacity));
matches
}

Expand All @@ -185,7 +185,7 @@ impl Nrf {
.values()
.filter(|p| p.active && p.has_capability(capability))
.collect();
matches.sort_by(|a, b| b.capacity.cmp(&a.capacity));
matches.sort_by_key(|b| std::cmp::Reverse(b.capacity));
matches
}

Expand Down
4 changes: 4 additions & 0 deletions crates/6g-semantic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ sixg-common = { path = "../6g-common" }
sixg-ai = { path = "../6g-ai" }
thiserror.workspace = true
serde.workspace = true

[features]
## Propagate the ONNX tier from 6g-ai.
onnx = ["sixg-ai/onnx"]
Loading
Loading