-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* remove modifying the saturation mode * Update environment.yml * update dockerfiles * update * update * pre-commit * contrib * update env * update widgets * black * Update _config.yml * headings * remove unneaded rounding/sat stuff, set trainging to true * fix incompatibilities in deployment * update docker * update hls4ml to 0.7.0 * update * clean up titles * docker publish * update docker images to tag * updaet docker locations --------- Co-authored-by: Javier Duarte <[email protected]>
- Loading branch information
Showing
27 changed files
with
1,569 additions
and
1,013 deletions.
There are no files selected for viewing
This file contains 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 @@ | ||
version: 2 | ||
updates: | ||
# Maintain dependencies for GitHub Actions | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" |
This file contains 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,52 @@ | ||
name: deploy-book | ||
|
||
# Only run this when the master branch changes | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
# This job installs dependencies, build the book, and pushes it to `gh-pages` | ||
jobs: | ||
deploy-book: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
# Install dependencies | ||
- name: Setup Miniconda | ||
uses: conda-incubator/setup-miniconda@v2 | ||
with: | ||
activate-environment: hls4ml-tutorial | ||
environment-file: environment.yml | ||
python-version: 3.10.10 | ||
auto-activate-base: false | ||
|
||
# Check dependencies | ||
- name: Check Miniconda | ||
shell: bash -l {0} | ||
run: | | ||
conda info | ||
conda list | ||
conda config --show-sources | ||
conda config --show | ||
printenv | sort | ||
- name: Build the book | ||
shell: bash -l {0} | ||
run: | | ||
jupyter contrib nbextension install --user | ||
jupyter nbextension enable --py widgetsnbextension | ||
jupyter-book build . | ||
- name: GitHub Pages action | ||
uses: peaceiris/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: _build/html | ||
force_orphan: true | ||
user_name: 'github-actions[bot]' | ||
user_email: 'github-actions[bot]@users.noreply.github.com' |
This file contains 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,35 @@ | ||
name: docker-publish | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- 'main' | ||
push: | ||
branches: | ||
- 'main' | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- | ||
name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- | ||
name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
push: ${{ github.event_name != 'pull_request' }} | ||
file: docker/Dockerfile | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
tags: | | ||
ghcr.io/${{ github.repository }}/hls4ml-0.7.0:latest | ||
ghcr.io/${{ github.repository }}/hls4ml-0.7.0:${{ github.sha }} |
This file contains 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 |
---|---|---|
@@ -1,3 +1,8 @@ | ||
.ipynb_checkpoints | ||
__pycache__ | ||
*~ | ||
*~ | ||
*.npy | ||
_build | ||
model_1 | ||
model_2 | ||
model_3 |
This file contains 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
This file contains 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,70 @@ | ||
exclude: .*\.rpt$ | ||
|
||
repos: | ||
- repo: https://github.com/psf/black | ||
rev: 22.12.0 | ||
hooks: | ||
- id: black-jupyter | ||
language_version: python3 | ||
args: ['--line-length=125', | ||
'--skip-string-normalization'] | ||
|
||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.4.0 | ||
hooks: | ||
- id: check-added-large-files | ||
- id: check-case-conflict | ||
- id: check-merge-conflict | ||
- id: check-symlinks | ||
- id: check-yaml | ||
- id: debug-statements | ||
- id: end-of-file-fixer | ||
- id: mixed-line-ending | ||
- id: requirements-txt-fixer | ||
- id: trailing-whitespace | ||
|
||
- repo: https://github.com/PyCQA/isort | ||
rev: 5.12.0 | ||
hooks: | ||
- id: isort | ||
args: ["--profile", "black", --line-length=125] | ||
|
||
- repo: https://github.com/asottile/pyupgrade | ||
rev: v3.3.1 | ||
hooks: | ||
- id: pyupgrade | ||
args: ["--py36-plus"] | ||
|
||
- repo: https://github.com/asottile/setup-cfg-fmt | ||
rev: v2.2.0 | ||
hooks: | ||
- id: setup-cfg-fmt | ||
|
||
- repo: https://github.com/pycqa/flake8 | ||
rev: 5.0.4 | ||
hooks: | ||
- id: flake8 | ||
exclude: docs/conf.py | ||
additional_dependencies: [flake8-bugbear, flake8-print] | ||
args: ['--max-line-length=125', # github viewer width | ||
'--extend-ignore=E203,T201'] # E203 is not PEP8 compliant | ||
|
||
- repo: https://github.com/mgedmin/check-manifest | ||
rev: "0.49" | ||
hooks: | ||
- id: check-manifest | ||
stages: [manual] | ||
|
||
- repo: https://github.com/jmduarte/p-clang-format | ||
rev: "v1.0.4" | ||
hooks: | ||
- id: p-clang-format | ||
types_or: [c++, c, cuda] | ||
ci: | ||
autofix_commit_msg: '[pre-commit.ci] auto fixes from pre-commit hooks' | ||
autofix_prs: false # default is true | ||
autoupdate_branch: 'main' | ||
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate' | ||
autoupdate_schedule: weekly | ||
skip: [] | ||
submodules: true |
This file contains 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 |
---|---|---|
@@ -1,34 +1,69 @@ | ||
# hls4ml-tutorial | ||
Tutorial notebooks for `hls4ml` | ||
# hls4ml-tutorial: Tutorial notebooks for `hls4ml` | ||
|
||
|
||
[](https://fastmachinelearning.org/hls4ml-tutorial) | ||
 | ||
[](https://github.com/psf/black) | ||
[](https://github.com/pre-commit/pre-commit) | ||
[](https://mybinder.org/v2/gh/fastmachinelearning/hls4ml-tutorial) | ||
|
||
|
||
There are several ways to run the tutorial notebooks: | ||
## Online | ||
[](http://cern.ch/ssummers/hls4ml-tutorial) | ||
[](https://binder.cern.ch/v2/gh/hls-fpga-machine-learning/hls4ml-tutorial/HEAD) | ||
[](https://mybinder.org/v2/gh/hls-fpga-machine-learning/hls4ml-tutorial/HEAD) | ||
[](https://mybinder.org/v2/gh/fastmachinelearning/hls4ml-tutorial) | ||
|
||
## Conda | ||
The Python environment used for the tutorials is specified in the `environment.yml` file. It can be setup like: | ||
``` | ||
The Python environment used for the tutorials is specified in the `environment.yml` file. | ||
It can be setup like: | ||
```bash | ||
conda env create -f environment.yml | ||
conda activate hls4ml-tutorial | ||
``` | ||
|
||
## Docker | ||
Follow these steps to build a Docker image that can be used locally, or on a JupyterHub instance, e.g. as the [single user image](https://zero-to-jupyterhub.readthedocs.io/en/latest/customizing/user-environment.html#choose-and-use-an-existing-docker-image). | ||
The Dockerfile was modified from one created using `repo2docker`. | ||
You can build the image straight from the Github: | ||
`docker build --build-arg NB_USER=jovyan --build-arg NB_UID=1000 https://github.com/hls-fpga-machine-learning/hls4ml-tutorial.git -f docker/Dockerfile` | ||
Alternatively, you can clone the repository and build locally (you might want to do this to add Vivado installation, for example): | ||
## Docker without Vivado | ||
Pull the prebuilt image from the GitHub Container Registry: | ||
```bash | ||
docker pull ghcr.io/fastmachinlearning/hls4ml-tutorial/hls4ml-0.7.0:latest | ||
``` | ||
git clone https://github.com/hls-fpga-machine-learning/hls4ml-tutorial.git | ||
|
||
Follow these steps to build a Docker image that can be used locally, or on a JupyterHub instance. | ||
You can build the image (without Vivado): | ||
```bash | ||
docker build https://github.com/fastmachinelearning/hls4ml-tutorial -f docker/Dockerfile | ||
``` | ||
Alternatively, you can clone the repository and build locally: | ||
```bash | ||
git clone https://github.com/fastmachinelearning/hls4ml-tutorial | ||
cd hls4ml-tutorial | ||
# modify something | ||
docker build --build-arg NB_USER=jovyan --build-arg NB_UID=1000 . -f docker/Dockerfile | ||
docker build -f docker/Dockerfile -t ghcr.io/fastmachinlearning/hls4ml-tutorial/hls4ml-0.7.0:latest . | ||
``` | ||
Then to start the container: | ||
`docker run -p 8888:8888 <IMAGE ID>` | ||
```bash | ||
docker run -p 8888:8888 ghcr.io/fastmachinlearning/hls4ml-tutorial/hls4ml-0.7.0:latest | ||
``` | ||
When the container starts, the Jupyter notebook server is started, and the link to open it in your browser is printed. | ||
You can clone the repository inside the container and run the notebooks. | ||
|
||
## Docker with Vivado | ||
Pull the prebuilt image from the GitHub Container Registry: | ||
```bash | ||
docker pull ghcr.io/fastmachinlearning/hls4ml-tutorial/hls4ml-0.7.0-vivado-2019.2:latest | ||
``` | ||
|
||
To build the image with Vivado, run (Warning: takes a long time and requires a lot of disk space): | ||
```bash | ||
docker build -f docker/Dockerfile.vivado -t ghcr.io/fastmachinlearning/hls4ml-tutorial:hls4ml-0.7.0-vivado-2019.2:latest . | ||
``` | ||
Then to start the container: | ||
```bash | ||
docker run -p 8888:8888 ghcr.io/fastmachinlearning/hls4ml-tutorial/hls4ml-0.7.0-vivado-2019.2:latest | ||
``` | ||
|
||
## Companion material | ||
We have prepared a set of slides with some introduction and more details on each of the exercises. Please find them [here](https://docs.google.com/presentation/d/1c4LvEc6yMByx2HJs8zUP5oxLtY6ACSizQdKvw5cg5Ck/edit?usp=sharing). | ||
We have prepared a set of slides with some introduction and more details on each of the exercises. | ||
Please find them [here](https://docs.google.com/presentation/d/1c4LvEc6yMByx2HJs8zUP5oxLtY6ACSizQdKvw5cg5Ck/edit?usp=sharing). | ||
|
||
|
||
## Notebooks | ||
```{tableofcontents} | ||
``` |
This file contains 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,35 @@ | ||
# Book settings | ||
# Learn more at https://jupyterbook.org/customize/config.html | ||
|
||
title: hls4ml tutorial | ||
author: Fast ML team | ||
logo: images/hls4ml_logo.svg | ||
favicon: images/hls4ml_logo.svg | ||
|
||
# Force re-execution of notebooks on each build. | ||
# See https://jupyterbook.org/content/execute.html | ||
execute: | ||
execute_notebooks: force | ||
timeout: -1 | ||
|
||
# Define the name of the latex output file for PDF builds | ||
latex: | ||
latex_documents: | ||
targetname: book.tex | ||
|
||
# Information about where the book exists on the web | ||
repository: | ||
url: https://github.com/fastmachinelearning/hls4ml-tutorial # Online location of your book | ||
path_to_book: "" # Optional path to your book, relative to the repository root | ||
branch: main # Which branch of the repository should be used when creating links (optional) | ||
|
||
# Add GitHub buttons to your book | ||
# See https://jupyterbook.org/customize/config.html#add-a-link-to-your-repository | ||
html: | ||
use_issues_button: true | ||
use_repository_button: true | ||
baseurl: "https://fastmachinlearning.org/hls4ml-tutorial/" # The base URL where your book will be hosted. Used for creating image previews and social links. e.g.: https://mypage.com/mybook/ | ||
|
||
launch_buttons: | ||
binderhub_url: "https://mybinder.org" | ||
colab_url: "https://colab.research.google.com" |
This file contains 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 @@ | ||
format: jb-book | ||
root: README.md | ||
chapters: | ||
- file: part1_getting_started.ipynb | ||
- file: part2_advanced_config.ipynb | ||
- file: part3_compression.ipynb | ||
- file: part4_quantization.ipynb | ||
- file: part5_bdt.ipynb | ||
- file: part6_cnns.ipynb | ||
- file: part7_deployment.ipynb |
Oops, something went wrong.