browsermt / mts

Marian Translation Service
Apache License 2.0
18 stars 4 forks source link

Clean up command line options for intgemm. #1

Open ugermann opened 4 years ago

ugermann commented 4 years ago

If I understand correctly, there are currently there are currently 4 interconnected boolean command line options relating to intgemm

--optimize
--optmize8
--intgemm-shift
--intgemm-shift-all

This does not make sense to me as options are either mutually exclusive (things can't be 8-bit and 16-bit at the same time), or imply one another, e.g. intgemm-shift implies intgemm-shift and intgemm-shift implies optimize8.

These four options should be combined into a single string-valued option --optimize with the values

which are then interpreted in cpu::Backed::configureDevice() in tensor/cpu/backend.h

This should happen sooner rather than later so that we don't have command line interface legacy issues. Easy to fix now, a nightmare to change later once people have started using these options.

cc: @kpu

XapaJIaMnu commented 4 years ago

@ugermann , you are also missing --use-precomputed-alphas

I have proposed a change to the interface in my pull request against master, which unfortunately is not getting any love. I can update this with the proposed changes over the next few days. It's something like --gemm-precision int8/int16/int8shift/int8shiftalpha/int8shiftprecomputedalpha

ugermann commented 4 years ago

You may want to include in that change, if you haven't done so yet, the new Backend::configureDevice() that does device configuration in a single location rather than 3 copies of the same* code block (4 including the server's translation worker, which does not use the Translator class).

ugermann commented 4 years ago

@XapaJIaMnu

you are also missing --use-precomputed-alphas

Missing where? In Backend::configureDevice()?

XapaJIaMnu commented 4 years ago

@ugermann is this approach acceptable to you:

https://github.com/marian-nmt/marian-dev/blob/intgemm_reintegrated/src/tensors/backend.h#L32

If so, I'll go ahead and merge (including the additional options specific to this branch, such as --use-precomputed-alphas).

Cheers,

Nick

ugermann commented 4 years ago
  1. As I mentioned earlier, I already implemented a Backend::configureDevice() member function in the current mt backend branch. I'd greatly prefer if all device configuration happened in that one function and not in four different locations in the code base.

  2. To make the backend branch easier to find in the marian code base, I've created a new branch named mts-backend-stable. We will use that branch for the time being as the official stable branch for the Marian server. At some point, there will probably also be a mt-backend-dev branch.

  3. Removing --optimize from the options will probably lead to backlash when trying to convince the Keepers of the Code to merge, because it may break exisiting scripts/regression tests, etc. The solution that I proposed preserves that backwards compatibility.

  4. --int8 and --int16 in your proposal are still mutually exclusive and should therefore not be boolean flags.

Suggestion: Replace original

  cli.add<bool>("--optimize",
      "Optimize speed aggressively sacrificing memory or precision");

With

  cli.add<std::string>("--optimize",
      "Optimize speed aggressively sacrificing memory or precision using intgemm (CPU only); values 'none', 'int8', 'int16'",
      "none")->implicit_val("int16");

and remove the "int8" and "int16" options.

XapaJIaMnu commented 4 years ago

Hey Uli,

Would this be acceptable? Here's what i coded. https://github.com/marian-nmt/marian-dev/commit/22842e111c88cc54c31f6805d50accc06056ec62 I don't like the number of permutations of intgemm options, so I'm welcome to suggestions.

Cheers,

Nick

ugermann commented 4 years ago

Note to the reader of this thread: conversation continues at marian-nmt/marian-dev@22842e1.

XapaJIaMnu commented 4 years ago

@ugermann, now maybe. I changed it a bit so that it's more similar to what might get into master one day. Also, we need to update all of our scripts.

ugermann commented 4 years ago

I'm lost. Can you point me to the relevant branch/commit? And I'd propose to change 'now maybe' to 'after the review'.

On Mon, Jul 20, 2020 at 7:51 PM Nikolay Bogoychev notifications@github.com wrote:

@ugermann https://github.com/ugermann, now maybe. I changed it a bit so that it's more similar to what might get into master one day. Also, we need to update all of our scripts.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/browsermt/mts/issues/1#issuecomment-661270098, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABCAWO3IYH2YPZJNPR6GZVTR4SG2HANCNFSM4OP3HTUQ .

-- Ulrich Germann Senior Researcher School of Informatics University of Edinburgh

XapaJIaMnu commented 4 years ago

This branch: https://github.com/marian-nmt/marian-dev/compare/cmdparsing

It can definitely wait for after the review. There are some other fixes that should land from the intgemm_reintegrated_computstats branch... whne i code them.