Repository navigation
feat: --xla, XLA-compiled inference for .h5 and .scnm models - #64
Merged
Merged
Conversation
`copick inference easymode --xla` runs each model's forward pass as one XLA-compiled function. It is off by default. An `XLAModel` wrapper is called like the Keras model and passes every other attribute through, so easymode's tiling of an .h5 network and the .scnm inference use it unchanged. Each worker compiles at the first call of each input shape and logs the time. If a compiled call raises, the worker warns once and continues with the plain model. The report records `"xla"`, and each worker lists in `xla_fallbacks` any model that gave up XLA, with the reason. On three 10521 tomograms at TTA 4 on one L40S with TensorFlow 2.21: the microtubule .h5 network went from 310 s to 107 s per tomogram, 2.9x, and the actin .scnm slab model from 87 s to 67 s, 1.3x. The masks matched the plain model's to an IoU of 0.9998 or better. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
easymode 1.2.6 and ais-cryoet 1.2.40 release the --xla options this package mirrors (mgflast/easymode#37, mgflast/Ais#16). The .h5 path uses only _pad_volume, _segment_tomogram_instance and load_model, which are unchanged, so the bump is the supported version and commit, the tests and the docs. The .scnm port follows ais-cryoet 1.2.40: its slab --stride keeps the depth // 2 default, which easymode does not override, and under XLA a short last 2.5D batch is padded with zeros to the batch size so the compiled function keeps one input shape. The docs also drop the claim that easymode is not on PyPI, and name its new metadata pins. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
uermel
pushed a commit
that referenced
this pull request
Oct 21, 2026
🤖 I have created a release *beep* *boop* --- ## [0.5.0](copick-easymode-v0.4.0...copick-easymode-v0.5.0) (2026-10-21) ### Features * --xla, XLA-compiled inference for .h5 and .scnm models ([#64](#64)) ([8960cc7](8960cc7)) --- Merging this PR will create a new release for copick-easymode. Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an opt-in
--xlaflag tocopick inference easymodethat runs each model's forward pass as one XLA-compiled function,tf.function(jit_compile=True). It is the option released upstream aseasymode segment --xlain easymode 1.2.6 (mgflast/easymode#37) andais segment --xlain ais-cryoet 1.2.40 (mgflast/Ais#16). This PR also moves the supported easymode release from 1.2.5 to 1.2.6.--xlacore/xla.py:XLAModelwraps a Keras model..h5network and the.scnminference use it unchanged, andScnmModel.is_slabstill reads the network's shapes.XLAModelfor three reasons: the attribute pass-through, the log line per compiled shape, and the fallback reason in the report.InferenceSettings.xla,dispatch_easymode_inference(xla=...)andrun_easymode_inference(xla=...)carry the option to every worker.load_stageswraps the network when it is set.--xla/--no-xla, off by default. It stays opt-in because a missing or too oldptxascan abort TensorFlow outright, which no fallback can catch."xla", and per workerxla_fallbacks, each withfeatureandreason. A fallback is not an error, and its runs still count as processed.easymode 1.2.6
EASYMODE_VERSION/EASYMODE_COMMITnow point to tagv1.2.6(00ab903), and the install line follows them. The.h5path uses only_pad_volume,_segment_tomogram_instanceandload_model, and all three are unchanged in 1.2.6..scnmport now follows ais-cryoet 1.2.40. Its inference differs from 1.2.38 in only three ways:--stride: a new option whose default stays at half the slab depth. easymode does not pass it, so nothing changes here..scnmbatch size of 1 it never fires.numpy<2,tensorflow<2.16andais-cryoet, which needs Keras 2. They also drop the claim that easymode is not on PyPI. The install stays--no-deps.Measurements
Three 10521 tomograms, each 320 x 772 x 548 voxels, streamed from the CryoET Data Portal. TTA 4 on one L40S, with TensorFlow 2.21 and Keras 3.15:
.scnmslice models were not measured.--xlawith easymode 1.2.6 on one of the tomograms reproduced the masks:Tests: new unit tests cover the wrapper, the last-batch padding, the flag and the report. The suite passes with easymode 1.2.6 inside the picking image: 75 passed.
🤖 Generated with Claude Code