Skip to content
Open

Vbq #45

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
3f58d98
Sketch of `EmpiricalDistribution`s
robamler Nov 27, 2023
6b439e7
Start own implementation of an augmented B-tree
robamler Nov 28, 2023
e02c014
refactor AugmentedBTree::insert
robamler Nov 29, 2023
c3d4ac0
First draft of AugmentedBTree::insert
robamler Nov 30, 2023
824b18a
Divide `augmented_btree` into submoduls
robamler Nov 30, 2023
190d68c
AugmentedBTree: rename `key` to `pos`
robamler Nov 30, 2023
2f1b671
Tests + fixes for `AugmentedBTree::{insert, cdf}`
robamler Nov 30, 2023
87087a5
Fix ownership issue in `AugmentedBTree` pointers
robamler Dec 1, 2023
6efaea8
Implement `AugmentedBTree::quantile_function`
robamler Dec 2, 2023
f30d329
More unit tests for `AugmentedBTree`
robamler Dec 2, 2023
449b186
Minor cleanup
robamler Dec 2, 2023
0acb60a
Simplify `AugmentedBTree`
robamler Dec 2, 2023
e7b13a5
Add missing `impl Drop for BoundedVec`
robamler Dec 2, 2023
1c40222
Minor cleanups
robamler Dec 3, 2023
17578be
Reimplementation of `BoundedVec`
robamler Dec 3, 2023
9d7e348
(breaking change) check assertions at compile time
robamler Oct 15, 2023
a2170ef
First draft of `AugmentedBTree::remove`
robamler Dec 6, 2023
2ea78f7
Nicer `NonLeafNode::leak_raw_parts`
robamler Dec 7, 2023
c924f8b
Unify representation of nodes in `AugmentedBTree`
robamler Dec 8, 2023
c405eb3
More unit tests for `remove`
robamler Dec 10, 2023
69e2241
Fix bugs in `remove` and add extensive unit tests
robamler Dec 10, 2023
6cc9084
Clean up tests
robamler Dec 11, 2023
85a33e3
Add benchmarks for `AugmentedBtree`
robamler Dec 11, 2023
c541219
Draft of new `DynamicEmpiricalDistribution`
robamler Dec 11, 2023
ec8e3db
Sketch VBQ with `DynamicEmpiricalDistribution`
robamler Dec 12, 2023
d19e5ed
`AugmentedBTree`: make closures `move`
robamler Dec 15, 2023
a617273
Implement a dedicated `AugmentedBTree::shift`
robamler Dec 15, 2023
482698b
Sketch Python API for VBQ
robamler Dec 21, 2023
6c235a1
Remove `AugmentedBTree::shift` & fix clippy lints
robamler Dec 21, 2023
3ea1be0
Better error handling in `AugmentedBTree`
robamler Dec 21, 2023
3b97d0c
Fix warnings in release mode
robamler Dec 21, 2023
3aec8d6
Fix 64/32-bit-issue on windows
robamler Dec 21, 2023
61fa29e
Improve Python API for VBQ
robamler Dec 21, 2023
97c1bf9
Fix compilation of benchmarks in CI
robamler Dec 21, 2023
a453172
Fix `reference` in VBQ for python
robamler Dec 21, 2023
cef2094
Fix excessive run times of some new miri tests
robamler Dec 21, 2023
8dcc071
Merge branch 'main' into vbq
robamler Dec 23, 2023
606f659
Split up python API for `quant`
robamler Dec 25, 2023
d408c35
Add not-in-place variant of VBQ to python API
robamler Dec 26, 2023
185be26
Allow element-specific variance in Python API for VBQ
robamler Dec 27, 2023
bc1d059
Make VBQ generic over distortion function
robamler Dec 27, 2023
5597784
Simplify & document rust interface to VBQ
robamler Dec 28, 2023
66ea3f1
Merge branch 'main' into vbq
robamler Dec 30, 2023
4f509a7
Fix "bench" github workflow
robamler Jan 1, 2024
84a42fc
Parallelize VBQ in python where trivially possible
robamler Jan 10, 2024
3fa82f1
Improve documentation of traits in `quant`
robamler Jan 17, 2024
5ba3ebf
Slightly improve rust API for empirical distributions
robamler Jan 17, 2024
5a6018b
Add test for VBQ with prior from `probability` crate
robamler Jan 17, 2024
85f6d9a
Python: VBQ with multiplexed prior
robamler Feb 7, 2024
12176c8
Fix clippy lints
robamler Feb 7, 2024
0363c0f
Merge branch 'main' into vbq
robamler Feb 7, 2024
b6d2ee5
Document rust API for `EmpiricalDistribution`
robamler Feb 8, 2024
802fc0c
Merge branch 'main' into vbq
robamler Feb 9, 2024
898c6af
Document `quant` module of python API
robamler Feb 10, 2024
b8e986e
Add python tests for module `quant`
robamler Feb 10, 2024
477c68d
Add tests for return value of `AugmentedBTree::remove`
robamler Feb 10, 2024
f7070aa
Fix `AugmentedBTree::remove`
robamler Feb 10, 2024
776ff3d
Implement `EmpiricalDistribution::remove_all`
robamler Feb 11, 2024
d58ad46
Change API of `EmpiricalDistribution::remove`
robamler Feb 11, 2024
0d3eb7b
Allow adding/removing multiple points to/from `EmpiricalDistribution`
robamler Feb 11, 2024
9c7523b
Python: implement `EmpiricalDistribution::shift`
robamler Feb 12, 2024
69967a3
Allow constructing `EmpiricalDistribution` from `points` and `counts`
robamler Feb 12, 2024
a843e91
Python: document and test `EmpiricalDistribution::shift`
robamler Feb 12, 2024
51fea02
Python: remove pitfall from `EmpiricalDistribution::shift`
robamler Feb 12, 2024
c81e0c1
Merge branch 'main' into vbq
robamler Feb 12, 2024
22aeff7
Add some `#[cold]` attributes
robamler Feb 12, 2024
a572295
First draft of `rate_distortion_quantization`
robamler Feb 13, 2024
c9e9ff3
Factor out `quant::FromPoints`
robamler Feb 16, 2024
3c7ba39
Factor out `quant::QuantizationMethod`
robamler Feb 16, 2024
0570309
Refactor pybindings for `quant`
robamler Feb 18, 2024
d7a72f7
Python frontend for `RatedGrid` + RD quantization
robamler Feb 18, 2024
81ca5ba
Make impls of `EmpiricalDistribution` generic over `CAP`
robamler Feb 19, 2024
5ecb2be
Docs + python tests for `RatedGrid` and rd-quantization
robamler Feb 19, 2024
099df1c
Merge branch 'main' into vbq
robamler Feb 19, 2024
deebfbd
Fix typo in documentation
robamler Feb 19, 2024
2564278
Merge branch 'main' into vbq
robamler Feb 20, 2024
e59fe9e
Implement `quant::DynamicRatedGrid`
robamler Feb 29, 2024
0a69e64
Python: add `reference` argument to R/D-quant
robamler Feb 29, 2024
366068c
Python: add `RatedGrid.{insert, remove, update}`
robamler Mar 1, 2024
93e6c32
Remove unnecessary imports in tests
robamler Mar 1, 2024
7f10d29
Merge branch 'main' into vbq
robamler Mar 1, 2024
aa48145
Don't include unused code for miri
robamler Mar 1, 2024
e1cb36c
Fix documentation of static assertions
robamler Jun 15, 2024
0c94674
Merge branch 'main' into vbq
robamler Aug 29, 2024
b643631
Address new clippy lints
robamler Aug 29, 2024
7d2af32
Merge branch 'main' into vbq
robamler Aug 29, 2024
c388356
Add test that `AugmentedBTree` is Send + Sync
robamler Oct 18, 2024
bc9282d
Merge branch 'main' into vbq
robamler Oct 25, 2024
4cda62f
Port `pybindings::quant` to PyO3 version 0.22
robamler Oct 25, 2024
3efe975
Merge branch 'simplify-pybindings' into vbq
robamler Oct 25, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/bench.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
uses: dtolnay/rust-toolchain@stable

- name: Rust Benchmark
run: cargo bench
run: cargo bench --features benchmark-internals
6 changes: 3 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ jobs:
- name: Test in development mode
env:
RUSTFLAGS: "-D warnings"
run: cargo test
run: cargo test --features benchmark-internals

- name: Test in release mode
env:
RUSTFLAGS: "-D warnings"
run: cargo test --release
run: cargo test --release --features benchmark-internals

- name: "Install cargo-msrv"
uses: taiki-e/install-action@v2
Expand Down Expand Up @@ -115,7 +115,7 @@ jobs:
env:
RUSTFLAGS: "-Zrandomize-layout"
MIRIFLAGS: "-Zmiri-symbolic-alignment-check -Zmiri-disable-isolation"
run: cargo +${{ steps.rust-version.outputs.rustc }} miri test --no-fail-fast
run: cargo +${{ steps.rust-version.outputs.rustc }} miri test --no-fail-fast --features benchmark-internals

python-test:
runs-on: ${{ matrix.os }}
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
- name: Lint with clippy
env:
RUSTFLAGS: "-D warnings"
run: cargo clippy --all-targets --all-features
run: cargo clippy --all-features

# The environment variable `RUSTFLAGS` doesn't actually seem to have any effect on rustdoc,
# but we set it here to the same value as in all other cargo runs as changing it would
Expand All @@ -61,19 +61,19 @@ jobs:
- name: Test in development mode
env:
RUSTFLAGS: "-D warnings"
run: cargo test
run: cargo test --features benchmark-internals

- name: Test in release mode
env:
RUSTFLAGS: "-D warnings"
run: cargo test --release
run: cargo test --release --features benchmark-internals

- name: "Install cargo-msrv"
uses: taiki-e/install-action@v2
if: matrix.os != 'windows-latest' # work around https://github.com/foresterre/cargo-msrv/issues/1036
with:
tool: cargo-msrv

- name: "Verify minimum supported rust version (MSRV)"
if: matrix.os != 'windows-latest' # work around https://github.com/foresterre/cargo-msrv/issues/1036
run: cargo msrv verify -- cargo check --all-features
Expand Down Expand Up @@ -140,7 +140,7 @@ jobs:
env:
RUSTFLAGS: "-Zrandomize-layout"
MIRIFLAGS: "-Zmiri-symbolic-alignment-check -Zmiri-disable-isolation"
run: cargo +${{ steps.rust-version.outputs.rustc }} miri test --no-fail-fast
run: cargo +${{ steps.rust-version.outputs.rustc }} miri test --no-fail-fast --features benchmark-internals

python-test:
runs-on: ${{ matrix.os }}
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"cSpell.words": [
"accums",
"gaussian",
"laplace",
"parameterizable",
Expand Down
32 changes: 31 additions & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,21 @@
"clear": true
},
},
{
"type": "cargo",
"command": "test",
"args": [
"--doc"
],
"problemMatcher": [
"$rustc"
],
"group": "build",
"label": "rust: cargo test --doc",
"presentation": {
"clear": true
},
},
{
"type": "cargo",
"command": "bench",
Expand All @@ -91,7 +106,12 @@
"$rustc"
],
"group": "build",
"label": "cargo check with pybindings"
"label": "cargo check with pybindings",
"presentation": {
"focus": true,
"showReuseMessage": true,
"clear": true
},
},
{
"label": "Build Python module and start REPL",
Expand Down Expand Up @@ -124,6 +144,16 @@
"presentation": {
"clear": true
},
},
{
"label": "Test Python module (without rebuilding)",
"type": "shell",
"command": "poetry run pytest tests/python",
"group": "build",
"problemMatcher": [],
"presentation": {
"clear": true
},
}
]
}
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 20 additions & 17 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[package]
authors = ["Robert Bamler <[email protected]>"]
categories = ["compression", "science", "no-std"]
description = "Entropy coders for research and production (Rust and Python)."
documentation = "https://docs.rs/constriction/"
edition = "2018"
homepage = "https://bamler-lab.github.io/constriction/"
keywords = ["compression", "entropy-coding", "range-coding", "python", "machine-learning"]
license = "MIT OR Apache-2.0 OR BSL-1.0"
name = "constriction"
readme = "README-rust.md"
repository = "https://github.com/bamler-lab/constriction/"
authors = ["Robert Bamler <[email protected]>"]
categories = ["compression", "science", "no-std"]
description = "Entropy coders for research and production (Rust and Python)."
documentation = "https://docs.rs/constriction/"
edition = "2018"
homepage = "https://bamler-lab.github.io/constriction/"
keywords = ["compression", "entropy-coding", "range-coding", "python", "machine-learning"]
license = "MIT OR Apache-2.0 OR BSL-1.0"
name = "constriction"
readme = "README-rust.md"
repository = "https://github.com/bamler-lab/constriction/"
rust-version = "1.75" # for feature `return_position_impl_trait_in_traits`
version = "0.4.1"
version = "0.4.1"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -20,25 +20,27 @@ crate-type = ["rlib", "cdylib"]
name = "constriction"

[features]
benchmark-internals = []
default = ["std"]
std = []

# Use feature `pybindings` to compile the python extension module that provides
# access to this library from python. This feature is turned off by default
# because it causes problems with `cargo test` on Mac OS. To turn it on, run:
# cargo build --release --features pybindings
pybindings = ["numpy", "pyo3"]
pybindings = ["ndarray", "numpy", "pyo3", "rayon"]

[dependencies]
hashbrown = "0.15.0"
num-traits = {version = "0.2.15", default-features = false, features = ["libm"]}
smallvec = "1.6.1"

libm = "0.2.6"
num-traits = {version = "0.2.15", default-features = false, features = ["libm"]}
probability = "0.20"
smallvec = "1.6.1"

ndarray = {version = "0.16.1", features = ["rayon"], optional = true}
numpy = {version = "0.22", optional = true}
pyo3 = {version = "0.22.5", features = ["extension-module"], optional = true}
rayon = {version = "1.10.0", optional = true}

[dev-dependencies]
byteorder = "1.4.2"
Expand All @@ -49,5 +51,6 @@ rand_xoshiro = "0.6"

[[bench]]
harness = false
name = "lookup"
name = "bench"
required-features = ["benchmark-internals"]
test = true
Loading