Skip to content
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

changed breakdown heuristic #74

Merged
merged 4 commits into from
Jun 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 66 additions & 40 deletions deepview-explore/react-ui/src/utils/utils.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
const GPU_POWER = {
MIN_WATTS: {
"k520": 26,
"a10g": 18,
"t4": 8,
"m60": 35,
"k80": 35,
"v100": 35,
"a100": 46,
"p4": 9,
"p100": 36
},
k520: 26,
a10g: 18,
t4: 8,
m60: 35,
k80: 35,
v100: 35,
a100: 46,
p4: 9,
p100: 36,
},
MAX_WATTS: {
"k520": 229,
"a10g": 156,
"t4": 71,
"m60": 306,
"k80": 306,
"v100": 306,
"a100": 107,
"p4": 76.5,
"p100": 306
}
}
k520: 229,
a10g: 156,
t4: 71,
m60: 306,
k80: 306,
v100: 306,
a100: 107,
p4: 76.5,
p100: 306,
},
};

const BYTE_UNITS = ["B", "KB", "MB", "GB"];

Expand Down Expand Up @@ -143,7 +143,6 @@ export function scalePercentages({ scaleSelector, shouldScale, applyFactor }) {
}

export function getTraceByLevel(tree) {
console.log("getTraceByLevel");
var tree_size = function (idx) {
let total = 1;
let num_children = tree[idx]["num_children"];
Expand All @@ -152,25 +151,44 @@ export function getTraceByLevel(tree) {
tree[idx + total]["parent"] = tree[idx];
total += tree_size(idx + total);
}
return (tree[idx]["total"] = total);
};

var total_time = tree[0]["forward_ms"] + tree[0]["backward_ms"];
var min_frac = 0.5;

var pick_expand = function (idx, expanded) {
let total = 1;
let num_children = tree[idx]["num_children"];

let node_time = tree[idx]["forward_ms"] + tree[idx]["backward_ms"];
let expand = true;
if (expanded || node_time > total_time * min_frac) {
expand = false;
}

tree[idx]["expand"] = expand;

for (let i = 0; i < num_children; i++) {
pick_expand(idx + total, expand | expanded);
total += tree[idx + total]["total"];
}
return total;
};

tree[0]["depth"] = 0;
tree_size(0);
pick_expand(0, false);

let coarseDecomposition = tree.filter((node) => {
return node["depth"] === 1;
});
for (let fineLevel = 1; ; fineLevel++) {
let fineDecomposition = tree.filter((node) => {
return node["depth"] === fineLevel;
});
console.log(`fineLevel: ${fineLevel}, length: ${fineDecomposition.length}`);
if (fineDecomposition.length === 0)
return { coarse: coarseDecomposition, fine: coarseDecomposition };
if (fineDecomposition.length >= 7)
return { coarse: coarseDecomposition, fine: fineDecomposition };
}

let fineDecomposition = tree.filter((node) => {
return node["expand"];
});

return { coarse: coarseDecomposition, fine: fineDecomposition };
}

export function computePercentage(operations, total_time) {
Expand Down Expand Up @@ -239,13 +257,21 @@ export function calculate_training_time(numIterations, instance) {
}

function getGPUAvgPower(gpuName) {
return (GPU_POWER.MAX_WATTS[gpuName] - GPU_POWER.MIN_WATTS[gpuName]) * 0.5 + GPU_POWER.MIN_WATTS[gpuName];
return (
(GPU_POWER.MAX_WATTS[gpuName] - GPU_POWER.MIN_WATTS[gpuName]) * 0.5 +
GPU_POWER.MIN_WATTS[gpuName]
);
}

export function getCarbonDataOfInstance(time, instance, cloudProvider) {
let carbonData = [];
for (let index = 0; index < instance.regions.length; index++) {
let instanceCarbonEmissions = getGPUAvgPower(instance.info.gpu) * instance.info.ngpus * time * cloudProvider.regions[instance.regions[index]].emissionsFactor * cloudProvider.pue;
let instanceCarbonEmissions =
getGPUAvgPower(instance.info.gpu) *
instance.info.ngpus *
time *
cloudProvider.regions[instance.regions[index]].emissionsFactor *
cloudProvider.pue;
const miles = unitScale(
instanceCarbonEmissions * ENERGY_CONVERSION_UNITS["miles"],
"generic"
Expand All @@ -262,11 +288,11 @@ export function getCarbonDataOfInstance(time, instance, cloudProvider) {
carbonEmissions: instanceCarbonEmissions,
miles: `${miles.val} ${miles.scale}`,
household: household,
phone: `${phone.val} ${phone.scale}`
phone: `${phone.val} ${phone.scale}`,
});
}
carbonData.sort(function(a, b) {
return ((a.carbonEmissions < b.carbonEmissions) ? -1 : ((a.x === b.x) ? 0 : 1));
carbonData.sort(function (a, b) {
return a.carbonEmissions < b.carbonEmissions ? -1 : a.x === b.x ? 0 : 1;
});
return carbonData;
}
Expand Down Expand Up @@ -295,12 +321,12 @@ export function getErrMsgFromInvalidURL(type, response) {
case "noJsonResponseFromUrl":
return {
msg: `no json data from url: ${response?.url}`,
code
code,
};
default: // url is not accesible
default: // url is not accesible
return {
msg: `url is not accesible: ${response?.url}`,
code
code,
};
}
}