-
Notifications
You must be signed in to change notification settings - Fork 30
feat: measuring compute efficiency per job #221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 100 commits
b4235fb
27b8610
7e6b369
ed1beaf
c50d28e
7c0e434
d947665
bd3d900
15f7892
f61ab7c
f55f8b0
2861539
474ead0
6da5674
7a51cf9
0a3c17b
9c8ffc0
8faafba
b78baeb
7f49ee5
c53937c
b3f80d8
9f8ed3e
dba70d8
d69a0b1
be45e7b
bf18d2b
8f5de00
bb4c85e
bc1f024
8d0f20f
11862ed
4b671e3
9361226
3cac42c
317a2af
f59d03d
641beb3
8baba42
92c3531
8321d29
5c21a1b
5686272
8007365
4cfac88
aca969c
7cf6c86
bfbc3a6
545f00d
2cc48a3
c4a1385
dd6e897
a9f1ceb
c38d11e
548eba6
acee2a6
a2ce419
212143d
1f31fc0
22f8715
a48eea5
22c3244
4ff426f
a3a1f34
a265e8c
bd4c173
1e06187
266aa41
05019fb
135c47a
af84f85
ebeb08b
2d1b041
bf3e88f
082e01a
4e99e32
67b0671
a1c5ba2
86ff31a
0cb4b7f
b433010
efd6398
7267dab
2c334ad
a26e395
02a855d
ee59544
db9116a
a0a0618
96551c6
7c8e3d6
4167460
07d663a
55e7d58
2dbc6a8
aadbf8c
820a9db
b56bf06
2b72aa4
8b2e100
fb826d1
930b70e
cb3db0c
91815df
f983322
66f0dc3
602db18
b7c80ef
012ce8f
761b562
067fac7
ece91e1
856601e
29a44de
5746c6e
4b411b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,50 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import re | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import pandas as pd | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
def time_to_seconds(time_str): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"""Convert SLURM time format to seconds.""" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if pd.isna(time_str) or time_str.strip() == "": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
parts = time_str.split(":") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if len(parts) == 3: # H:M:S | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return int(parts[0]) * 3600 + int(parts[1]) * 60 + float(parts[2]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
elif len(parts) == 2: # M:S | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return int(parts[0]) * 60 + float(parts[1]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
elif len(parts) == 1: # S | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return float(parts[0]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
def parse_maxrss(maxrss): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"""Convert MaxRSS to MB.""" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if pd.isna(maxrss) or maxrss.strip() == "" or maxrss == "0": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
match = re.match(r"(\d+)([KMG]?)", maxrss) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if match: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
value, unit = match.groups() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
value = int(value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
unit_multipliers = {"K": 1 / 1024, "M": 1, "G": 1024} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return value * unit_multipliers.get(unit, 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cmeesters marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
def parse_reqmem(reqmem, number_of_nodes=1): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"""Convert requested memory to MB.""" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if pd.isna(reqmem) or reqmem.strip() == "": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
match = re.match( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
r"(\d+)([KMG])?(\S+)?", reqmem | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
) # Handles "4000M" or "4G" or "2G/node" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if match: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
value, unit, per_unit = match.groups() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
value = int(value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
unit_multipliers = {"K": 1 / 1024, "M": 1, "G": 1024} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
mem_mb = value * unit_multipliers.get(unit, 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if per_unit and "/node" in per_unit: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# the memory values is per node, hence we need to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# multiply with the number of nodes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return mem_mb * number_of_nodes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return mem_mb # Default case (per CPU or total) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+38
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion NaN propagation & ‘/cpu’ interpretation
Consider: - if per_unit and "/node" in per_unit:
- # the memory values is per node, hence we need to
- # multiply with the number of nodes
- return mem_mb * number_of_nodes
- return mem_mb # Default case (per CPU or total)
+ if per_unit:
+ if "/node" in per_unit:
+ return mem_mb * (number_of_nodes if pd.notna(number_of_nodes) else 1)
+ if "/cpu" in per_unit:
+ # multiply by CPUs per task later; keep per-cpu value for now
+ return mem_mb
+ return mem_mb 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @coderabbitai - there is no data frame present in this function. Hence, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain@cmeesters You're absolutely right about Let me search for SLURM documentation about memory specification formats to clarify the For the NaN handling in scalar context, here's the corrected approach: if per_unit and "/node" in per_unit:
# Guard against NaN/None values in number_of_nodes
if number_of_nodes is None or (isinstance(number_of_nodes, float) and math.isnan(number_of_nodes)):
return mem_mb # fallback to treating as total
return mem_mb * number_of_nodes However, since you're passing 🌐 Web query:
💡 Result: In SLURM, the
For example, if a job requests 4 GB of memory per CPU and is allocated 2 CPUs, the This format allows users to specify memory requirements based on the number of CPUs or nodes allocated to the job. For more detailed information, refer to the SLURM documentation on the Citations: Thank you for the correction! Based on the SLURM documentation, I found the official format for the According to SLURM documentation:
However, there's a discrepancy: Your current code checks for
Corrected function based on documented format: def parse_reqmem(reqmem, number_of_nodes=1):
"""Convert requested memory to MB."""
if pd.isna(reqmem) or reqmem.strip() == "":
return 0
match = re.match(r"(\d+(?:\.\d+)?)([KMG])?([cn]?)", reqmem)
if match:
value, unit, per_unit = match.groups()
value = float(value)
unit_multipliers = {"K": 1 / 1024, "M": 1, "G": 1024}
mem_mb = value * unit_multipliers.get(unit, 1)
if per_unit == "n": # per node
return mem_mb * max(number_of_nodes, 1) # avoid multiplication by 0
elif per_unit == "c": # per CPU - needs CPU count from caller
return mem_mb # Return per-CPU value; caller handles multiplication
return mem_mb # Default: total memory
return 0 Recommendation: Since you found 🧠 Learnings used
Comment on lines
+38
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion
- match = re.match(
- r"(\d+)([KMG])?(\S+)?", reqmem
- )
+ # 4Gc (per-CPU) / 16Gn (per-node) / 2.5G
+ match = re.match(r"(\d+(?:\.\d+)?)([KMG])?([cn]|/node)?", reqmem) - value = int(value)
+ value = float(value) - if per_unit and "/node" in per_unit:
- return mem_mb * number_of_nodes
+ if per_unit in ("n", "/node"): # per node
+ nodes = 1 if pd.isna(number_of_nodes) else number_of_nodes
+ return mem_mb * nodes
+ # `/c` or `c` → per-CPU; caller may multiply later Catches 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
Uh oh!
There was an error while loading. Please reload this page.