-
-
Notifications
You must be signed in to change notification settings - Fork 39
Use touchstone #352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Use touchstone #352
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ce9689c
Barebones touchstone setup
VisruthSK faaca77
Generated tests
VisruthSK c73be4d
Fixed script calling
VisruthSK bb68267
Use wine data
VisruthSK b7c7719
Fixed typo
VisruthSK e61f350
Renamed file [no ci]
VisruthSK 672ec21
wine rds in touchstone dir for testing
VisruthSK 4b4020b
Typo
VisruthSK 8ddd1c3
Properly load the wine loglik for each benchmark run
VisruthSK 4e9c78e
Restored sysdata
VisruthSK 8af5a81
Scoped token perms
VisruthSK File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,3 +24,4 @@ vignettes/loo2-non-factorized_cache/* | |
| ^release-prep\.R$ | ||
| ^_pkgdown\.yml$ | ||
| ^pkgdown$ | ||
| ^touchstone$ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| name: Continuous Benchmarks (Comment) | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.head_ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| on: | ||
| workflow_run: | ||
| workflows: ["Continuous Benchmarks (Receive)"] | ||
| types: | ||
| - completed | ||
|
|
||
| jobs: | ||
| upload: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| actions: read | ||
| pull-requests: write | ||
| statuses: write | ||
| if: > | ||
| ${{ github.event.workflow_run.event == 'pull_request' }} | ||
| steps: | ||
| - uses: lorenzwalthert/touchstone/actions/comment@main | ||
| with: | ||
| GITHUB_TOKEN: ${{ github.token }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| name: Continuous Benchmarks (Receive) | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.head_ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| on: | ||
| pull_request: | ||
|
|
||
| jobs: | ||
| prepare: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| config: ${{ steps.read_touchstone_config.outputs.config }} | ||
| steps: | ||
| - name: Checkout repo | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - id: read_touchstone_config | ||
| run: | | ||
| echo "config=$(jq -c . ./touchstone/config.json)" >> $GITHUB_OUTPUT | ||
|
|
||
| build: | ||
| needs: prepare | ||
| runs-on: ${{ matrix.config.os }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| config: | ||
| - ${{ fromJson(needs.prepare.outputs.config) }} | ||
| steps: | ||
| - name: Checkout repo | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
| - uses: lorenzwalthert/touchstone/actions/receive@main | ||
| with: | ||
| r-version: ${{ matrix.config.r }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| library(brms) | ||
| library(loo) | ||
| options(brms.backend = "cmdstanr") | ||
| options(mc.cores = 4) | ||
|
|
||
| fitos <- read.delim("data-raw/winequality-red.csv", sep = ";") |> | ||
| unique() |> | ||
| scale() |> | ||
| as.data.frame() |> | ||
| brm( | ||
| ordered(quality) ~ ., | ||
| family = cumulative("logit"), | ||
| prior = prior(R2D2(mean_R2 = 1 / 3, prec_R2 = 3)), | ||
| data = _, | ||
| seed = 1, | ||
| silent = 2, | ||
| refresh = 0 | ||
| ) | ||
|
|
||
| saveRDS(log_lik(fitos), "touchstone/wine.rds") |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| * | ||
| !script.R | ||
| !config.json | ||
| !.gitignore | ||
| !header.R | ||
| !footer.R | ||
| !wine.rds |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "os": "ubuntu-22.04", | ||
| "r": "4.4.3", | ||
| "rspm": "https://packagemanager.posit.co/cran/__linux__/jammy/latest", | ||
| "benchmarking_repo": "", | ||
| "benchmarking_ref": "", | ||
| "benchmarking_path": "" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # You can modify the PR comment footer here. You can use github markdown e.g. | ||
| # emojis like :tada:. | ||
| # This file will be parsed and evaluate within the context of | ||
| # `benchmark_analyze` and should return the comment text as the last value. | ||
| # See `?touchstone::pr_comment` | ||
| link <- "https://lorenzwalthert.github.io/touchstone/articles/inference.html" | ||
| glue::glue( | ||
| "\nFurther explanation regarding interpretation and", | ||
| " methodology can be found in the [documentation]({link})." | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # You can modify the PR comment header here. You can use github markdown e.g. | ||
| # emojis like :tada:. | ||
| # This file will be parsed and evaluate within the context of | ||
| # `benchmark_analyze` and should return the comment text as the last value. | ||
| # Available variables for glue substitution: | ||
| # * ci: confidence interval | ||
| # * branches: BASE and HEAD branches benchmarked against each other. | ||
| # See `?touchstone::pr_comment` | ||
| glue::glue( | ||
| "This is how benchmark results would change (along with a", | ||
| " {100 * ci}% confidence interval in relative change) if ", | ||
| "{system2('git', c('rev-parse', 'HEAD'), stdout = TRUE)} is merged into {branches[1]}:\n" | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| # see `help(run_script, package = 'touchstone')` on how to run this | ||
| # interactively | ||
|
|
||
| # installs branches to benchmark | ||
| touchstone::branch_install() | ||
|
|
||
| touchstone::pin_assets("touchstone/wine.rds") | ||
|
|
||
| # These synthetic workloads are large enough to expose real slowdowns in the | ||
| # core `loo()` paths, but still short enough to keep PR feedback reasonably fast. | ||
| touchstone::benchmark_run( | ||
| expr_before_benchmark = { | ||
| suppressPackageStartupMessages(library(loo)) | ||
| # benchmark_run() evaluates in a callr subprocess, so load pinned assets here. | ||
| wine_log_lik_matrix <- readRDS(touchstone::path_pinned_asset( | ||
| "touchstone/wine.rds" | ||
| )) | ||
| matrix_r_eff <- rep(1, ncol(wine_log_lik_matrix)) | ||
| }, | ||
| loo_matrix = { | ||
| suppressWarnings( | ||
|
VisruthSK marked this conversation as resolved.
|
||
| loo( | ||
| wine_log_lik_matrix, | ||
| r_eff = matrix_r_eff, | ||
| cores = 1 | ||
| ) | ||
| ) | ||
| }, | ||
| n = 10 | ||
| ) | ||
|
|
||
| touchstone::benchmark_run( | ||
| expr_before_benchmark = { | ||
| suppressPackageStartupMessages(library(loo)) | ||
| wine_log_lik_matrix <- readRDS(touchstone::path_pinned_asset( | ||
| "touchstone/wine.rds" | ||
| )) | ||
| function_r_eff <- rep(1, ncol(wine_log_lik_matrix)) | ||
| wine_data <- data.frame(obs = seq_len(ncol(wine_log_lik_matrix))) | ||
| wine_llfun <- function(data_i, draws) draws[, data_i$obs, drop = FALSE] | ||
| }, | ||
| loo_function = { | ||
| suppressWarnings( | ||
|
jgabry marked this conversation as resolved.
|
||
| loo( | ||
| wine_llfun, | ||
| data = wine_data, | ||
| draws = wine_log_lik_matrix, | ||
| r_eff = function_r_eff, | ||
| cores = 1 | ||
| ) | ||
| ) | ||
| }, | ||
| n = 10 | ||
| ) | ||
|
|
||
| # create artifacts used downstream in the GitHub Action | ||
| touchstone::benchmark_analyze() | ||
Binary file not shown.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.