Skip to content

For Arne#4

Open
ribalba wants to merge 7 commits intomainfrom
fixes
Open

For Arne#4
ribalba wants to merge 7 commits intomainfrom
fixes

Conversation

@ribalba
Copy link
Contributor

@ribalba ribalba commented Feb 13, 2026

So you can see what I have changed

@ribalba
Copy link
Contributor Author

ribalba commented Feb 13, 2026

@ArneTR can you see how this performs. I create the data with running energy-logger and then benchmark --rounds 10 Also I added --trim-upper-quantile 99 as a parameter to the ./model to remove outliers. Also I now sample randomly for the test set.

@ArneTR ArneTR mentioned this pull request Mar 18, 2026
Copy link
Collaborator

@ArneTR ArneTR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code works. Comments inline

rcu_read_lock();
struct task_struct *p = pid_task(find_vpid(pid), PIDTYPE_PID);
alive = p && pid_alive(p);
task = pid_task(find_vpid(tgid), PIDTYPE_TGID);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed all the alive saving as this was quite the overhead.

return task;
}

static int ensure_pid_entry(u32 tgid)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain what this does and why it is necessary and was not necessary before?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is the same thing as below but only in a function and changed to work on tasks and not threads/processes


rcu_read_lock();
u32 tgid = task_tgid_nr(t);
/* discover tasks that do not have a pid entry yet */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you summarize for the changes from here until the end of the file why you changed this and what is the expected gain?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mainly changed it from processes to tasks and now remove tasks that are not alive anymore.

q = train_df["target_uj"].quantile(quantile)
return (
train_df[train_df["target_uj"] <= q],
test_df[test_df["target_uj"] <= q],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not trim the test set also as this skews the information about its prediction power

tools/model.py Outdated


def main() -> None:
parser = argparse.ArgumentParser(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment the code cannot compare to a new out of sample file. I opened up a PR to do so #5

)


def fit_nonnegative_ridge(X: np.ndarray, y: np.ndarray, alpha: float) -> np.ndarray:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this model be used in the kernel? Or is it just to showcase?

To my understanding this uses no intercept. But I believe we should have one

@ArneTR
Copy link
Collaborator

ArneTR commented Mar 18, 2026

Just for documentation purposes these are the results I am getting when running this code out of the box:

(venv) arne@framebook:~/Sites/procpower/tools$ python3 model.py /tmp/energy-gKpkxu81.log --mode delta --alpha 10
# mode=delta alpha=10.0
# rows_total=1246 rows_train=995 rows_test=250

# --- test metrics (current module defaults) ---
R2     : -3.00767
RMSE   : 3340332.139 uJ
MAE    : 2897199.311 uJ
MAPE   : 99.824 %

# --- test metrics (linear non-negative ridge) ---
R2     : 0.87867
RMSE   : 581195.727 uJ
MAE    : 502103.984 uJ
MAPE   : 27.267 %

# --- test metrics (nonlinear reference) ---
R2     : 0.99567
RMSE   : 109762.387 uJ
MAE    : 72772.653 uJ
MAPE   : 3.640 %

# --- test metrics (distilled kernel model) ---
R2     : 0.89540
RMSE   : 539636.194 uJ
MAE    : 459136.968 uJ
MAPE   : 24.124 %

# --- train metrics (distilled kernel model) ---
R2     : 0.90925
RMSE   : 517380.926 uJ
MAE    : 453785.128 uJ
MAPE   : 24.045 %

I have also seen better runs on my system though where test metrics (distilled kernel model) goes down to 16% error rate. The reason for that is unknown.

Copy link
Contributor Author

@ribalba ribalba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As already mentioned I didn't spend to much time on the procpower refactoring. I even forgot I had done that, as already mentioned. I will have to work on this again at some stage to validate everything.

rcu_read_lock();
struct task_struct *p = pid_task(find_vpid(pid), PIDTYPE_PID);
alive = p && pid_alive(p);
task = pid_task(find_vpid(tgid), PIDTYPE_TGID);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed all the alive saving as this was quite the overhead.

return task;
}

static int ensure_pid_entry(u32 tgid)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is the same thing as below but only in a function and changed to work on tasks and not threads/processes


rcu_read_lock();
u32 tgid = task_tgid_nr(t);
/* discover tasks that do not have a pid entry yet */
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mainly changed it from processes to tasks and now remove tasks that are not alive anymore.

@ribalba
Copy link
Contributor Author

ribalba commented Mar 19, 2026

(venv) didi@fedora:~/code/procpower/tools$ python3 model.py /tmp/energy-kIyAfwhh.log --mode delta --alpha 10
# mode=delta alpha=10.0
# rows_total=2678 rows_train=2139 rows_test=536

# --- test metrics (current module defaults) ---
R2     : -1.12845
RMSE   : 6359584.911 uJ
MAE    : 4649711.760 uJ
MAPE   : 99.898 %

# --- test metrics (linear non-negative ridge) ---
R2     : 0.91347
RMSE   : 1282310.178 uJ
MAE    : 1077131.597 uJ
MAPE   : 27.082 %

# --- test metrics (nonlinear reference) ---
R2     : 0.77467
RMSE   : 2069211.622 uJ
MAE    : 421845.440 uJ
MAPE   : 6.913 %

# --- test metrics (distilled kernel model) ---
R2     : 0.90722
RMSE   : 1327807.047 uJ
MAE    : 1077579.672 uJ
MAPE   : 27.704 %

# --- train metrics (distilled kernel model) ---
R2     : 0.96312
RMSE   : 1714277.637 uJ
MAE    : 1106326.862 uJ
MAPE   : 26.251 %

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.

2 participants