Skip to content

Fix scalar-state hashing for PyTorch 1.12 in state hashing utilities - #61

Merged
InsightofSPb merged 1 commit into
codex/integrate-genuine-lposs-inference-in-repositoryfrom
codex/apply-minimal-scalar-state-hashing-fix-to-pr-#58
Aug 26, 2026
Merged

Fix scalar-state hashing for PyTorch 1.12 in state hashing utilities#61
InsightofSPb merged 1 commit into
codex/integrate-genuine-lposs-inference-in-repositoryfrom
codex/apply-minimal-scalar-state-hashing-fix-to-pr-#58

Conversation

@InsightofSPb

Copy link
Copy Markdown
Owner

Motivation

  • PyTorch 1.12 handles scalar tensors differently when viewed as raw bytes, so existing cpu.view(torch.uint8).numpy().tobytes() usage could mis-hash or fail for scalar parameters.
  • The intent is to preserve deterministic, provenance-friendly raw-byte hashing for both scalar and multidimensional tensors without altering semantics for non-scalar tensors.

Description

  • Replace cpu.view(torch.uint8).numpy().tobytes() with cpu.reshape(-1).view(torch.uint8).numpy().tobytes() at the three raw-byte hashing sites to ensure scalars are flattened before byte-viewing in ovs_heritage/stock_features.py and tools/run_official_lposs_parity.py.
  • Update module_state_fingerprint to flatten the tensor bytes with reshape(-1).view(...) prior to hashing in ovs_heritage/stock_features.py.
  • Add a focused CPU regression test test_scalar_state_hashing_is_deterministic_and_sensitive to ovs_heritage/tests/test_stock_lposs.py that registers a scalar parameter and a multidimensional buffer, verifies deterministic fingerprints, and verifies hashes change when the scalar changes.

Testing

  • python -m compileall -q ovs_heritage segmentation/evaluation/lposs_eval.py tools/check_stock_lposs_gpu.py tools/run_official_lposs_parity.py executed and succeeded.
  • pytest -q ovs_heritage/tests could not complete collection due to missing runtime dependencies in the environment (errors loading numpy, torch, and yaml).
  • ruff check on the modified modules completed successfully and git working-tree checks show the changes staged and committed locally.

Codex Task

@InsightofSPb
InsightofSPb merged commit 6bf8fbe into codex/integrate-genuine-lposs-inference-in-repository Aug 26, 2026
1 check passed
@InsightofSPb
InsightofSPb deleted the codex/apply-minimal-scalar-state-hashing-fix-to-pr-#58 branch August 26, 2026 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant