Skip to content

Commit

Permalink
implement diffusion model layout
Browse files Browse the repository at this point in the history
  • Loading branch information
jolgau committed Jan 8, 2025
1 parent f5bcb3f commit a12071e
Show file tree
Hide file tree
Showing 12 changed files with 458 additions and 10 deletions.
1 change: 1 addition & 0 deletions backend/src/constants/algorithmTypesConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const ALGORITHM_TYPES = {
MACHINE_UNLEARNING: 'machine_unlearning',
AWQ: 'awq',
MULTIFLOW: 'multiflow',
DIFFUSION_MODEL: 'diffusion_model',
TRAIN: 'train'
};

Expand Down
19 changes: 17 additions & 2 deletions backend/src/constants/algorithmsConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const QUANTIZATION_PATH = 'examples_quant/';
const MACHINE_UNLEARNING_PATH = 'examples_unlearning/';
const AUTOAWQ_PATH = 'autoawq/examples/';
const MULTIFLOW_PATH = 'multiflow/';
const DIFFUSION_MODEL_PATH = 'diffusion_model/';

const PRUNING_ALGORITHMS = {
IPG: {
Expand Down Expand Up @@ -118,20 +119,34 @@ const TRAIN_ALGORITHMS = {
};

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

const DIFFUSION_MODEL_ALGORITHMS = {
PTQ4DIT_GET_CALIBRATION_SET: {
path: DIFFUSION_MODEL_PATH / 'ptq4dit/',
type: ALGORITHM_TYPES.DIFFUSION_MODEL,
fileName: 'get_calibration_set.py'
},
PTQ4DIT_QUANT_SAMPLE: {
path: DIFFUSION_MODEL_PATH / 'ptq4dit/',
type: ALGORITHM_TYPES.DIFFUSION_MODEL,
fileName: 'quant_sample.py'
}
};

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

module.exports = ALGORITHMS;
290 changes: 289 additions & 1 deletion backend/src/constants/parametersConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -1527,13 +1527,301 @@ const MULTIFLOW_PARAMETERS = {
]
};

const DIFFUSION_MODEL_PARAMETERS = {
PTQ4DIT_GET_CALIBRATION_SET: [
{
argName: 'model',
defaultValue: 'DiT-XL/2',
inputType: 'select',
label: 'Model Type',
placeholder: 'Select model type',
help: 'Choose the type of model to use for calibration.',
options: [{ value: 'DiT-XL/2', viewValue: 'DiT-XL/2' }]
},
{
argName: 'vae',
defaultValue: 'mse',
inputType: 'select',
label: 'VAE Type',
placeholder: 'Select VAE type',
help: 'Type of VAE to use for sampling.',
options: [
{ value: 'ema', viewValue: 'ema' },
{ value: 'mse', viewValue: 'mse' }
]
},
{
argName: 'image-size',
defaultValue: 256,
inputType: 'select',
label: 'Image Size',
placeholder: 'Select image size',
help: 'Resolution of the generated images.',
options: [
{ value: 256, viewValue: '256' },
{ value: 512, viewValue: '512' }
]
},
{
argName: 'num-classes',
defaultValue: 1000,
inputType: 'number',
label: 'Number of Classes',
placeholder: 'Enter number of classes',
help: 'Number of classes for classification. Default: 1000',
validators: {
min: 1
}
},
{
argName: 'cfg-scale',
defaultValue: 1.5,
inputType: 'number',
label: 'CFG Scale',
placeholder: 'Enter CFG scale value',
help: 'Classifier-free guidance scale. Default: 1.5',
validators: {
min: 0
}
},
{
argName: 'num-sampling-steps',
defaultValue: 250,
inputType: 'number',
label: 'Number of Sampling Steps',
placeholder: 'Enter number of sampling steps',
help: 'Number of sampling steps for diffusion. Default: 250',
validators: {
min: 1
}
},
{
argName: 'seed',
defaultValue: 1,
inputType: 'number',
label: 'Random Seed',
placeholder: 'Enter random seed value',
help: 'Seed for random number generator. Default: 1',
validators: {
min: 0
}
},
{
argName: 'ckpt',
defaultValue: null,
inputType: 'text',
label: 'Checkpoint Path',
placeholder: 'Enter checkpoint path',
help: 'Path to a custom DiT checkpoint (leave blank for auto-download).'
},
{
argName: 'outdir',
defaultValue: 'output/',
inputType: 'text',
label: 'Output Directory',
placeholder: 'Enter output directory path',
help: 'Directory where generated images and logs will be saved.'
},
{
argName: 'filename',
defaultValue: 'imagenet_DiT-512_sample4000_250steps_allst.pt',
inputType: 'text',
label: 'Output Filename',
placeholder: 'Enter output filename',
help: 'Name of the file where generated logs will be saved.'
}
],
PTQ4DIT_QUANT_SAMPLE: [
{
argName: 'model',
defaultValue: 'DiT-XL/2',
inputType: 'select',
label: 'Model Type',
placeholder: 'Select model type',
help: 'Choose the type of model to quantize.',
options: [{ value: 'DiT-XL/2', viewValue: 'DiT-XL/2' }]
},
{
argName: 'vae',
defaultValue: 'mse',
inputType: 'select',
label: 'VAE Type',
placeholder: 'Select VAE type',
help: 'Type of VAE to use for sampling.',
options: [
{ value: 'ema', viewValue: 'ema' },
{ value: 'mse', viewValue: 'mse' }
]
},
{
argName: 'image-size',
defaultValue: 256,
inputType: 'select',
label: 'Image Size',
placeholder: 'Select image size',
help: 'Resolution of the generated images.',
options: [
{ value: 256, viewValue: '256' },
{ value: 512, viewValue: '512' }
]
},
{
argName: 'num-classes',
defaultValue: 1000,
inputType: 'number',
label: 'Number of Classes',
placeholder: 'Enter number of classes',
help: 'Number of classes for classification. Default: 1000',
validators: {
min: 1
}
},
{
argName: 'cfg-scale',
defaultValue: 1.5,
inputType: 'number',
label: 'CFG Scale',
placeholder: 'Enter CFG scale value',
help: 'Classifier-free guidance scale. Default: 1.5',
validators: {
min: 0
}
},
{
argName: 'num-sampling-steps',
defaultValue: 250,
inputType: 'number',
label: 'Number of Sampling Steps',
placeholder: 'Enter number of sampling steps',
help: 'Number of sampling steps for diffusion. Default: 250',
validators: {
min: 1
}
},
{
argName: 'seed',
defaultValue: 1,
inputType: 'number',
label: 'Random Seed',
placeholder: 'Enter random seed value',
help: 'Seed for random number generator. Default: 1',
validators: {
min: 0
}
},
{
argName: 'ckpt',
defaultValue: null,
inputType: 'text',
label: 'Checkpoint Path',
placeholder: 'Enter checkpoint path',
help: 'Path to a custom DiT checkpoint (leave blank for auto-download).'
},
{
argName: 'outdir',
defaultValue: 'output/',
inputType: 'text',
label: 'Output Directory',
placeholder: 'Enter output directory path',
help: 'Directory where generated images and logs will be saved.'
},
{
argName: 'ptq',
defaultValue: false,
inputType: 'checkbox',
label: 'Post-Training Quantization',
help: 'Enable post-training quantization.'
},
{
argName: 'weight_bit',
defaultValue: 8,
inputType: 'number',
label: 'Weight Bits',
placeholder: 'Enter weight quantization bit-width',
help: 'Bit-width for weight quantization. Default: 8',
validators: {
min: 1,
max: 32
}
},
{
argName: 'act_bit',
defaultValue: 8,
inputType: 'number',
label: 'Activation Bits',
placeholder: 'Enter activation quantization bit-width',
help: 'Bit-width for activation quantization. Default: 8',
validators: {
min: 1,
max: 32
}
},
{
argName: 'cali_data_path',
defaultValue: 'sd_coco_sample1024_allst.pt',
inputType: 'text',
label: 'Calibration Data Path',
placeholder: 'Enter calibration dataset path',
help: 'Path to the calibration dataset.'
},
{
argName: 'resume',
defaultValue: false,
inputType: 'checkbox',
label: 'Resume Quantization',
help: 'Resume calibration with existing checkpoint.'
},
{
argName: 'cali_st',
defaultValue: 1,
inputType: 'number',
label: 'Calibration Steps',
placeholder: 'Enter number of calibration timesteps',
help: 'Number of timesteps used for calibration. Default: 1',
validators: {
min: 1
}
},
{
argName: 'cali_batch_size',
defaultValue: 32,
inputType: 'number',
label: 'Calibration Batch Size',
placeholder: 'Enter batch size for calibration',
help: 'Batch size used for model calibration. Default: 32',
validators: {
min: 1
}
},
{
argName: 'inference',
defaultValue: false,
inputType: 'checkbox',
label: 'Perform Inference',
help: 'Enable inference on all classes.'
},
{
argName: 'n_c',
defaultValue: 10,
inputType: 'number',
label: 'Number of Samples per Class',
placeholder: 'Enter number of samples per class for inference',
help: 'Number of samples generated per class for inference. Default: 10',
validators: {
min: 1
}
}
]
};

const ALGORITHM_PARAMETERS = {
...QUANTIZATION_PARAMETERS,
...PRUNING_PARAMETERS,
...MACHINE_UNLEARNING_PARAMETERS,
...AWQ_PARAMETERS,
...TRAIN_PARAMETERS,
...MULTIFLOW_PARAMETERS
...MULTIFLOW_PARAMETERS,
...DIFFUSION_MODEL_PARAMETERS
};

module.exports = ALGORITHM_PARAMETERS;
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ export enum PageKey {
MODEL_TRAINING = 'MODEL_TRAINING',
AWQ = 'AWQ',
MODEL_SPECIALIZATION = 'MODEL_SPECIALIZATION',
DIFFUSION_MODEL = 'DIFFUSION_MODEL',
NONE = 'NONE'
}
1 change: 0 additions & 1 deletion frontend/src/app/modules/core/services/icons.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export class IconsService {
* @param iconPath The relative path to the SVG file.
*/
registerIcon(iconName: string, iconPath: string): void {
console.log(iconName, iconPath);
this.matIconRegistry.addSvgIcon(iconName, this.domSanitizer.bypassSecurityTrustResourceUrl(iconPath));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ export class PageRunningScriptSpiningIndicatorService {
this._currentRunningPage.next(PageKey.MODEL_SPECIALIZATION);
break;
}
case AlgorithmType.DIFFUSION_MODEL: {
this._currentRunningPage.next(PageKey.DIFFUSION_MODEL);
break;
}
default: {
this._currentRunningPage.next(PageKey.NONE);
break;
Expand Down
Loading

0 comments on commit a12071e

Please sign in to comment.