Commit 82608bf
authored
Gh/larryliu0820/46/base (#4643)
* [llava][13/N] Move metadata util to a separate header for reuse
As titled.
[ghstack-poisoned]
* Update on "[llava][13/N] Move metadata util to a separate header for reuse"
As titled.
[ghstack-poisoned]
* Update on "[llava][13/N] Move metadata util to a separate header for reuse"
As titled.
[ghstack-poisoned]
* Update on "[llava][13/N] Move metadata util to a separate header for reuse"
As titled.
[ghstack-poisoned]
* Update on "[llava][13/N] Move metadata util to a separate header for reuse"
As titled.
[ghstack-poisoned]
* [llava][14/N] Refactor runner prefill() and run_model_step()
This refactoring is needed in order to extract out prefill() and
run_model_step() out from runner so that these APIs become replaceable
and easy to plugin and use.
* prefill():
For the case where parallel prefill is enabled or not using kv cache,
the model is able to accept a large block (more than 1) of tokens.
For the other case where we have kv cache but parallel prefill is not
enabled, we can only feed in 1 token every time.
* run_model_step():
This function should not update the input. Instead it should run the
model differently, depending on whether kv cache is enabled. This should
return the next token directly. All the input update needs to happen in
the generation loop.
[ghstack-poisoned]
* Update on "[llava][14/N] Refactor runner prefill() and run_model_step()"
This refactoring is needed in order to extract out prefill() and
run_model_step() out from runner so that these APIs become replaceable
and easy to plugin and use.
* prefill():
For the case where parallel prefill is enabled or not using kv cache,
the model is able to accept a large block (more than 1) of tokens.
For the other case where we have kv cache but parallel prefill is not
enabled, we can only feed in 1 token every time.
* run_model_step():
This function should not update the input. Instead it should run the
model differently, depending on whether kv cache is enabled. This should
return the next token directly. All the input update needs to happen in
the generation loop.
[ghstack-poisoned]
* Update on "[llava][14/N] Refactor runner prefill() and run_model_step()"
This refactoring is needed in order to extract out prefill() and
run_model_step() out from runner so that these APIs become replaceable
and easy to plugin and use.
* prefill():
For the case where parallel prefill is enabled or not using kv cache,
the model is able to accept a large block (more than 1) of tokens.
For the other case where we have kv cache but parallel prefill is not
enabled, we can only feed in 1 token every time.
* run_model_step():
This function should not update the input. Instead it should run the
model differently, depending on whether kv cache is enabled. This should
return the next token directly. All the input update needs to happen in
the generation loop.
[ghstack-poisoned]
* [llava][15/N] Extract out text decoder runner
Last PR #4556 refactored run_model_step() so that it is suitable to be
extracted out as a separate class.
This new `TextDecoderRunner` provides 2 APIs:
* step(tokens, start_pos)
This API takes one or more tokens with start_pos and feed them into Module. Return a tensor of logits.
* logits_to_token(logits)
This API samples the result and returns a token. We don't expect this
logic to change across different runners.
[ghstack-poisoned]
* Update on "[llava][14/N] Refactor runner prefill() and run_model_step()"
This refactoring is needed in order to extract out prefill() and
run_model_step() out from runner so that these APIs become replaceable
and easy to plugin and use.
* prefill():
For the case where parallel prefill is enabled or not using kv cache,
the model is able to accept a large block (more than 1) of tokens.
For the other case where we have kv cache but parallel prefill is not
enabled, we can only feed in 1 token every time.
* run_model_step():
This function should not update the input. Instead it should run the
model differently, depending on whether kv cache is enabled. This should
return the next token directly. All the input update needs to happen in
the generation loop.
Differential Revision: [D60840327](https://our.internmc.facebook.com/intern/diff/D60840327)
[ghstack-poisoned]
* Update on "[llava][15/N] Extract out text decoder runner"
Last PR #4556 refactored run_model_step() so that it is suitable to be
extracted out as a separate class.
This new `TextDecoderRunner` provides 2 APIs:
* step(tokens, start_pos)
This API takes one or more tokens with start_pos and feed them into Module. Return a tensor of logits.
* logits_to_token(logits)
This API samples the result and returns a token. We don't expect this
logic to change across different runners.
Differential Revision: [D60856571](https://our.internmc.facebook.com/intern/diff/D60856571)
[ghstack-poisoned]
* Update base for Update on "[llava][15/N] Extract out text decoder runner"
Last PR #4556 refactored run_model_step() so that it is suitable to be
extracted out as a separate class.
This new `TextDecoderRunner` provides 2 APIs:
* step(tokens, start_pos)
This API takes one or more tokens with start_pos and feed them into Module. Return a tensor of logits.
* logits_to_token(logits)
This API samples the result and returns a token. We don't expect this
logic to change across different runners.
Differential Revision: [D60856571](https://our.internmc.facebook.com/intern/diff/D60856571)
[ghstack-poisoned]
* [llava][16/N] Extract out prefill logic into a new class
Depends on whether parallel or sequential prefill is chosen, prefill()
calls `TextDecoderRunner.step()` to prefill prompt tokens to LLM.
[ghstack-poisoned]
* Update base for Update on "[llava][16/N] Extract out prefill logic into a new class"
Depends on whether parallel or sequential prefill is chosen, prefill()
calls `TextDecoderRunner.step()` to prefill prompt tokens to LLM.
Differential Revision: [D60927756](https://our.internmc.facebook.com/intern/diff/D60927756)
[ghstack-poisoned]
* Update base for Update on "[llava][16/N] Extract out prefill logic into a new class"
Depends on whether parallel or sequential prefill is chosen, prefill()
calls `TextDecoderRunner.step()` to prefill prompt tokens to LLM.
Differential Revision: [D60927756](https://our.internmc.facebook.com/intern/diff/D60927756)
[ghstack-poisoned]
* Update base for Update on "[llava][16/N] Extract out prefill logic into a new class"
Depends on whether parallel or sequential prefill is chosen, prefill()
calls `TextDecoderRunner.step()` to prefill prompt tokens to LLM.
Differential Revision: [D60927756](https://our.internmc.facebook.com/intern/diff/D60927756)
[ghstack-poisoned]
* Update base for Update on "[llava][17/N] Move util.h into /e/llm/runner"
So that it can be reused
Differential Revision: [D60938984](https://our.internmc.facebook.com/intern/diff/D60938984)
[ghstack-poisoned]
* Update base for Update on "[llava][17/N] Move util.h into /e/llm/runner"
So that it can be reused
Differential Revision: [D60938984](https://our.internmc.facebook.com/intern/diff/D60938984)
[ghstack-poisoned]
* [llava][17/N] Move util.h into /e/llm/runner
Differential Revision: D60938984
Pull Request resolved: #45881 parent c04bc99 commit 82608bf
File tree
10 files changed
+447
-293
lines changed- examples/models/llama2/runner
- extension/llm
- runner
- tokenizer
10 files changed
+447
-293
lines changedLarge diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| |||
44 | 46 | | |
45 | 47 | | |
46 | 48 | | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | 49 | | |
59 | 50 | | |
60 | 51 | | |
| |||
65 | 56 | | |
66 | 57 | | |
67 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
68 | 64 | | |
69 | 65 | | |
70 | 66 | | |
| 67 | + | |
| 68 | + | |
71 | 69 | | |
72 | | - | |
73 | 70 | | |
74 | | - | |
75 | | - | |
| 71 | + | |
| 72 | + | |
76 | 73 | | |
77 | | - | |
78 | 74 | | |
79 | 75 | | |
80 | 76 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | 25 | | |
27 | 26 | | |
28 | 27 | | |
| |||
34 | 33 | | |
35 | 34 | | |
36 | 35 | | |
37 | | - | |
| 36 | + | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
7 | 10 | | |
8 | 11 | | |
9 | 12 | | |
10 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
0 commit comments