Skip to content

impression comparison on gpu#216

Draft
SimoneAriens wants to merge 4 commits intomainfrom
feature/gpu-impression-matching
Draft

impression comparison on gpu#216
SimoneAriens wants to merge 4 commits intomainfrom
feature/gpu-impression-matching

Conversation

@SimoneAriens
Copy link
Copy Markdown
Collaborator

Added a batched GPU path (PyTorch + CUDA) to match_cells for the coarse cell registration step. When CUDA is available, all rotated comparison images are stacked into a single tensor, uploaded once, and matched against all cell templates using FFT-based normalized cross-correlation (torch.fft).
The original algorithm is unchanged — same angles, same NCC formula, same fill-fraction masking. The only difference is execution on GPU with batched FFTs instead of sequential CPU template matching.

@SimoneAriens SimoneAriens marked this pull request as draft April 3, 2026 14:05
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 7, 2026

Diff Coverage

Diff: origin/main..HEAD, staged and unstaged changes

  • packages/scratch-core/src/container_models/base.py (100%)
  • packages/scratch-core/src/conversion/preprocess_striation/alignment.py (100%)
  • packages/scratch-core/src/conversion/surface_comparison/cell_registration/coarse.py (100%)
  • packages/scratch-core/src/conversion/surface_comparison/cell_registration/utils.py (99.1%): Missing lines 184

Summary

  • Total: 123 lines
  • Missing: 1 line
  • Coverage: 99%

packages/scratch-core/src/conversion/surface_comparison/cell_registration/utils.py

Lines 180-188

  180         max_per_angle, pos_per_angle = flat.max(dim=1)
  181         best_angle_idx = int(max_per_angle.argmax())
  182         best_score = float(max_per_angle[best_angle_idx])
  183         if best_score > 1.0 + SCORE_TOLERANCE:
! 184             raise ValueError(f"NCC score {best_score} exceeds valid range [-1, 1]")
  185         best_score = min(best_score, 1.0)
  186 
  187         score_w = score_maps.shape[3]
  188         best_pos = int(pos_per_angle[best_angle_idx])

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 7, 2026

Code Coverage

Package Line Rate Branch Rate Health
. 96% 92%
computations 94% 67%
container_models 99% 100%
conversion 96% 89%
conversion.export 99% 93%
conversion.filter 97% 89%
conversion.leveling 100% 100%
conversion.leveling.solver 100% 75%
conversion.plots 99% 88%
conversion.preprocess_impression 99% 91%
conversion.preprocess_striation 90% 62%
conversion.profile_correlator 96% 82%
conversion.surface_comparison 99% 89%
conversion.surface_comparison.cell_registration 99% 95%
extractors 97% 75%
mutations 100% 100%
parsers 97% 50%
parsers.patches 89% 60%
preprocessors 100% 100%
processors 100% 83%
renders 99% 50%
utils 71% 100%
Summary 98% (3324 / 3395) 87% (352 / 404)

Minimum allowed line rate is 50%

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.

2 participants