Skip to content

Remove static precomputedAlphas bool in affine operation#78

Merged
XapaJIaMnu merged 1 commit intobrowsermt:masterfrom
jelmervdl:fix-gemm-switching
Mar 9, 2022
Merged

Remove static precomputedAlphas bool in affine operation#78
XapaJIaMnu merged 1 commit intobrowsermt:masterfrom
jelmervdl:fix-gemm-switching

Conversation

@jelmervdl
Copy link
Copy Markdown
Member

This fixes a bug when switching between translation models that have different gemm-precision precisions specified in their configuration file. Which is why we never noticed it with our own student models (all int8shiftAlpha), but do see it now with the Ukrainian model (which uses just int8)

I tried to go through git blame to figure out why it was marked static. @XapaJIaMnu please correct me if I'm wrong.

  1. It was introduced in b75168d. Probably as an optimisation?
  2. Then in 2b9e69d the other static variable, static auto map = b->graph()->params()->getMap(); in fetchAlphaFromModel(Expr b) disappears when that function is rewritten into a UnaryNodeOp. But the one removed in this pull request remained.

`b->graph()` changes when switching models in bergamot-translator. That graph can have a new backend that has a different gemm precision specified.
@XapaJIaMnu
Copy link
Copy Markdown
Collaborator

Ah yes, now that the marian instance is kept around, my static optimisations will burn.... And probably a bunch of other things.

And yes the static optimisation was exactly this: avoid doing this check for every affine call as this value would never change once a model is loaded... As long as models are not hot swapped.

This shouldn't show up in the runtime like the calls to shape that you fixed earlier...

@XapaJIaMnu XapaJIaMnu merged commit 7e67124 into browsermt:master Mar 9, 2022
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