Skip to content

Add variant option (atomify wasm in the kernel) and ship python/ in the npm tarball#92

Merged
andeplane merged 3 commits into
masterfrom
feat/atomify-variant
Jul 12, 2026
Merged

Add variant option (atomify wasm in the kernel) and ship python/ in the npm tarball#92
andeplane merged 3 commits into
masterfrom
feat/atomify-variant

Conversation

@andeplane

Copy link
Copy Markdown
Collaborator

Two coupled changes that Atomify needs from lammps.js.

1. variant: "serial" | "kokkos" | "atomify" client option

The full-package atomify wasm build already ships in the npm tarball (./wasm-atomify, built by PACKAGES=atomify python3 cpp/build.py), but neither LammpsClient nor the Python bindings could load it — so the Pyodide kernel was stuck on the MOLECULE-only serial build.

  • client.ts: variant selects the wasm module (lammps.js, lammps-kokkos.js, or lammps-atomify.js). Precedence: an explicit variant wins over the kokkos flag; kokkos: true remains equivalent to variant: "kokkos" (full back-compat). Since the atomify build is itself a KOKKOS/pthreads build, both threaded variants start LAMMPS with -k on t N [-sf kk] (threads/suffix still tunable via the kokkos option) and require a cross-origin isolated context in browsers.
  • worker path: variant is forwarded through LammpsWorkerClient, the worker init protocol message, and the worker host.
  • python/lammps/init.py: await lammps(variant="atomify") mirrors the client option. The crossOriginIsolated check now covers every threaded variant, and the shared wasm-module cache is keyed per (client URL, variant) so serial/kokkos/atomify sessions don't collide. Reused sessions now also receive the client options, so threaded restarts keep their Kokkos start args.
  • types/client.d.ts: declares KokkosOptions, LammpsVariant, and the new options.
  • docs: README, python/README, and NOTEBOOK_TUTORIALS updated; the "no LammpsClient entry point for the atomify variant" caveat is gone.

2. Ship python/ in the npm tarball + version alignment

python/lammps, python/pyproject.toml, and python/README.md are added to the package files, so consumers can build the lammps-js wheel directly from node_modules/lammps.js/python without cloning this repo. The entries are listed individually so local build artifacts (python/build/, python/lammps_js.egg-info/) can never leak into the tarball. The wheel version is bumped 1.5.0 → 1.5.1 to match the npm package version exactly.

Why Atomify needs this

Atomify's JupyterLite kernel runs the lammps.js Python bindings on top of the wasm engine. Its example library needs the full package set (MANYBODY, KSPACE, REAXFF, GRANULAR, …), which only the atomify build provides — variant="atomify" lets the kernel run it. Shipping python/ in the tarball lets Atomify CI build the wheel from node_modules instead of vendoring it. After this merges and a release is cut, Atomify can drop its vendored-wheel version pin.

Tests

  • Full vitest suite green locally against a freshly built serial wasm: 146 passed, 12 skipped (the kokkos/atomify specs skip where those builds are absent; CI covers them via test:kokkos / test:atomify).
  • New tests: variant precedence + Kokkos start args (client.unit.spec.ts), init-message forwarding (worker-host.spec.ts), and an end-to-end variant: "atomify" client test in atomify.spec.ts.
  • npm pack --dry-run verified: the tarball gains exactly python/lammps/__init__.py, python/pyproject.toml, python/README.md.

🤖 Generated with Claude Code

andeplane and others added 3 commits July 11, 2026 13:31
The client (and the Python bindings) could only load the serial or the
KOKKOS wasm build; the full-package atomify build shipped under
./wasm-atomify but had no LammpsClient / lammps() entry point, so the
Pyodide kernel could not use it.

- client.ts: new `variant` option ("serial" | "kokkos" | "atomify")
  selects the wasm module. An explicit variant takes precedence over the
  `kokkos` flag; `kokkos: true` stays equivalent to variant "kokkos".
  Since the atomify build is itself a KOKKOS/pthreads build, both
  threaded variants start LAMMPS with `-k on t N [-sf kk]` (tunable via
  the `kokkos` option) and require cross-origin isolation in browsers.
- worker path: `variant` is forwarded through LammpsWorkerClient, the
  init protocol message, and the worker host.
- python/lammps/__init__.py: `lammps(variant=...)` mirrors the client
  option; the COI check now covers every threaded variant and the shared
  wasm-module cache is keyed per (client URL, variant). Reused sessions
  now also get the client options, so threaded restarts keep their
  Kokkos start args.
- types/client.d.ts: declare KokkosOptions, LammpsVariant, and the new
  client options.
- tests: variant precedence + Kokkos start args in client.unit.spec.ts,
  init forwarding in worker-host.spec.ts, and an end-to-end
  variant:"atomify" test in atomify.spec.ts (runs under test:atomify).
- docs: README, python/README, NOTEBOOK_TUTORIALS notes on the new
  option replacing the "no client entry point for atomify" caveat.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Add python/lammps, python/pyproject.toml, and python/README.md to the
package files so consumers (Atomify CI) can build the lammps-js wheel
straight from node_modules/lammps.js/python without cloning this repo.
The entries are listed individually so local build artifacts
(python/build/, python/lammps_js.egg-info/) never leak into the tarball.

Bump the wheel version 1.5.0 -> 1.5.1 to match the npm package version
it is developed against.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Minor bump: adds the backward-compatible variant option (serial | kokkos
| atomify) and ships python/ in the npm tarball so consumers can build the
lammps-js wheel from the installed package. Triggers release.yml to publish
1.6.0 on merge to master.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@andeplane andeplane enabled auto-merge (squash) July 12, 2026 17:02
@andeplane andeplane merged commit 3dc9c66 into master Jul 12, 2026
3 checks passed
@andeplane andeplane deleted the feat/atomify-variant branch July 12, 2026 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant