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

[MPQEditor] Create or edit mixed precision quantization json file. #1505

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

stamalakhov
Copy link
Contributor

@stamalakhov stamalakhov commented Feb 16, 2023

This commit allows to create or edit mixed precision quantization json file.
To use the tool the following actions are suggested:

  1. right-click in explorer any circle model
  2. context menu should contain "Create MPQ json" - click it
  3. provide name for new .json
  4. after creation of new json we may edit it

Related: #1491
ONE-vscode-DCO-1.0-Signed-off-by: s.malakhov s.malakhov@partner.samsung.com

@stamalakhov stamalakhov self-assigned this Feb 16, 2023
@stamalakhov stamalakhov force-pushed the manual_MPQ_BR branch 2 times, most recently from 3702a75 to ea65d9e Compare February 16, 2023 08:02
@stamalakhov
Copy link
Contributor Author

More info:
1_2
gen_info
select_layers
show_model_graph
VISQ_INFO

@@ -52,6 +52,7 @@ const viewMode = {
viewer: 0, // default circle viewer
selector: 1, // circle partition editor node selector
visq: 2, // quantization error viewer
visqselr: 3, //quantization error viewer whicj is able to select nodes
Copy link
Contributor

Choose a reason for hiding this comment

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

typo whicj

Copy link
Contributor

Choose a reason for hiding this comment

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

why is this mode added?
what is visqselr? this word is hard to read.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

why is this mode added?

new mode is intended to provide .visq colormap, as well as selector capabilities to provide a user handy selection of nodes.

what is visqselr? this word is hard to read.

Yes. The name is hard to read, i'll gladly change it with any other more fortunate name.

} else if (message.mode === "visq") {
this._mode = viewMode.visq;
} else if (message.mode === "visqselr") {
this._mode = viewMode.visqselr;
Copy link
Contributor

Choose a reason for hiding this comment

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

only put this line as there is no other 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.

only put this line as there is no other change

Sorry. I don't quite get it. Current implementation assumes that we can change html _mode to another mode, so these lines are intended to provide full enumeration of viewMode, but for now only visqselr is enough.

Copy link
Contributor

Choose a reason for hiding this comment

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

but for now only visqselr is enough.

this is the point. check only for visqselr. setting to other modes are never called.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahhh. Thank you. Ok.

@jinevening
Copy link

Q) How visq info is created? Is it assumed to be generated before? If so, it would be better to give instruction on how to make visq info (e.g., making a small question mark icon near the "Load visq info" button). BTW, is it possible to create visq info in ONE-vscode?

(optional) I think it is better to show the model graph by default when the tab is first created. I guess most users will want to select layers in the graph with visq info.

@stamalakhov stamalakhov marked this pull request as draft February 17, 2023 05:19
@stamalakhov
Copy link
Contributor Author

Q) How visq info is created? Is it assumed to be generated before?

Yes, for this draft it was generated before.

If so, it would be better to give instruction on how to make visq info (e.g., making a small question mark icon near the "Load visq info" button)

ok.

BTW, is it possible to create visq info in ONE-vscode?

I'll investigate it.

(optional) I think it is better to show the model graph by default when the tab is first created. I guess most users will want to select layers in the graph with visq info.

Ok.

I'll be back with reworked draft.

@stamalakhov
Copy link
Contributor Author

stamalakhov commented Feb 17, 2023

Currently the workflow looks like this:

last_screen_cast

@stamalakhov stamalakhov force-pushed the manual_MPQ_BR branch 2 times, most recently from b87a618 to a9ebb2d Compare February 20, 2023 09:56
@stamalakhov
Copy link
Contributor Author

BTW, is it possible to create visq info in ONE-vscode?

I've tried to introduce visq data computation into MPQEditor and it occured to be heavy:
input for float model
input for quantized model
input for h5 data
ouput for MPEIR mode
ouput for MSE mode
...
to be continued

IMHO for visq component we may try to create additional command in ONE-vscode.
@jinevening
May be we could do another item in context menu for circle file like "Create VISQ data" ?

@stamalakhov
Copy link
Contributor Author

@jinevening @seanshpark
Please see docs/MPQEditor.md for readme.
For now model-graph-view is opened by default.
And help btn is also introduced into visq_path input.
image

@seanshpark
Copy link
Contributor

seanshpark commented Feb 20, 2023

Thanks for video attach at #1505 (comment) :)

Q1) what happens if wrong json (not visq info content) is selected in visq info ?
Q2) what happens if wrong json (visq info content but for different model) is selected in visq info ?
Q3) there seems to be no way to clear loaded visq info. is there any particular reason for this?

model.json filename doesn't seem to be appropriate. we can't distinguish by just .json. how about use model.blabla.json ? @jinevening , do you have any good word for blabla ?

package.json Outdated Show resolved Hide resolved
}

public onLoadVisqInfo(visqPath: string) {
const fileData = fs.readFileSync(visqPath, { encoding: "utf8", flag: "r" });
Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIK, it's rather safer to use vscode.workspace.fs.readFile instead of fs.readFileSync. Related issue: #746

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. Thank you. I didn't know that.

if (this._panel.visible) {
// NOTE if we call this.update(), it'll reload the model which may take time.
// TODO call conditional this.update() when necessary.
// this.update();
Copy link
Contributor

Choose a reason for hiding this comment

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

Q. Is it fine with this.update() being commented out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah... Sorry. I'll remove that.

Comment on lines 222 to 223
// let parsedPath = path.parse(args.docPath);
// let fileBase = path.join(parsedPath.dir, parsedPath.name);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could it be removed, if it's not used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahhh.. Sorry. These lines will be removed.

5) all layers from 'layers' section in json are shown in grid-table, so that their options for quantization can be edited using their respective dropdowns
6) to make 'model-graph-view' more informative the user may use 'visq' information, it shows which layers are more sensitive to quantization than others

<img src="./images/MPQ_UI.png"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

please refine this image. do not use red color for text. use smaller size for explanation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Add "Default Parameters" in GUI not in this image.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahhh... Sorry. I'll fix it.

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.

None yet

4 participants