Skip to content

Fix performance issues related to memory usage during feature engineering - #183

Merged
ch55secake merged 5 commits into
mainfrom
copilot/reduce-memory-footprint-feature-engineering
Apr 20, 2026
Merged

Fix performance issues related to memory usage during feature engineering#183
ch55secake merged 5 commits into
mainfrom
copilot/reduce-memory-footprint-feature-engineering

Conversation

Copilot AI commented Apr 19, 2026

Copy link
Copy Markdown
Contributor

Description

Holding all raw OHLCV data, per-ticker engineered features, and concatenated train/test frames simultaneously causes significant memory pressure for large ticker universes. This PR cuts peak memory by ~50%+ through dtype downcasting and explicit object lifetime management.

Changes in this pull request

  • feature_engineering.pyprepare_features() downcasts all float64 feature columns to float32 after matrix construction
  • base_pipeline.py_add_stock_features() writes beta, avg_volume_log, market_cap_log as np.float32 scalars so no float64 leaks into the final matrix
  • stacked_pipeline.py — sets self._stock_data = None post feature-engineering loop; clears each per-ticker list immediately after its pd.concat
  • Tests: test_numeric_feature_columns_are_float32, test_categorical_columns_not_downcast, test_feature_matrix_uses_float32, test_stock_data_freed_after_prepare_features
  • tests/model/test_stacked_pipeline.py — reformatted with ruff format .

Agent-Logs-Url: https://github.com/ch55secake/hyperion/sessions/80782c30-a563-4add-8966-f9ce65052b7d

Co-authored-by: ch55secake <87881861+ch55secake@users.noreply.github.com>
@ch55secake
ch55secake marked this pull request as ready for review April 20, 2026 21:03
@ch55secake ch55secake changed the title [WIP] Fix performance issues related to memory usage during feature engineering Fix performance issues related to memory usage during feature engineering Apr 20, 2026
@ch55secake

Copy link
Copy Markdown
Owner

@copilot Run ruff format .

Agent-Logs-Url: https://github.com/ch55secake/hyperion/sessions/8eb2d025-fe63-4e38-9e1b-08f07ce307ad

Co-authored-by: ch55secake <87881861+ch55secake@users.noreply.github.com>

Copilot AI commented Apr 20, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Run ruff format .

Done — ruff format . reformatted tests/model/test_stacked_pipeline.py (commit cd0733e).

@ch55secake
ch55secake merged commit ff37bb8 into main Apr 20, 2026
8 checks passed
@ch55secake
ch55secake deleted the copilot/reduce-memory-footprint-feature-engineering branch April 20, 2026 21:10
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.

Performance: Reduce memory footprint during multi-interval feature engineering

2 participants