transformers
65f70d49 - Allow capturing only necessary hidden_states with capture_outputs (#48081)

Commit
80 days ago
Allow capturing only necessary hidden_states with capture_outputs (#48081) * [feat] Add selective hidden-state capture via output_hidden_states_layers. This PR extends the generic output-capturing hook so callers can request only specific hidden-state layers: outputs = model(..., output_hidden_states_layers=[1, 3]) When this argument is provided, hidden-state capture is enabled automatically, but tensors are only retained for the requested layer ids. Non-requested positions are kept as None placeholders so the existing indexing convention remains unchanged Signed-off-by: Wang, Yi A <yi.a.wang@intel.com> * update Signed-off-by: Wang, Yi A <yi.a.wang@intel.com> * add dflash case Signed-off-by: Wang, Yi A <yi.a.wang@intel.com> * format Signed-off-by: Wang, Yi A <yi.a.wang@intel.com> * fmt Signed-off-by: Wang, Yi A <yi.a.wang@intel.com> * remove unnecessary test Signed-off-by: Wang, Yi A <yi.a.wang@intel.com> * use a single kwarg * add general test --------- Signed-off-by: Wang, Yi A <yi.a.wang@intel.com> Co-authored-by: Cyril Vallez <cyril.vallez@gmail.com> Co-authored-by: Cyril Vallez <cyril.vallez@huggingface.co>
Author
Parents
Loading