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: 1 addition & 1 deletion .github/DISCUSSION_TEMPLATE/ideas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ body:
attributes:
label: The idea
description: |
A model, an interface or a direction you think TorchSim should take,
A model, an interface or a direction you think BlochSim should take,
before it is concrete enough to be a feature request.
validations:
required: true
Expand Down
2 changes: 1 addition & 1 deletion .github/DISCUSSION_TEMPLATE/q-a.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ body:
- type: input
id: version
attributes:
label: TorchSim version
label: BlochSim version
placeholder: "0.4.1, or the commit you are on"
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ body:
- type: markdown
attributes:
value: |
Questions about how to use TorchSim, and results you are unsure about,
belong in [Discussions](https://github.com/pulserver/torchsim/discussions).
Questions about how to use BlochSim, and results you are unsure about,
belong in [Discussions](https://github.com/pulserver/blochsim/discussions).
This form is for behaviour you can pin down.

- type: textarea
Expand Down Expand Up @@ -47,7 +47,7 @@ body:
Paste the output of

```sh
python -c "from importlib.metadata import version; print('torchsim', version('torchsim'))"
python -c "from importlib.metadata import version; print('blochsim', version('blochsim'))"
python -c "import torch; print(torch.__version__, torch.version.cuda, torch.cuda.get_device_name() if torch.cuda.is_available() else 'cpu')"
python -VV
```
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: Question, or a result you are unsure about
url: https://github.com/pulserver/torchsim/discussions
url: https://github.com/pulserver/blochsim/discussions
about: Ask how to model a sequence, or whether a signal you got is expected.
- name: Security report
url: https://github.com/pulserver/torchsim/security/policy
url: https://github.com/pulserver/blochsim/security/policy
about: Report a vulnerability privately rather than in a public issue.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Feature request
description: A sequence, a physical effect, an estimator or an interface TorchSim should carry.
description: A sequence, a physical effect, an estimator or an interface BlochSim should carry.
labels: ["enhancement"]
body:
- type: textarea
Expand All @@ -16,7 +16,7 @@ body:
- type: textarea
id: proposal
attributes:
label: What you would like TorchSim to do
label: What you would like BlochSim to do
description: |
If you already know the shape of it -- an operator, a tissue property,
a keyword on an existing simulator -- sketch the call you would like
Expand Down
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ pytest tests/
- [ ] Comments and docstrings describe the code as it is now -- no
"previously", no "this replaces", no naming of a bug that is fixed.
- [ ] A change to what the kernels compute is in both of them, and arrives
with a test that pins it against something outside TorchSim.
with a test that pins it against something outside BlochSim.
- [ ] The documentation is updated where the change is visible to a caller,
and `bash scripts/build_docs.sh` still builds.
6 changes: 3 additions & 3 deletions .github/SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Older releases are not patched.
Report privately, not as a public issue:

- open a draft advisory through
[Security -> Report a vulnerability](https://github.com/pulserver/torchsim/security/advisories/new),
[Security -> Report a vulnerability](https://github.com/pulserver/blochsim/security/advisories/new),
which is the preferred route; or
- email **matteo.cencini@gmail.com** if you cannot use GitHub.

Expand All @@ -22,7 +22,7 @@ publicly.

## Scope

TorchSim executes the code you give it: a sequence layout, a cost function and
BlochSim executes the code you give it: a sequence layout, a cost function and
a signal model are all Python that runs in your process, so a malicious
*script* is out of scope in the same way it is for NumPy or PyTorch.

Expand All @@ -36,4 +36,4 @@ merely a bug.
## Not a vulnerability

A simulation that returns wrong physics, diverges, or raises is a
[bug report](https://github.com/pulserver/torchsim/issues/new/choose).
[bug report](https://github.com/pulserver/blochsim/issues/new/choose).
10 changes: 5 additions & 5 deletions .github/skills/add-a-sequence/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
name: add-a-sequence
description: Write a new simulator, signal model, or sequence operator in TorchSim. Use when asked to add a sequence, a readout module, a physical effect, or a tissue property.
description: Write a new simulator, signal model, or sequence operator in BlochSim. Use when asked to add a sequence, a readout module, a physical effect, or a tissue property.
---

# Add a sequence to TorchSim
# Add a sequence to BlochSim

**There is one base class, `Simulator`, written in one of two ways.** Nothing
downstream ever asks which way.
Expand Down Expand Up @@ -62,15 +62,15 @@ and a run reads which properties were passed to decide which terms the kernel
evaluates. Adding an effect is one line in a model's property declaration, plus
the term itself in **both** kernels.

The shared parameter ABI is `src/torchsim/sequence/_parameters.py`, read by the
The shared parameter ABI is `src/blochsim/sequence/_parameters.py`, read by the
Python dispatch, the C++ extension and the Triton kernels. A parameter added
there is added in all three or in none.

## What the change has to arrive with

A test that pins the new physics against something **outside** TorchSim: a
A test that pins the new physics against something **outside** BlochSim: a
closed form, a published figure, or an isochromat summation written out in the
test itself. Comparing TorchSim to TorchSim proves the two agree, which was
test itself. Comparing BlochSim to BlochSim proves the two agree, which was
never in doubt. Put it in `tests/epg/` and state the invariant in the module
docstring.

Expand Down
8 changes: 4 additions & 4 deletions .github/skills/build-and-test/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
name: build-and-test
description: Compile the C++ kernels and run the TorchSim suite, including the Triton paths on a machine with no GPU. Use when asked to build, install, test, or reproduce a failure in torchsim.
description: Compile the C++ kernels and run the BlochSim suite, including the Triton paths on a machine with no GPU. Use when asked to build, install, test, or reproduce a failure in blochsim.
---

# Build and test TorchSim
# Build and test BlochSim

## Install

Expand All @@ -15,7 +15,7 @@ pip install -e ".[dev]" ; echo "exit: $?"
run alone, `pip install -e ".[test]"` is enough and much smaller.

An editable install puts the Python sources on the path, so an edit under
`src/torchsim` takes effect on the next import. The two C++ extensions are
`src/blochsim` takes effect on the next import. The two C++ extensions are
compiled artifacts and do not: re-run the install after editing any `.cpp`.

**Read the exit status, not the output.** A failed compile leaves the
Expand All @@ -24,7 +24,7 @@ that no longer corresponds to the source. Confirm the extension is the one you
just built:

```sh
python -c "import torchsim._epg_cpu as k; print(k.__file__)"
python -c "import blochsim._epg_cpu as k; print(k.__file__)"
```

## Test
Expand Down
22 changes: 11 additions & 11 deletions .github/skills/build-the-docs/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
---
name: build-the-docs
description: Build the TorchSim documentation, add a figure to an explanation page, or add a gallery example. Use when asked about docs, Sphinx, the gallery, MyST, or Read the Docs for torchsim.
description: Build the BlochSim documentation, add a figure to an explanation page, or add a gallery example. Use when asked about docs, Sphinx, the gallery, MyST, or Read the Docs for blochsim.
---

# Build the TorchSim documentation
# Build the BlochSim documentation

```sh
bash scripts/build_docs.sh # incremental
bash scripts/build_docs.sh --clean # re-execute every example
PYTHON_BIN=~/envs/torchsim/bin/python bash scripts/build_docs.sh
PYTHON_BIN=~/envs/blochsim/bin/python bash scripts/build_docs.sh
python -m http.server --directory docs/build/html 8000
```

The script checks that the interpreter it is given can import TorchSim and the
The script checks that the interpreter it is given can import BlochSim and the
documentation extensions, then builds into `docs/build/html`. Two things make
it slower than a plain Sphinx run and are the point of it: **sphinx-gallery
executes the examples**, and **the explanation pages' figures are re-rendered**
by `docs/explanation_figures.py` with the TorchSim in your working tree.
by `docs/explanation_figures.py` with the BlochSim in your working tree.

An example is executed when the interpreter can import everything it imports:
an environment with the `dev` or `examples` extra runs the whole gallery, one
with `doc` alone runs what needs nothing but TorchSim. A page already carrying
with `doc` alone runs what needs nothing but BlochSim. A page already carrying
output executed from the source as it stands is reused rather than re-run, and
the build names each example it did not run and where its output came from. To
build the pages without running any of them, pass `-D plot_gallery=0`.

## Where the published pages are built

`.github/workflows/docs.yml` builds them, and GitHub Pages serves them from
the `gh-pages` branch at <https://pulserver.github.io/torchsim/>.
the `gh-pages` branch at <https://pulserver.github.io/blochsim/>.

Its **HTML** job runs on every branch and pull request with the `doc` extra:
every page is written and the examples needing nothing but TorchSim are
every page is written and the examples needing nothing but BlochSim are
executed, in a few minutes, and the tree is uploaded as an artifact to read.

Its **Site** job runs on `main`, on a `v*.*.*` tag and on demand. It installs
Expand All @@ -43,7 +43,7 @@ Sphinx wrote to `scripts/publish_docs.py`, which places it in the site:
site/index.html a page sending a reader to the newest release
site/versions.json the list the switcher in the sidebar reads

`TORCHSIM_DOCS_VERSION` is what a build calls itself; it names the directory,
`BLOCHSIM_DOCS_VERSION` is what a build calls itself; it names the directory,
the switcher's mark and the Binder path prefix, and defaults to `latest`.

## Markdown, and the two places it is not
Expand Down Expand Up @@ -90,7 +90,7 @@ executed and where it is published as source.
## Writing

The audience is MR scientists: pulse sequences and physics, not software
architecture. Describe what TorchSim does and why that is right on its own
architecture. Describe what BlochSim does and why that is right on its own
terms. These pages are not a changelog — never justify a design by describing
the design it replaced.

Expand All @@ -109,7 +109,7 @@ Keep the public sidebar shallow and in this order:
The first four Framework examples are the Course. They teach the public
abstraction in order; the remaining example sections are standalone Tours.

For a new sequence, teach {class}`torchsim.model.Simulator` as the extension
For a new sequence, teach {class}`blochsim.model.Simulator` as the extension
point. A state-machine simulator has two complementary inputs: its class-level
handlers interpret commands from an incoming Pulseq/MRD description, and
`layout()` constructs the same sequence offline. Lower-level
Expand Down
4 changes: 2 additions & 2 deletions .github/skills/cut-a-release/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
name: cut-a-release
description: Publish a TorchSim release to PyPI, and diagnose a wheel build. Use when asked about releasing, versioning, cibuildwheel, abi3 wheels, or the packaging setup.
description: Publish a BlochSim release to PyPI, and diagnose a wheel build. Use when asked about releasing, versioning, cibuildwheel, abi3 wheels, or the packaging setup.
---

# Cut a TorchSim release
# Cut a BlochSim release

The version comes from the git tag through setuptools-scm; nothing in the tree
states it. To release:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
--extra-index-url https://pypi.org/simple

# The ``doc`` extra alone: every page is written and the examples
# needing nothing but TorchSim are executed, which is what a branch
# needing nothing but BlochSim are executed, which is what a branch
# wants to know within a few minutes. The Site job below runs the rest.
- name: Build the extensions and install
run: python -m pip install ".[doc]"
Expand Down Expand Up @@ -86,7 +86,7 @@ jobs:
# A tag is published under its own name; anything else is the
# development version. It names the directory of the site, the entry
# the switcher marks, and the prefix the notebook links reach through.
TORCHSIM_DOCS_VERSION: ${{ github.ref_type == 'tag' && github.ref_name || 'latest' }}
BLOCHSIM_DOCS_VERSION: ${{ github.ref_type == 'tag' && github.ref_name || 'latest' }}

steps:
- uses: actions/checkout@v7
Expand Down Expand Up @@ -125,7 +125,7 @@ jobs:

- uses: actions/upload-artifact@v7
with:
name: html-${{ env.TORCHSIM_DOCS_VERSION }}
name: html-${{ env.BLOCHSIM_DOCS_VERSION }}
path: docs/build/html
retention-days: 7

Expand All @@ -141,8 +141,8 @@ jobs:
else
git worktree add --orphan ../pages
fi
python scripts/publish_docs.py docs/build/html "$TORCHSIM_DOCS_VERSION" ../pages
python scripts/publish_docs.py docs/build/html "$BLOCHSIM_DOCS_VERSION" ../pages
git -C ../pages add --all
git -C ../pages commit --quiet \
-m "Publish $TORCHSIM_DOCS_VERSION from ${{ github.sha }}" || exit 0
-m "Publish $BLOCHSIM_DOCS_VERSION from ${{ github.sha }}" || exit 0
git -C ../pages push origin HEAD:gh-pages
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
shell: python
run: |
import importlib.util, pathlib
spec = importlib.util.find_spec("torchsim")
spec = importlib.util.find_spec("blochsim")
root = pathlib.Path(next(iter(spec.submodule_search_locations)))
for kernel in sorted(root.glob("_*_cpu*")):
print(kernel.name, kernel.stat().st_size, "bytes")
Expand All @@ -84,6 +84,6 @@ jobs:
uses: codecov/codecov-action@v7
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: pulserver/torchsim
slug: pulserver/blochsim
files: coverage.xml
fail_ci_if_error: false
6 changes: 3 additions & 3 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ on:
- pyproject.toml
- CMakeLists.txt
- setup.py
- "src/torchsim/*.cpp"
- "src/torchsim/*.hpp"
- "src/blochsim/*.cpp"
- "src/blochsim/*.hpp"
- scripts/check_wheel.py
- .github/workflows/wheels.yml
workflow_dispatch:
Expand Down Expand Up @@ -95,7 +95,7 @@ jobs:
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/torchsim
url: https://pypi.org/p/blochsim
permissions:
# Trusted publishing: no API token is stored anywhere.
id-token: write
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ CMakeFiles/
cmake_install.cmake

# Generated at build time
src/torchsim/_version.py
src/blochsim/_version.py

# Test and coverage output
.coverage*
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
ci:
autoupdate_schedule: monthly

exclude: ^src/torchsim/_version\.py$
exclude: ^src/blochsim/_version\.py$

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down
Loading
Loading