Skip to content

[integration/peerlab] Bugfix/tiling issue - #42

Merged
Tobiaspk merged 4 commits into
integration/peerlabfrom
bugfix/tiling_issue
May 18, 2026
Merged

[integration/peerlab] Bugfix/tiling issue#42
Tobiaspk merged 4 commits into
integration/peerlabfrom
bugfix/tiling_issue

Conversation

@Tobiaspk

@Tobiaspk Tobiaspk commented May 15, 2026

Copy link
Copy Markdown
Collaborator

Closes #40. This PR makes building QuadTree constructino more robust. This issue is common across datasets, but particularly often seen when processing the Atera Breast Cancer public dataset.

This PR fixes the error where -1 is passed into bincount.

Cause: cuspatial sometimes generates invalid QuadTrees where tiles overlap across levels, while other regions are not covered at all. This results in invalid tile assignments during spatial queries. This issue appears randomly despite the pipeline being deterministic, and occurs in roughly 2–35% of Segger runs. In some datasets, such as Atera, even 100%.

Fix:

  • Add is_quadtree_valid: Simple validation that all points are covered by the generated quadtree.
  • Add margin_bounds to get_quadtree_kwargs: Expands the bounds used to construct the quadtree. This produces more valid trees.
  • Retry quadtree construction with larger max_size: If a generated tree is invalid, rebuild with an increased tree size. Particularly important for _points_in_polygons_contains in query.py, which defaults to max_size=10000. In the Atera dataset this frequently produces invalid trees.

Example log of dynamically increasing tree size:

2026-05-17 23:08:45 | DEBUG    | segger.geometry.quadtree:178 | GPU: 20.61 GB (peak 67.49 GB) - Building quadtree on 624327019 points with max_size=10000, max_depth=14
2026-05-17 23:08:46 | WARNING  | segger.geometry.quadtree:196 | GPU: 23.11 GB (peak 67.49 GB) - Invalid quadtree generated with max_size=10000. Retry with max_size=20000.
2026-05-17 23:08:46 | DEBUG    | segger.geometry.quadtree:204 | GPU: 23.11 GB (peak 67.49 GB) - Quadtree built: 75131 leaves

@Tobiaspk
Tobiaspk changed the base branch from main to integration/peerlab May 15, 2026 21:28
@Tobiaspk
Tobiaspk merged commit 0cb01cd into integration/peerlab May 18, 2026
Tobiaspk added a commit that referenced this pull request May 26, 2026
Major:

CUDA/Xenium install #21: CUDA 12.1 support; Xenium v1 + binary column datatype support; pixi/conda install updates
Reference gene correlation #32: Add custom reference gene correlation support via `--gene-corr-reference-path`
Memory optimisations #36: GPU/memory optimisations for large datasets; chunked subgraphing fallback
Large dataset fixes #44: Fix torch array overflow and related scaling issues
Tiling fixes #42: Fix tiling/bincount errors and transcript thresholding

Minor:

Logging improvements #31: Improve debug logging; support `SEGGER_LOG_LEVEL`
Margin handling #34: Warn instead of fail when tiling margins are too large
Misc cleanup: Refactors; assertions/debugging; remove unused code and comments

---------

Co-authored-by: Nandula
Co-authored-by: Kalfus
EliHei2 pushed a commit that referenced this pull request Jun 1, 2026
Major:

CUDA/Xenium install #21: CUDA 12.1 support; Xenium v1 + binary column datatype support; pixi/conda install updates
Reference gene correlation #32: Add custom reference gene correlation support via `--gene-corr-reference-path`
Memory optimisations #36: GPU/memory optimisations for large datasets; chunked subgraphing fallback
Large dataset fixes #44: Fix torch array overflow and related scaling issues
Tiling fixes #42: Fix tiling/bincount errors and transcript thresholding

Minor:

Logging improvements #31: Improve debug logging; support `SEGGER_LOG_LEVEL`
Margin handling #34: Warn instead of fail when tiling margins are too large
Misc cleanup: Refactors; assertions/debugging; remove unused code and comments

---------

Co-authored-by: Nandula
Co-authored-by: Kalfus
EliHei2 pushed a commit that referenced this pull request Jun 1, 2026
[integration/peerlab] Bugfix/tiling issue
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.

[integration/peerlab] Tiling fails in ~3-5% across datasets

1 participant