Skip to content

fix(config): compute vit_normalization inline, not via ptychoml (client/replay envs lack it)#49

Merged
Garrett Bischof (gwbischof) merged 1 commit into
mainfrom
fix/config-normalization-no-ptychoml
Jun 9, 2026
Merged

fix(config): compute vit_normalization inline, not via ptychoml (client/replay envs lack it)#49
Garrett Bischof (gwbischof) merged 1 commit into
mainfrom
fix/config-normalization-no-ptychoml

Conversation

@gwbischof

Copy link
Copy Markdown
Collaborator

Found while validating scan 405820 against the operator's known-good config.

Bug

H6b (#47) swapped config_from_tiled's vit_normalization auto-detect from an inline hot-pixel-masked max to ptychoml.compute_intensity_normalization. But config_from_tiled runs in the client and replay pixi envs, which deliberately don't depend on ptychoml (the replay env dropped it). So:

WARNING: could not auto-detect vit_normalization: No module named 'ptychoml'

The broad except swallowed it and vit_normalization came out unset — both for the standalone config-from-tiled task and for replay --hp-start (which builds its config via build_full_configload_config_from_tiled).

Fix

Revert to the inline numpy hot-pixel-masked max. Verified against scan 405820: vit_normalization now resolves to 1150.0, matching the operator's known-good config.

How it slipped through

The H6b swap was only exercised in the default env (which has ptychoml) via py_compile + --help; the failure only manifests in the client/replay envs where the function actually runs. (compute_intensity_normalization itself is fine and still used by detect_orientation.py, which runs in an env that does have ptychoml.)

No new test: config_from_tiled is Tiled-I/O bound (the normalization path needs a live scan). Validated end-to-end against 405820.

config_from_tiled's vit_normalization auto-detect was changed in the H6b
decomposition PR to call ptychoml.compute_intensity_normalization. But
config_from_tiled runs in the `client` and `replay` pixi envs, which
deliberately do NOT depend on ptychoml (the replay env dropped it on purpose).
So the import raised ModuleNotFoundError, the broad except swallowed it, and
vit_normalization silently came out unset — both for `config-from-tiled` and
for `replay --hp-start` (which builds its config via
build_full_config -> load_config_from_tiled).

Revert to the inline hot-pixel-masked max (numpy only). Verified against scan
405820: vit_normalization now resolves to 1150.0, matching the operator's
known-good config.

(The ptychoml-reuse was well-intentioned but I only tested it in the default
env, which has ptychoml; the failure only shows in the client/replay envs.)

Co-authored-by: Himanshu Goel <4122621+himanshugoel2797@users.noreply.github.com>
@gwbischof Garrett Bischof (gwbischof) merged commit 00ea7ab into main Jun 9, 2026
5 checks passed
@gwbischof Garrett Bischof (gwbischof) deleted the fix/config-normalization-no-ptychoml branch June 9, 2026 21:06
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