Skip to content

Refactoring scripts for decision models generation#74

Open
jhozzova wants to merge 5 commits into
HiPerCoRe:developmentfrom
jhozzova:development
Open

Refactoring scripts for decision models generation#74
jhozzova wants to merge 5 commits into
HiPerCoRe:developmentfrom
jhozzova:development

Conversation

@jhozzova

Copy link
Copy Markdown
Member

I propose refactoring the model generation scripts to consume KTT's native JSON output formats (Legacy and T4) instead of CSV files, with automatic schema inference and metadata extraction. This eliminates the manual column-counting workflow and provides forward compatibility with KTT's evolving output formats.

In the old model generation workflow requires users to:

  1. Export tuning results to CSV
  2. Manually count column indices for tuning parameters and profiling counters
  3. Pass ranges like -t 4:12 -c 13:50 to specify which columns contain what data
  4. Manually specify compute capability via --cc

Pain points:

  • Extremely error-prone (off-by-one errors, wrong ranges)
  • No forward compatibility with KTT's JSON formats
  • CSV format doesn't self-describe column semantics
  • User-unfriendly interface requiring manual inspection

Proposed model generation:

  • Automatically detects JSON format (Legacy or T4)
  • Infers tuning parameters, profiling counters, and metadata from JSON structure
  • Extracts device compute capability automatically
  • Maintains identical output format (.sav + .sav.metadata.json)

Tested thoroughly. One known difference is that the new models have tuning parameters always in alphabetical order whereas before the order was the same as in csv file. That should not matter, as tuning parameters are later ordered alphabetically in ProfileBasedSearcher.py itself. The names of global/local size and compilation data are the same as in old model generation, so they can be located by profile-based searcher the same way as before. I have compared models created by those two versions and they have such a high correlation (not the same values, as training data differed) that I can conclude they are functionally the same.

jhozzova added 5 commits July 6, 2026 08:51
Add JSON format detection
Implement detect_format() function to distinguish between T4 and
Legacy KTT JSON schemas.

Add device compute capability lookup
Implement word-boundary device name matching to automatically extract
compute capability from GPU names. Uses regex to avoid false positives
(e.g., 'RTX 500' won't match 'RTX 5000'). Falls back to --cc override
when device unknown. Add lookup table for common GPUs.
Implement T4 format parser
Add T4Parser class to extract tuning parameters, profiling counters,
global/local sizes and compilation data from T4 JSON schema. Filters
out performance metrics (time, power, energy) and ignored measurements
(temperature, frequency, etc.) from profiling counters using exclusion
lists.

Implement Legacy format parser
Add LegacyParser class to extract data from Legacy KTT JSON schema.
Handles Configuration.Pairs for tuning params, ProfilingData.Counters
for profiling data, GlobalSize/LocalSize and CompilationData from
ComputationResults.
Implement build_dataframe() to convert parsed JSON results into
training matrices. Combines tuning params, sizes, profiling
counters and compilation data into ordered columns
with deterministic sorting.

Filters out configurations missing profiling data. Splits into X
(tuning params) and Y (sizes + profiling counters + compilation data)
for sklearn.
Update and document docopt interface for JSON input

Create README.md

Implement main JSON processing pipeline

Add full end-to-end pipeline that loads JSON data, detects format
(T4 vs Legacy), extracts device/compute capability, builds DataFrame,
trains ExtraTreesRegressor, and saves model + metadata.

Pipeline logic:
1. Load JSON file with error handling
2. Detect format using metadata field case
3. Create appropriate parser (T4Parser or LegacyParser)
4. Extract device name and compute capability (with optional override)
5. Extract kernel name for Legacy format (validates single kernel)
6. Build DataFrame with tuning params as X, sizes + counters +
   compilation data as Y
7. Split into train/test sets (configurable via --test-size)
8. Train ExtraTreesRegressor with 10 estimators
9. Evaluate model and print metrics
10. Save model as .sav pickle file
11. Save metadata as .sav.metadata.json

Output naming:
- T4 format: {basename}_DT.sav
- Legacy format: {basename}_{kernel}_DT.sav

Metadata format: {"cc": float, "tp": [params], "pc": [targets]}
The orchestration script was used to make it easier to run
generate_decision_tree_model.py as that one had multiple confusing
and error-prone cmd arguments. Now generate_decision_tree_model.py
takes only one (non-optional) argument and that is json file with data.
The orchestration script is therefore unnecessary.
@jhozzova
jhozzova requested a review from jiri-filipovic July 21, 2026 08:43
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.

1 participant