Skip to content

Commit

Permalink
integrate multiflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Pop John committed Jul 2, 2024
1 parent d2cd3f9 commit 8c93053
Show file tree
Hide file tree
Showing 6 changed files with 231 additions and 2,226 deletions.
1 change: 1 addition & 0 deletions backend/src/constants/algorithmTypesConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const ALGORITHM_TYPES = {
QUANTIZATION: 'quantization',
MACHINE_UNLEARNING: 'machine_unlearning',
AWQ: 'awq',
MULTIFLOW: 'multiflow',
TRAIN: 'train'
};

Expand Down
12 changes: 11 additions & 1 deletion backend/src/constants/algorithmsConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const PRUNING_PATH = 'examples_pruning/';
const QUANTIZATION_PATH = 'examples_quant/';
const MACHINE_UNLEARNING_PATH = 'examples_unlearning/';
const AUTOAWQ_PATH = 'autoawq/examples/';
const MULTIFLOW_PATH = 'multiflow/';

const PRUNING_ALGORITHMS = {
IPG: {
Expand Down Expand Up @@ -116,12 +117,21 @@ const TRAIN_ALGORITHMS = {
}
};

const MULTIFLOW_ALGORITHMS = {
MULTIFLOW_PRUNE: {
path: MULTIFLOW_PATH,
type: ALGORITHM_TYPES.MULTIFLOW,
fileName: 'prune.py'
}
};

const ALGORITHMS = {
...PRUNING_ALGORITHMS,
...QUANT_ALGORITHMS,
...MACHINE_UNLEARNING_ALGORITHMS,
...AWQ_ALGORITHMS,
...TRAIN_ALGORITHMS
...TRAIN_ALGORITHMS,
...MULTIFLOW_ALGORITHMS
};

module.exports = ALGORITHMS;
16 changes: 12 additions & 4 deletions backend/src/router/scriptsRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,22 @@ function executePythonScript(path, algorithm, args = '', type) {
}

const scriptPath = `${process.env.MACHINE_LEARNING_CORE_PATH}/${path}`;
const cmd = `source ${process.env.CONDA_SH_PATH} && conda activate modelsmith && python3 -u ${scriptPath}${algorithm} ${args}`;
broadcastTerminal(`python3 ${scriptPath}${algorithm} ${args}`);
let cmd;

if (type === ALGORITHM_TYPES.MULTIFLOW) {
cmd = `source "${process.env.CONDA_SH_PATH}" && cd "${process.env.MACHINE_LEARNING_CORE_PATH}/multiflow" && conda activate modelsmith && python3 -u ${algorithm} ${args}`;
pythonCmd = `python3 ${algorithm} ${args}`;
} else {
cmd = `source "${process.env.CONDA_SH_PATH}" && conda activate modelsmith && python3 -u "${scriptPath}${algorithm}" ${args}`;
pythonCmd = `python3 "${scriptPath}${algorithm}" ${args}`;
}

broadcastTerminal(pythonCmd);

executeCommand(
cmd,
(data) => {
console.log(data);
const formattedData = data.toString().replace(/\r\n/g, '');
const formattedData = data.toString();
broadcastTerminal(formattedData);

switch (type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ export class PageRunningScriptSpiningIndicatorService {
this._currentRunningPage.next(PageKey.MODEL_TRAINING);
break;
}
case AlgorithmType.MULTIFLOW: {
this._currentRunningPage.next(PageKey.MODEL_SPECIALIZATION);
break;
}
default: {
this._currentRunningPage.next(PageKey.NONE);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { Component, ViewChild } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { ScriptConfigsDto } from '../../../../services/client/models/script/script-configs.interface-dto';
import { ScriptActions } from '../../../../state/core/script';
import { ScriptFacadeService } from '../../../core/services';
import { AlgorithmType, MultiflowAlgorithmsEnum } from '../../../model-compression/models/enums/algorithms.enum';
import { isScriptActive } from '../../../model-compression/models/enums/script-status.enum';
Expand Down Expand Up @@ -57,7 +58,7 @@ export class ModelSpecializationComponent {
});

setTimeout(() => {
this.form.get('algorithm.alg')?.setValue(MultiflowAlgorithmsEnum);
this.form.get('algorithm.alg')?.setValue(MultiflowAlgorithmsEnum.MULTIFLOW_PRUNE);
}, 0);
}

Expand All @@ -78,17 +79,15 @@ export class ModelSpecializationComponent {
return;
}

const { algorithm, model: modelPanel } = this.form.getRawValue();
const { model } = modelPanel;
const { algorithm } = this.form.getRawValue();

const configs: ScriptConfigsDto = {
...algorithm,
params: {
...this.panelParametersComponent.parametersFormatted,
model
...this.panelParametersComponent.parametersFormatted
}
};

// this.scriptFacadeService.dispatch(ScriptActions.callScript({ configs }));
this.scriptFacadeService.dispatch(ScriptActions.callScript({ configs }));
}
}
Loading

0 comments on commit 8c93053

Please sign in to comment.