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
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@
^vignettes/articles$
^vignettes/examples$
^CRAN-SUBMISSION$
^\.context$
^Rplots\.pdf$
45 changes: 3 additions & 42 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,16 @@ jobs:
TORCH_INSTALL: 1
TORCH_TEST: 1
PYTORCH_ENABLE_MPS_FALLBACK: 1
LUZ_DISABLE_MPS: ${{ matrix.config.disable_mps|| 'FALSE' }}
LUZ_DISABLE_MPS: ${{ matrix.config.disable_mps || 'FALSE' }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
if: ${{ !contains(matrix.config.os, 'm1') }}
with:
r-version: ${{ matrix.config.r }}
use-public-rspm: true

- uses: r-lib/actions/setup-pandoc@v2
if: ${{ !contains(matrix.config.os, 'm1') }}
Expand All @@ -62,43 +63,3 @@ jobs:
with:
error-on: '"error"'
args: 'c("--no-multiarch", "--no-manual", "--as-cran")'

GPU:
runs-on: ['self-hosted', 'gpu']
name: 'gpu'
container: {image: 'nvidia/cuda:12.4.1-cudnn-devel-ubuntu22.04', options: '--gpus all --runtime=nvidia'}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
TORCH_INSTALL: 1
TORCH_TEST: 1
DEBIAN_FRONTEND: 'noninteractive'

steps:
- uses: actions/checkout@v2

- run: |
apt-get update -y
apt-get install -y sudo software-properties-common dialog apt-utils tzdata libpng-dev protobuf-compiler libprotobuf-dev

- uses: r-lib/actions/setup-r@v2

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r-dependencies@v2
with:
cache: false
extra-packages: any::rcmdcheck
needs: check

- run: |
print(torch::torch_is_installed())
install.packages('tfevents')
library(tfevents)
shell: Rscript {0}

- uses: r-lib/actions/check-r-package@v2
with:
error-on: '"error"'
args: 'c("--no-multiarch", "--no-manual", "--as-cran")'
16 changes: 13 additions & 3 deletions .github/workflows/test-coverage-pak.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ name: test-coverage
jobs:
test-coverage:

runs-on: ['self-hosted', 'gpu-local']
concurrency:
group: gpu-tests
cancel-in-progress: false
runs-on:
- "runs-on=${{ github.run_id }}/family=g4dn.xlarge/image=ubuntu24-gpu-x64/spot=true"

container:
image: nvidia/cuda:12.4.1-cudnn-devel-ubuntu22.04
image: nvidia/cuda:12.8.1-cudnn-devel-ubuntu22.04
options: --gpus all

env:
Expand All @@ -26,20 +30,26 @@ jobs:
DEBIAN_FRONTEND: 'noninteractive'

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- run: |
apt-get update -y
apt-get install -y sudo software-properties-common dialog apt-utils tzdata protobuf-compiler libprotobuf-dev

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
cache: false
extra-packages: any::rcmdcheck
needs: check

- name: Run tests
run: testthat::test_local()
shell: Rscript {0}

- name: Test coverage
run: covr::codecov()
shell: Rscript {0}
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
Package: luz
Title: Higher Level 'API' for 'torch'
Version: 0.5.1.9000
Version: 0.5.2
Authors@R: c(
person("Daniel", "Falbel", email = "daniel@rstudio.com", role = c("aut", "cre", "cph")),
person("Tomasz", "Kalinowski", role = c("ctb", "cre"), email = "tomasz@posit.co"),
person("Daniel", "Falbel", email = "dfalbel@gmail.com", role = c("aut", "cph")),
person("Christophe", "Regouby", email = "christophe.regouby@free.fr", role = c("ctb")),
person(family = "RStudio", role = c("cph"))
)
Expand All @@ -16,7 +17,7 @@ License: MIT + file LICENSE
URL: https://mlverse.github.io/luz/, https://github.com/mlverse/luz
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
RoxygenNote: 7.3.3
Imports:
torch (>= 0.11.9000),
magrittr,
Expand Down
7 changes: 6 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# luz (development version)
# luz 0.5.2

* New maintainer: Tomasz Kalinowski.
* Switched CI GPU runners to ephemeral runs-on instances.
* Bumped CI CUDA container to 12.8.1.
* Fixed bugs in example vignettes (`mnist-vae`, `text-generation`).

# luz 0.5.1

Expand Down
8 changes: 8 additions & 0 deletions man/evaluate.Rd

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

2 changes: 1 addition & 1 deletion vignettes/examples/mnist-vae.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ model <- autoencoder |>
preds <- predict(model, data)

df <- as.data.frame(as.matrix(preds))
df$labels <- sapply(seq_len(length(mnist)), \(i) mnist[i]$y)
df$labels <- sapply(seq_len(length(data)), \(i) data[i]$y)

# Visualization ------------------------------------------------------------

Expand Down
3 changes: 2 additions & 1 deletion vignettes/examples/text-generation.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class from the [Hugging Face NLP course](https://huggingface.co/learn/nlp-course
library(torch)
library(tok)
library(luz)
library(dotty)
library(minhub) # remotes::install_github("mlverse/minhub")
#library(tidyverse)
options(arrow.skip_nul = TRUE)
Expand Down Expand Up @@ -204,7 +205,7 @@ net <- nn_module(
for (i in seq_len(iter)) {
logits <- self$forward(x)[,,-1]
logits <- logits/temperature
c(prob, ind) %<-% logits$topk(top_k)
.[prob, ind] <- logits$topk(top_k)
logits <- torch_full_like(logits, -Inf)$scatter_(-1, ind, prob)
logits <- nnf_softmax(logits, dim = -1)
id_next <- torch_multinomial(logits, num_samples = 1)
Expand Down
Loading