Add NumPy window-processing engine - #94
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a selectable NumPy-based window-processing engine alongside the existing xarray path, keeping xarray as the public default while routing internal training/evaluation/inference pipelines through NumPy for substantially lower CPU overhead.
Changes:
- Add
engine={"xarray","numpy"}to public selectors/datasets, with NumPy producing canonical(time, individuals, keypoints, space)arrays. - Update augmentation + preprocessing transforms to transparently accept either xarray datasets or canonical NumPy arrays (with
PoseToVideoremaining xarray-only). - Add extensive parity tests and update documentation; adjust the training DataLoader worker heuristic (via
estimate_num_workers) to target 16 samples/worker.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/test_training_helpers.py | Adds coverage for estimate_num_workers and adapts dataloader tests for the new worker-selection path. |
| tests/test_numpy_engine.py | Comprehensive parity tests across engines for selectors, datasets, transforms, and internal pipeline routing. |
| src/lisbet/transforms_extra.py | Adds canonical NumPy handling and dispatch in pose transforms, plus xarray-only enforcement for PoseToVideo. |
| src/lisbet/training/utils.py | Updates worker heuristic default (batch_size_per_worker=16) and exposes helper used by training. |
| src/lisbet/training/tasks.py | Routes configured training/dev datasets through the NumPy engine internally. |
| src/lisbet/training/core.py | Switches dataloader worker selection to the updated estimate_num_workers default behavior. |
| src/lisbet/inference/common.py | Forces inference WindowDataset to use engine="numpy". |
| src/lisbet/evaluation.py | Forces evaluation AnnotatedWindowDataset to use engine="numpy". |
| src/lisbet/datasets/map_style.py | Adds engine argument + tracking to map-style datasets and passes it through selectors. |
| src/lisbet/datasets/iterable_style.py | Adds engine argument and implements NumPy-compatible concatenation paths for iterable datasets. |
| src/lisbet/datasets/common.py | Implements NumPy window selection (padding + interpolation) and annotation caching for NumPy engine. |
| src/lisbet/datasets/init.py | Exports WindowSelector / AnnotatedWindowSelector publicly. |
| src/lisbet/config/schemas.py | Updates augmentation config documentation to reflect container/semantics changes. |
| src/lisbet/cli/commands/train.py | Updates CLI help text to reflect updated augmentation semantics. |
| docs/user_guide/data_preparation.rst | Documents the new window-processing engines and canonical NumPy representation. |
| docs/user_guide/data_augmentation.rst | Documents container support (xarray vs NumPy) and updates augmentation descriptions/examples. |
Comments suppressed due to low confidence (1)
src/lisbet/inference/common.py:197
- The PR description mentions adjusting the worker heuristic from 8→16 samples per worker, but inference still uses
batch_size // 8, so large inference batches can still over-provision DataLoader workers. Consider matching the updated heuristic here (or centralizing on a shared helper) to keep behavior consistent with the change rationale.
engine="numpy",
)
num_workers = min(suggested_max_num_workers(1), batch_size // 8)
prefetch_factor = 4 if num_workers > 0 else None
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
109
to
113
| annot_format=mode, | ||
| engine="numpy", | ||
| ) | ||
| num_workers = min(suggested_max_num_workers(1), batch_size // 8) | ||
| prefetch_factor = 4 if num_workers > 0 else None |
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.
Summary
xarrayand NumPy engines to window selectors and datasets.xarrayas the public default.PoseToTensor.Performance
On CalMS21 task 1 with all four pretraining tasks:
This reduced warm epoch time by 21.3% and CPU work by approximately 14.4x.
Verification
Closes #93.
Follow-up: #92 tracks the existing
TemporalOrdersampling ambiguity.