Wasserstein Index Generation (WIG) Model
Overview
Efficient implementation of several Optimal Transport algorithms in Fangzhou Xie (2025) doi:10.48550/arXiv.2504.08722 and the Wasserstein Index Generation (WIG) model in Fangzhou Xie (2020) doi:10.1016/j.econlet.2019.108874.
Performance work driven by perf profiles; all solver outputs are checked
against frozen outputs of version 0.2.0 (relative differences below 1e-11)
and the Julia-derived reference solutions in the tests.
wdl()/wig()on the CPU now predict the document barycenters with the same batched Gibbs-kernel iteration the training uses, on a whole batch of documents at once. Before, inference solved one barycenter per document and, with the defaultmethod = "auto", did so in the log domain, which cost about 20 times the whole training (2000 NYT headlines, 1 epoch: 33 minutes, now 33 seconds).method,thresholdandn_threadsof the barycenter control are documented as unused by WDL.- The log-stabilized
sinkhorn()andbarycenter()exponentiate with a vectorised rational approximation (1-2 ulp ofexp()) instead of one libm call per matrix entry, and logsinkhorn()no longer computes a column soft-min per iteration whose only use, the column term of the error, is identically zero. 1000 x 1000 log Sinkhorn, 1000 iterations: 19 s to 8 s on one thread.
Show all changes in 0.3.0Hide the rest of the changes in 0.3.0
- Worker threads (
n_threads) spin briefly between the short parallel sections of an iteration instead of sleeping; 12 threads now give about 5x on the forward passes where they gave 3x. - The backward passes of the log-stabilized
sinkhorn()andbarycenter()(with_grad = TRUE) no longer materialize the M x N softmax matrices: the forward pass keeps its row and column soft-mins (M + N numbers per iteration), from which each adjoint product is one fused sweep over the cost matrix, split over the threads by column blocks. 1000 x 1000 log Sinkhorn with gradient, 1000 iterations: 15.6 s to 13.2 s on one thread, 3.8 s to 2.1 s on 12; 800 x 800 log barycenter with gradients: 37.9 s to 33.9 s and 10.9 s to 5.2 s. - Kernel products with up to 4 right-hand columns (the "parallel"
barycenter()) use onedsymv/dgemvper column rather than a level-3 call that repacks the N x N kernel every time: 800 x 800 barycenter with 4 sources, 0.79 s to 0.34 s. - CUDA
wdl(): the per-documentcublasDgemvlaunches of the weight adjoint are one strided-batched GEMM (2000 headlines: 5.6 s to 4.5 s).
From NEWS.md in the release
Install
Health
- OK13 OK2026-08-04
- NOTE12 OK, 1 NOTE2026-08-01
- OK13 OK2026-05-02
- NOTE10 OK, 1 NOTE2026-04-25
- ERROR6 OK, 1 NOTE, 1 ERROR2026-04-22
Documentation
- Help pages
- 9 (1 internal)includes a package overview page
- Examples that run
- 100%6 run in a plain check
- Exported functions with examples
- 86%
- Documented parameters
- 59%
- Return-value docs
- 100%
- Help pages citing references
- 78%
- Barycenter Algorithms HTML
- Computation of the Gradients HTML
- CUDA Acceleration HTML
- Multi-threading Support HTML
- Sinkhorn Algorithms HTML
- Truncated SVD HTML
- WDL and WIG Model Specs HTML
- WDL Model HTML
- WIG Model HTML
Downloads
Repository
Stars over time
Commits over time
11 development-tooling and community-health practices detected across 6 families in the upstream repository
Checks run against github.com/fangzhou-xie/rwig on 2026-10-18.
The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel
GitHub Pages site last deployed 2026-10-07 · The repository has a site deploy workflow
pkgdown site last built 2026-10-07
Show all practicesHide 2 practices
This repository shows signs of AI coding tools.
- Claude Codefirst seen 2026-03-06Named in .Rbuildignore: .claudeNamed in .gitignore: .claudeCommits: at least 25 crediting it in the message
- Claude Fable 5.125 commits · Sep to Oct 2026
Dependencies
Installing rwig adds 10 packages (7 with compiled code, 16 MB of source tarballs). Heaviest: stringi 11 MB, Rcpp 1.8 MB, rlang 766 KB.
Code & Tests
Datasets
People & History
Package metadata
- First published
- 2026-04-21
- Total releases
- 3 / 1 yrs
- License
- MIT + file LICENSE OSI
- Minimum R
- ≥ 4.2
- Bundled data
- 343 KB / 1 file
- Download size
- 478 KB
Cite
Cite this package
Run in R for the authors' preferred citation:
citation("rwig")This package has no citation file, so citation() returns this entry built from DESCRIPTION.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-21, which the citation names so these numbers can be found later. More on citing and the projects behind them.