Skip to content

Commit 131ee1c

Browse files
docs: align estimation specs and guides [skip-ci]
1 parent 6c7b497 commit 131ee1c

7 files changed

Lines changed: 207 additions & 134 deletions

‎docs/cx/BENCHKIT_GAP_ANALYSIS.md‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,13 @@ Once the estimation specification is clarified, many other design decisions beco
183183

184184
| 項目 | 仕様上の期待 | 現状実装 | GAP | 優先度 |
185185
|---|---|---|---|---|
186-
| 共通推定エントリ | app 側 `estimate.sh` を薄くし、共通呼び出し順を持つこと | `scripts/estimation/common.sh` と package 呼び出し型の `qws/estimate.sh` がある | 他 app への横展開が未着手 | 最優先 |
186+
| 共通推定エントリ | app 側 `estimate.sh` を薄くし、共通呼び出し順を持つこと | `scripts/estimation/common.sh` と package 呼び出し型の `qws/estimate.sh` がある | 他 app への横展開が未着手。`estimate.sh` 内の宣言ブロックの共通 API も未固定 | 最優先 |
187187
| 軽量推定 package | FOM-only、weak scaling 前提、補正なしなら FOM 一定 | `lightweight_fom_scaling` が実装済み | 参照実装は 1 本のみ。current/future 側で別 model を使う実運用は未整備 | 高 |
188188
| 適用可能性判定 | 不足入力を `applicable/fallback/not_applicable/needs_remeasurement` で扱うこと | `lightweight_fom_scaling` と `instrumented_app_sections_dummy` はこれらを扱え、final Estimate JSON では `applicable`、`partially_applicable`、`fallback`、`not_applicable` を表現できる。requested/applied package の識別も保持できる | 複数 detailed package 間の分岐、より細かい fallback 選択、UI 表示は未実装 | 高 |
189189
| package metadata | package 名、版、required inputs、fallback policy を持つこと | 軽量/詳細ダミーとも最小 metadata を持つ | richer metadata を discovery や UI に活かす実装がまだ無い | 中 |
190-
| section ごとの package 指定 | 区間ごとに推定 package を割り当てられること | `bk_emit_section` / `bk_emit_overlap` から Result JSON に `estimation_package` を載せられ、`instrumented_app_sections_dummy` でも dispatch に利用している | 他 app への横展開と package discovery の整理が未完 | 最優先 |
190+
| section ごとの package 指定 | 区間ごとに推定 package を割り当てられること | `bk_emit_section` / `bk_emit_overlap` から Result JSON に `estimation_package` を載せられ、`instrumented_app_sections_dummy` でも dispatch に利用している | 他 app への横展開と package discovery の整理が未完。app 側が実行前に宣言する形は設計整理済みだが未実装 | 最優先 |
191+
| app 側推定宣言 | app 側が実行前に section / overlap と `estimation_package` をまとめて宣言できること | `estimate.sh` に宣言ブロックを寄せる方向性は整理済み | 宣言 API、既定値の与え方、`run.sh` からの読込み方は未固定。実装も未着手 | 最優先 |
192+
| 追加採取実行 | 通常実行と別に詳細推定入力の採取だけを共通入口から追加実行できること | `run_estimation_data_collection` 方向は整理済み | shell API、分岐条件、保存処理との接続は未実装 | 最優先 |
191193
| section ごとの補助データ参照 | tgz 等の補助データを section ごとに紐付けられること | `qws` では section / overlap ごとに `artifacts` を Result JSON に保持し、詳細ダミー package でも利用している | 他 app への横展開と artifact 収集方式の一般化が未着手 | 高 |
192194
| overlap 推定 | overlap を独立した推定部品として扱えること | Result JSON で保持でき、詳細ダミー package でも overlap の `bench_time/time` は扱える | overlap 専用 package や複数方式切替は未実装 | 中 |
193195
| 詳細推定 package | `instrumented_app_sections` など取得方式別 package を持てること | `instrumented_app_sections_dummy` を `qws` 向け参照実装として実装済み | 実測区間時間や外部ツール区間時間を使う本格 package は未実装 | 最優先 |
@@ -249,11 +251,12 @@ AI 駆動最適化連携は、PoC を含む試行錯誤を前提として早め
249251

250252
### 6.1 短期 / Short Term
251253

252-
1. `estimate.sh` のテンプレートまたは共通補助を整える
253-
2. `qws` 以外に 1 から 2 本の app へ推定を横展開する
254-
3. Estimate JSON と portal 表示を section / overlap 詳細まで整える
255-
4. 再推定比較の UI / API を整える
256-
5. package metadata discovery を portal や比較導線に活かす
254+
1. `estimate.sh` の宣言ブロックと共通補助を整える
255+
2. `run_estimation_data_collection` の共通入口を整える
256+
3. `qws` 以外に 1 から 2 本の app へ推定を横展開する
257+
4. Estimate JSON と portal 表示を section / overlap 詳細まで整える
258+
5. 再推定比較の UI / API を整える
259+
6. package metadata discovery を portal や比較導線に活かす
257260

258261
### 6.2 中期 / Mid Term
259262

‎docs/cx/ESTIMATION_INPUT_ACQUISITION_SPEC.md‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,41 @@ At this stage, this document does not fix whether section / overlap registration
303303

304304
However, the semantic elements ultimately received by BenchKit should preferably be aligned as described above.
305305

306+
### 6.4 app 側宣言ブロック / Application-Side Declaration Block
307+
308+
詳細推定では、app 側が `estimate.sh` の中に推定用の宣言ブロックを持てる形が望ましい。`run.sh` は必要に応じて `estimate.sh` を読み込み、`estimate.sh` 自身は CI や再推定の入口としても使える形にしてよい。
309+
310+
ここで app 側が先に宣言する内容は、少なくとも次が望ましい。
311+
- section 名
312+
- overlap 名
313+
- 各 section / overlap に割り当てる `estimation_package`
314+
- target system や target nodes などの app 既定値
315+
316+
重要なのは、これらの宣言は「何を推定したいか」を先に示すためのものであり、実測値が確定したあとに後付けで決めるものではない、という点である。
317+
318+
### 6.5 `bk_emit_*` との共存 / Coexistence with `bk_emit_*`
319+
320+
`estimate.sh` 内の宣言を導入しても、`bk_emit_section` や `bk_emit_overlap` を直ちに廃止する必要はない。宣言は section / overlap と package 割当てを先に示し、`bk_emit_*` は実際に得られた値を Result JSON に流し込む既存手段として共存してよい。
321+
322+
この形により、少なくとも次の 3 通りが同居できる。
323+
- app 実行中に直接得られた section 時間を `bk_emit_section` で出す
324+
- 実行後のログ解析で得た値を `bk_emit_section` で出す
325+
- 追加採取実行の結果を BenchKit 側でまとめて反映する
326+
327+
### 6.6 追加採取実行 / Additional Data-Collection Run
328+
329+
PAPI のように、通常実行とは別に追加採取実行が必要な入力は、`run_estimation_data_collection` のような共通入口から扱える形が望ましい。
330+
331+
概念的には次の 2 段に分かれる。
332+
1. 通常実行
333+
- 例: `mpiexec a.out ...`
334+
- 主に FOM や通常 section 時間を得る
335+
2. 推定データ採取実行
336+
- 例: `run_estimation_data_collection mpiexec a.out ...`
337+
- package metadata を見て必要な counter / trace / 追加ログ採取を行う
338+
339+
このとき、どの追加採取が必要か、複数回実行が必要か、保存先をどうするかは BenchKit 側で共通化して扱うのが望ましい。app 側は原則として、通常実行コマンドと section / overlap への package 割当てを示せばよい。
340+
306341
## 7. 失敗時の扱い / Failure Handling
307342

308343
### 7.1 採取失敗と実行失敗を分ける / Distinguish Acquisition Failure from Execution Failure
@@ -352,6 +387,8 @@ The application developer should generally only need to ensure:
352387
- auxiliary artifact references can be passed when needed
353388
- application-specific section names can be defined
354389

390+
詳細推定では、これに加えて app 側が `estimate.sh` の宣言ブロックで section / overlap と `estimation_package` の割当てを先に示せるようにしてよい。ただし、採取手順の詳細や保存形式の詳細まで app 側へ押し込めない方が望ましい。
391+
355392
### 8.2 推定パッケージ開発者の責務 / Estimation Package Developer Responsibility
356393

357394
推定パッケージ開発者は、原則として次を定義する。
@@ -386,6 +423,11 @@ BenchKit is generally responsible for:
386423
- handoff into estimation packages
387424
- unified storage and presentation formats
388425

426+
詳細推定では、さらに次も BenchKit 側で扱うのが望ましい。
427+
- `estimate.sh` 内の宣言ブロックの読込み
428+
- package metadata を見た追加採取実行の組立て
429+
- `bk_emit_*` で与えられた値と追加採取結果の合流
430+
389431
## 9. 現時点で固定しないこと / Items Intentionally Left Open
390432

391433
本書は以下を現時点では固定しない。

‎docs/cx/ESTIMATION_PACKAGE_SHELL_API_SPEC.md‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,16 @@ At the initial stage, the following order is recommended:
166166

167167
app 側 `estimate.sh` は、将来的には少なくとも以下だけで済むことが望ましい。
168168

169-
- package の選択
170-
- package の読み込み
171-
- 必要なら app 固有パラメータの設定
169+
- section / overlap と `estimation_package` の割当て宣言
170+
- target system や target nodes など、app 固有の既定値の宣言
171+
- 必要に応じた `run.sh` からの読込み
172172
- 共通の呼び出し順序に従った実行
173173

174174
In the future, application-side `estimate.sh` should preferably be limited to:
175175

176-
- selecting the package
177-
- loading the package
178-
- setting app-specific parameters if needed
176+
- declaring section / overlap to `estimation_package` assignments
177+
- declaring minimal app-specific defaults such as target system or target nodes
178+
- being sourced from `run.sh` when needed
179179
- executing according to the common invocation order
180180

181181
## 7. 参照イメージ / Reference Shape

‎docs/cx/ESTIMATION_PACKAGE_SPEC.md‎

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,16 @@ Here, input means not only the presence of a Result JSON, but at least:
438438
- `not_applicable_when`
439439
- 例: `["missing required section artifact", "unsupported source system"]`
440440
- `fallback_to`
441+
442+
上位パッケージでは、必要であれば次のような項目も持ってよい。
443+
- `supported_section_packages`
444+
- その上位パッケージが受け持てる区間パッケージ名の一覧
445+
- `supported_overlap_packages`
446+
- その上位パッケージが受け持てる overlap パッケージ名の一覧
447+
448+
ここで重要なのは、これらは「使える配下パッケージの集合」を表すものであり、app 固有の section 名そのものを固定で期待するための項目ではない、という点である。どの section にどの package を割り当てるかは app 側 Result JSON の `estimation_package` で表す。
449+
450+
また、区間パッケージ側が `required_artifact_kinds` や system 範囲を定義している場合、それと実際の section / overlap の割当て、必要なデータ採取、採取済みデータの保存・復元との照合は BenchKit 側で扱う。app 側は原則として「section 名」と「どの推定 package を使うか」を決めればよく、採取手順や保存形式の具体記述を直接抱え込まない方がよい。
441451
- 例: `"interval_time_simple"`
442452

443453
For practical use, the package metadata or equivalent documented definition should preferably be able to express at least:
@@ -487,6 +497,11 @@ BenchKit should preferably provide the following:
487497
- Estimate JSON standardization
488498
- retention of package identity metadata
489499

500+
詳細推定では、BenchKit 側が次も扱うのが望ましい。
501+
- 区間パッケージ metadata と section / overlap への割当ての照合
502+
- `required_artifact_kinds` に応じた採取手順の共通化
503+
- 採取済みデータの保存先と復元方法の共通化
504+
490505
### 5.2 app 側責務 / Application-Side Responsibilities
491506

492507
app 側の責務は、原則として以下に留めることが望ましい。
@@ -500,9 +515,12 @@ The application side should preferably be limited to:
500515

501516
- selecting the estimation package to use
502517
- mapping application-specific FOM or section names
503-
- specifying application-specific auxiliary inputs
518+
- assigning an estimation package to each section / overlap
519+
- specifying application-specific auxiliary inputs only when truly necessary
504520
- minimal special handling
505521

522+
特に詳細推定では、app 側は section 名と `estimation_package` の割当てを決めるところまでに責務を寄せ、PAPI の counter set 分割や trace 採取方法、保存形式のような共通化可能な処理は BenchKit 側へ寄せるのが望ましい。
523+
506524
### 5.3 推定パッケージ開発者側責務 / Estimation-Package-Developer Responsibilities
507525

508526
推定パッケージ開発者の責務は、原則として以下を定義することにある。
@@ -569,29 +587,37 @@ These are suitable for deeper analysis and future-system evaluation.
569587

570588
## 7. 参照実装イメージ / Reference Implementation Direction
571589

572-
BenchKit においては、将来的に app 側の `estimate.sh` が毎回すべてを書くのではなく、例えば以下のような形へ寄せることが望ましい。
590+
BenchKit においては、将来的に app 側の `estimate.sh` が毎回すべてを書くのではなく、section / overlap と `estimation_package` の割当て、必要最小限の既定値、共通入口の呼出しだけを書く形へ寄せることが望ましい。
573591

574592
```sh
575-
BK_ESTIMATION_PACKAGE=lightweight_fom_scaling
576593
BK_ESTIMATION_TARGET_SYSTEM=FutureSystemA
594+
BK_ESTIMATION_TARGET_NODES=256
595+
596+
bk_declare_section prepare_rhs interval_time_simple
597+
bk_declare_section compute_hopping counter_papi_detailed
598+
bk_declare_overlap compute_hopping,halo_exchange overlap_max_basic
577599

578-
source scripts/estimation/packages/${BK_ESTIMATION_PACKAGE}.sh
579-
bk_run_estimation_package
600+
source scripts/estimation/common.sh
601+
bk_run_estimation
580602
```
581603

582-
この形では、app 側はパッケージ選択と最小限の app 固有設定を担い、推定方式の詳細はパッケージ側へ集約される。
604+
この形では、app 側は section / overlap への package 割当てと最小限の app 固有設定だけを担い、推定方式の詳細や追加採取は BenchKit と package 側へ集約される。
583605

584-
In BenchKit, a desirable future direction is that application-side `estimate.sh` no longer implements everything each time, but instead looks like:
606+
In BenchKit, a desirable future direction is that application-side `estimate.sh` no longer implements everything each time, but instead focuses on section / overlap package assignments, minimal defaults, and common entrypoints:
585607

586608
```sh
587-
BK_ESTIMATION_PACKAGE=lightweight_fom_scaling
588609
BK_ESTIMATION_TARGET_SYSTEM=FutureSystemA
610+
BK_ESTIMATION_TARGET_NODES=256
611+
612+
bk_declare_section prepare_rhs interval_time_simple
613+
bk_declare_section compute_hopping counter_papi_detailed
614+
bk_declare_overlap compute_hopping,halo_exchange overlap_max_basic
589615

590-
source scripts/estimation/packages/${BK_ESTIMATION_PACKAGE}.sh
591-
bk_run_estimation_package
616+
source scripts/estimation/common.sh
617+
bk_run_estimation
592618
```
593619

594-
In this form, the application side is responsible only for package selection and minimal app-specific configuration, while the details of the estimation method are concentrated in the package.
620+
In this form, the application side is responsible only for assigning packages to sections / overlaps and providing minimal app-specific defaults, while the details of the estimation method and additional data acquisition are concentrated in BenchKit and the packages.
595621

596622
## 8. 現時点で固定しないもの / Items Not Fixed Yet
597623

‎docs/cx/ESTIMATION_SPEC.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,14 +491,14 @@ When only part of the section / overlap / component chain falls back while the o
491491
推定は一度きりの計算ではなく、モデルや仮定の更新に応じて再推定できることが重要である。
492492
BenchKit は、少なくとも以下を扱えるべきである。
493493

494-
- benchmark result を再指定しての再推定
494+
- `estimate_result_uuid` を起点にした再推定
495495
- 推定結果の履歴保持
496496
- 異なる推定方式の比較
497497

498498
Estimation is not a one-time calculation. Re-estimation in response to updated models or assumptions is important.
499499
BenchKit should be able to handle at least:
500500

501-
- re-estimation from a specified benchmark result
501+
- re-estimation starting from `estimate_result_uuid`
502502
- history retention of estimation results
503503
- comparison of different estimation methods
504504

‎docs/guides/add-estimation-package.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,20 @@ output_fields:
248248
fallback_to: interval_time_simple
249249
```
250250

251+
このとき、上位パッケージと区間パッケージで役割を分けておくと整理しやすくなります。
252+
- 上位パッケージ
253+
- どの区間パッケージ群を使って合成できるか
254+
- 何を top-level Estimate JSON に出すか
255+
- 区間パッケージ
256+
- どの system 範囲を受けるか
257+
- section / overlap のどちらを受けるか
258+
- どの採取種別を必要とするか
259+
- 何を出力するか
260+
261+
ここで、上位パッケージは app 固有の section 名を固定で期待しない方がよいです。どの section にどの package を割り当てるかは app 側 Result JSON の `estimation_package` で表します。
262+
263+
PAPI のように複数回の採取が必要な場合でも、package 開発者は「`papi` が必要」と定義するところまでに責務を寄せるのがよいです。どの counter set を何回に分けて取るか、どこへ保存するか、再推定時にどう復元するかは、できるだけ BenchKit 側の共通処理に寄せます。
264+
251265
ここが曖昧なまま実装を始めると、
252266
- package 自体は動く
253267
- でもどの system で使えるのか分からない

0 commit comments

Comments
 (0)