Skip to content

smart ratio v3 init - #25

Open
jysohn1108 wants to merge 34 commits into
masterfrom
pt_sr
Open

jysohn1108 wants to merge 34 commits into
masterfrom
pt_sr

Conversation

@jysohn1108

Copy link
Copy Markdown
Collaborator

Do not merge for now

jysohn1108 and others added 7 commits February 4, 2022 01:19
i'm sure i broke a few things, but this should be more amenable
to autodiff
turns out the device_error was due to this, hiding under the pretense
of multithreading
Comment thread SmartRatio.py Outdated
# if we use modified version of smart ratio
if parser_args.sr_version == 2:
if parser_args.sr_version >= 2:
if parser_args.arch.lower() != 'resnet20':

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This stuff is okay while debugging but make sure to remove it before we merge :)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

sry I didn't get it.. so we need to remove this line 93 handling different SR versions?

Comment thread SmartRatio.py Outdated

if parser_args.sr_version == 2:
# followed the result in https://github.com/ksreenivasan/results_repo_pruning/blob/master/per_layer_sparsity_resnet20/hc_iter.csv
if parser_args.smart_ratio == 0.9856: # 1.44% sparsity

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Can we move these things to the config or a csv file?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

yeah let me change it to load values from a csv file :)

Comment thread main.py
if parser_args.random_subnet:
test_random_subnet(model, data, criterion, parser_args, result_root, parser_args.smart_ratio)
return
exit()

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I'm guessing this is debug?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

as I know, we want to end program from here, since test_random_subnet will do until finetune & save the result.
I found that the program is not exiting if we use "return" here, so added exit() instead.

Comment thread main_utils.py Outdated
def init_smart_ratio(parser_args):
if parser_args.arch.lower() == 'resnet20':
if parser_args.target_sparsity == 3.72:
parser_args.init_sr = np.array([41.43518518518518, 24.305555555555557, 21.875, 19.57465277777778, 17.36111111111111,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Like above. Would be preferable if this is a config thing, or reads from a csv.

Comment thread utils/conv_type.py
return g_1, g_2, None, None, None


class GetRandomSubnet(autograd.Function):

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This is the new function. The reason I had to do this is because the parameters are now 1 dimensional. So the gradients are of different shape

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thank you so much!

Comment thread utils/conv_type.py
if parser_args.algo == 'pt_sr':
#self.layer_score = nn.Parameter(torch.Tensor([parser_args.init_sr[parser_args.current_layer]]))
self.layer_weight_ratio = nn.Parameter(torch.Tensor(1))
self.layer_weight_ratio.data = torch.Tensor([0.5])

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

this is where ratios are initialized at 0.5

@ksreenivasan

Copy link
Copy Markdown
Owner

https://github.com/ksreenivasan/pruning_is_enough/blob/master/utils/net_utils.py#L531
You'll have to change some code here (because it calls GetSubnet() when it should really be calling GetRandomSubnet()

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.

2 participants