Benchmark based on py_r_torch_benchmarking, related to mlverse/torch#1435.
- Machine: Apple Silicon (arm64), macOS Darwin 24.5.0
- R: 4.5.2
- Python: 3.13 (via uv)
- PyTorch: 2.8.0
Benchmark based on py_r_torch_benchmarking, related to mlverse/torch#1435.
# Benchmark: overhead of async+await vs the sync C++ path
#
# Both paths end up calling the same PJRT C API, but the sync path
# awaits in C++ while async+await does it through R. This measures the
# R-side overhead difference to decide if the dedicated sync path is worth keeping.
#
# Usage: Rscript bench/bench-async-vs-sync.R
library(pjrt)This is a Guild AI runs repository. To access runs, install Guild AI and run guild pull gist:dfalbel/denoising. For more information about Guild AI Gist based repositories, see Guild AI - Gists.
This is a Guild AI runs repository. To access runs, install Guild AI and run guild pull gist:dfalbel/denoising-diffusion-runs. For more information about Guild AI Gist based repositories, see Guild AI - Gists.
| library(torch) | |
| dat <- dataset( | |
| "mydataset", | |
| initialize = function(time, size, len = 100 * 32) { | |
| self$time <- time | |
| self$len <- len | |
| self$size <- size | |
| }, | |
| .getitem = function(i) { |
| library(keras) | |
| library(tensorflow) | |
| input <- layer_input(shape = list(365, 10)) | |
| representation <- input %>% | |
| layer_lstm(units = 32, input_shape = list(365, 10)) %>% | |
| layer_dropout(rate = 0.2) | |
| output1 <- representation %>% | |
| layer_dense(units = 2, name = "out1") |
| library(torch) | |
| library(ggplot2) | |
| # we want to find the minimum of this function | |
| # using the gradient descent. | |
| f <- function(x) { | |
| x^2 - x | |
| } |
| todoist_token <- config::get("TODOIST_TOKEN") | |
| get_tasks_week <- function(week = 0, offset = 0) { | |
| res <- httr::POST( | |
| url = "https://api.todoist.com/sync/v8/activity/get", | |
| body = list( | |
| token = todoist_token, | |
| limit = 100, | |
| page = week, |
| --- | |
| title: "Quora Question Pairs" | |
| output: | |
| flexdashboard::flex_dashboard: | |
| orientation: columns | |
| runtime: shiny | |
| --- | |
| ```{r global, include=FALSE} | |
| library(keras) |