feat(vit): true vit-only mode — skip the iterative engine entirely#43
Merged
Conversation
recon_mode='vit' previously still created the PtychoRecon / StreamingPtychoRecon engine (it only skipped wiring its flows), opening a CuPy context on the ViT GPU — PyCUDA + CuPy on the same device from different threads can crash (SIGABRT). Now the engine, SaveResult, and SaveLiveResult are created only for recon_mode in (iterative, both). With no engine, the geometry it used to supply is derived from config: - config_ops gains a has_recon branch; in vit-only it sizes the ops from param.nx/ny and computes the position-conversion pixel size via ptychoml.compute_sample_pixel_size (same far-field formula the engine uses), leaving x/y_direction at the values point_proc already got at construction. - compose computes _x_pixel_m/_y_pixel_m/_lambda_nm once (engine when present, else config) for run metadata and SaveViTResult; SaveViTResult's ranges come from abs(param.x/y_range) — the same values recon supplies, no axis swap (that's a separate orientation change). - the reset_for_scan block is guarded. preprocess.py: ImageSendOp and PointProcessorOp skip their device copies when diff_d_target / point_info_target are None (the vit-only case). All self.pty references are now inside has_recon / recon_mode guards. This is compose-time Holoscan behavior exercised by real vit-only runs; the geometry fallback delegates to the ptychoml-tested helper, and the existing suite passes (85, modulo the 2 pre-existing TILED smoke imports). H4b of the #37 decomposition. Co-authored-by: Himanshu Goel <4122621+himanshugoel2797@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.
H4b of the #37 decomposition — make
recon_mode='vit'actually skip the iterative engine.Problem
recon_mode='vit'previously still created thePtychoRecon/StreamingPtychoReconengine (it only skipped wiring its flows), which opens a CuPy context on the ViT GPU. PyCUDA (ViT) + CuPy (recon) on the same device from different threads can crash with SIGABRT.Changes (
ptycho_holo.py,preprocess.py)PtychoRecon,SaveResult,SaveLiveResultare created only forrecon_mode in (iterative, both). Thereset_for_scanblock is likewise guarded. (The iterative add-flows were already guarded on main.)config_opsgains ahas_reconbranch; in vit-only it sizes ops fromparam.nx/nyand computes the position-conversion pixel size viaptychoml.compute_sample_pixel_size(the same far-field formula the engine uses).x/y_directionalready come from config atpoint_procconstruction.composecomputes_x_pixel_m/_y_pixel_m/_lambda_nmonce (engine when present, else config) for the run metadata andSaveViTResult. Ranges useabs(param.x/y_range)— the same values the engine supplies, no axis swap (that swap is a separate orientation change, H5).preprocess.py—ImageSendOp/PointProcessorOpskip their GPU device copies whendiff_d_target/point_info_targetareNone(the vit-only case; both default toNone).Verified every
self.ptyreference is inside ahas_recon/recon_modeguard, and the vit-only range/pixel-size fallbacks reproduce whatStreamingPtychoReconcomputes (x_range_um = abs(param.x_range),x_pixel_m = compute_sample_pixel_size(...)) — so vit-only geometry matches the iterative path on main.Testing
This is compose-time Holoscan behavior — not unit-testable in CI (the
ptycho_holosmoke import already fails on a missingTILED_BASE_URL, beforecompose). It's exercised by real vit-only runs, faithfully reproduces #37's working vit-only path, and the geometry fallback delegates to the ptychoml-testedcompute_sample_pixel_size. Safety net here is the audited guards + no regression: