For auto-regressive prefill-phase, how can I get all token's hidden_states?
for llama model, I want to return the last hidden_states of all tokens. And I already got the hidden_states in py_session with debug_mode. But it's only return the last token's hidden_states shape like [1, 4096].
I debug the trt-build phase in llama/model.py, the IR's shape of hidden_states in forward func is [-1, 4096], Can I assume that we can only generate one by one?
You need to add an output tensor with gather_context = True, then they will outputted as "context_
You need to add an output tensor with gather_context = True, then they will outputted as "context_". You will have to build a model that marks this tensor as an output
hello, can you tell me where to add attr gather_context = True ? thanks!! I add hidden_states as output by hidden_states.mark_output("hidden_states", self.confgi.dtype) or self.register_network_output("hidden_states", hidden_states)[both work]. But both api can't pass "gather_context". Meanwhile, the prefill-context [in trt-llm context-phase], the hidden_states in forward may be with size of [batch_size, prompt_len, hidden_size], but the IR's shape is [-1, hidden_size], so by "self.register_network_output("hidden_states", hidden_states) " or " hidden_states.mark_output("hidden_states", self.confgi.dtype)" only return shape [1, 4096], It make me confused.
- @yweng0828 who may know more details of this question.
June
Solved
Hey @Bobo-y would you mind sharing how you made it work?