spec: sparse parameter data is densified at build and in model.parameters
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 領域
- backend, performance
調査の方向性
Start with the sparse parameter attach and storage path used by Model.from_spec, then inspect how model.parameters represents dimensioned data and where constraint rows consume parameters. The issue provides a reproducible example and memory measurements; compare stored and peak memory with the expected input-sized behavior while checking that constraints still receive the needed values.
索引モデルが issue の本文から書いたものです。
説明
[!NOTE]
The following content was generated by AI.
Found in the API review for #1068 (stacked on #958); linopy.spec is unreleased.
Describe the feature you'd like to see
Sparse parameter data is densified onto the full grid of its dimensions at attach time, and the dense array is kept in model.parameters. 50k rows on an 8760 x 2000 grid occupy about 0.8 MB as input but 140 MB as stored parameter, and the build peaks at about 500 MB traced memory.
Minimal reproducible example
import tracemalloc
import warnings
import numpy as np
import pandas as pd
import linopy
warnings.simplefilter("ignore", linopy.EvolvingAPIWarning)
SPEC = """
dimensions: {t: {dtype: int}, g: {}}
parameters: {c: {dims: [t, g], missing: absent}}
variables: {x: {dims: [g], bounds: {lower: 0, upper: 1}}}
objective: {sense: minimize, expression: "sum(x)"}
"""
T = pd.Index(range(8760), name="t")
G = pd.Index([f"g{i}" for i in range(2000)], name="g")
rng = np.random.default_rng(0)
idx = pd.MultiIndex.from_arrays([rng.integers(0, len(T), 50_000), G[rng.integers(0, len(G), 50_000)]], names=["t", "g"])
c = pd.Series(1.0, index=idx[~idx.duplicated()])
print(f"sparse input: {len(c)} rows, {c.memory_usage(deep=True) / 1e6:.1f} MB")
tracemalloc.start()
m = linopy.Model.from_spec(SPEC, {"t": T, "g": G, "c": c})
peak = tracemalloc.get_traced_memory()[1]
tracemalloc.stop()
stored = m.parameters["c"]
print(f"m.parameters['c']: shape {stored.shape}, {stored.nbytes / 1e6:.1f} MB, {int(stored.notnull().sum())} non-NaN")
print(f"peak traced during from_spec: {peak / 1e6:.0f} MB")
Output on spec-simplification:
sparse input: 49938 rows, 0.8 MB
m.parameters['c']: shape (8760, 2000), 140.2 MB, 49938 non-NaN
peak traced during from_spec: 500 MB
Expected
Memory proportional to the supplied rows, not to the product of the dimension sizes, both while building and in model.parameters.
Proposal
Keep sparse parameters sparse through attach and storage (e.g. a long-format or sparse-backed array), densifying only where a constraint row needs it.
- 主要言語
- Python
- スター
- 263
- フォーク
- 92
- 平均マージ
- 1日 13時間
- マージ済み PR(30日)
- 32
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
PyPSA/linopy のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
Constant LinearExpression * multi-term LinearExpression raises TypeError (mirrored product works)対応中かも @anveshachuri が 2 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
PyPSA/linopy#1055 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
bug solver interface
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
-
Validate finite output clamping limits in StepPredictor.prepare_clamping_params to prevent silent NaN/Inf propagation対応中かも @muskan-creates352 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
mllam/neural-lam#848 ·
メンテナーはふだん 2 日以内に返信
-
infra
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
fab-geocommuns/RNB-coeur#1166 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
deepspeedai/DeepSpeed#8951 ·
メンテナーはふだん 2 日以内に返信