Skip to content
Open
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
14 changes: 13 additions & 1 deletion .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,19 @@
"imageSize": 80,
"commit": true,
"commitConvention": "angular",
"contributors": [],
"contributors": [
{
"login": "ultrasphere-dev",
"name": "ultrasphere-dev",
"avatar_url": "https://avatars.githubusercontent.com/u/231439132?v=4",
"profile": "https://github.com/ultrasphere-dev",
"contributions": [
"code",
"ideas",
"doc"
]
}
],
"contributorsPerLine": 7,
"skipCi": true
}
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,19 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d

<!-- prettier-ignore-start -->
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<!-- markdownlint-enable -->
<table>
<tbody>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/ultrasphere-dev"><img src="https://avatars.githubusercontent.com/u/231439132?v=4?s=80" width="80px;" alt="ultrasphere-dev"/><br /><sub><b>ultrasphere-dev</b></sub></a><br /><a href="https://github.com/ultrasphere-dev/hpc-tutorial/commits?author=ultrasphere-dev" title="Code">💻</a> <a href="#ideas-ultrasphere-dev" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/ultrasphere-dev/hpc-tutorial/commits?author=ultrasphere-dev" title="Documentation">📖</a></td>
</tr>
</tbody>
</table>

<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->
<!-- prettier-ignore-end -->

Expand Down
21 changes: 21 additions & 0 deletions hpc/miyabi.just
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# User name
user:="${MIYABI_USER}"
# Group name
group:="${MIYABI_GROUP}"
# The remote server to connect to
remote:=user + "@miyabi-g.jcahpc.jp"
# Your directory in the group drive
group_dir:="/work" / group / user
# The path to the script to be executed
script_path:="miyabi.sh"

default: ssh

# connect to group drive (from local)
ssh:
ssh -t {{remote}} "cd {{group_dir}}; bash --login"

# run the script (from hpc)
run:
git pull
qsub -W group_list={{group}} {{script_path}}
15 changes: 15 additions & 0 deletions hpc/miyabi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash -l
#PBS -q debug-g
#PBS -o out.log
#PBS -j oe
#PBS -m abe
#PBS -V
#PBS -l select=4:mpiprocs=1
#PBS -l walltime=03:00
#PBS -l mail_power_info=true

#export UV_CACHE_DIR=/work//m
echo $UV_CACHE_DIR
cd ${PBS_O_WORKDIR}
uv run python -m hpc_tutorial.tutorial_normal
mpiexec uv run python -m hpc_tutorial.tutorial_dask
2 changes: 2 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mod? tsubame 'hpc/tsubame.just'
mod? miyabi 'hpc/miyabi.just'
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ classifiers = [
]

dependencies = [
"cm-time>=0.1.2",
"dask-mpi>=2025.10.0",
"joblib>=1.5.3",
"numpy>=2.2.6",
"rich>=10",
"typer>=0.15,<1",
]
Expand Down
9 changes: 0 additions & 9 deletions src/hpc_tutorial/cli.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
import typer
from rich import print

from .main import add

app = typer.Typer()


@app.command()
def main(n1: int, n2: int) -> None:
"""Add the arguments and print the result."""
print(add(n1, n2))
3 changes: 0 additions & 3 deletions src/hpc_tutorial/main.py

This file was deleted.

33 changes: 33 additions & 0 deletions src/hpc_tutorial/tutorial_dask.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import joblib
import numpy as np
from cm_time import timer
from dask_mpi import initialize
from distributed import Client


def _task(seed: int) -> float:
rng = np.random.default_rng(seed)
A = rng.normal(size=(100, 1000, 1000))
b = rng.normal(size=(100, 1000, 1))
x = np.linalg.solve(A, b)
return x.mean()


if __name__ == "__main__":
with timer() as t:
initialize()
client = Client()
joblib.parallel_backend("dask")
print(f"Initialized Dask client in {t.elapsed:g}s")

with timer() as t:
results = joblib.Parallel(n_jobs=-1)(
joblib.delayed(_task)(seed) for seed in range(2)
)
print(results)
print(f"Computed results in {t.elapsed:g}s")

with timer() as t:
client.retire_workers()
client.close()
print(f"Closed Dask client in {t.elapsed:g}s")
16 changes: 16 additions & 0 deletions src/hpc_tutorial/tutorial_normal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import numpy as np
from cm_time import timer


def _task(seed: int) -> float:
rng = np.random.default_rng(seed)
A = rng.normal(size=(200, 1000, 1000))
b = rng.normal(size=(200, 1000, 1))
x = np.linalg.solve(A, b)
return x.mean()


if __name__ == "__main__":
with timer() as t:
print(_task(0))
print(f"Computed result in {t.elapsed:g}s")
6 changes: 0 additions & 6 deletions tests/test_main.py
Original file line number Diff line number Diff line change
@@ -1,6 +0,0 @@
from hpc_tutorial.main import add


def test_add():
"""Adding two number works as expected."""
assert add(1, 1) == 2
494 changes: 493 additions & 1 deletion uv.lock

Large diffs are not rendered by default.

Loading