Fix device state restoration in NamedEntityExtractor and add release …#11259
Fix device state restoration in NamedEntityExtractor and add release …#11259ritikraj2425 wants to merge 5 commits intodeepset-ai:mainfrom
Conversation
|
@ritikraj2425 is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
|
Hey @ritikraj2425 is this an issue you were running into with scripts you were running yourself? Also please look at the failing CI and fix the issues there. |
|
Hi @sjrl! I also pushed a fix for the CI. I had mistakenly placed my new device restoration test in the standard unit tests (where spaCy isn't installed in CI), causing an ImportError during collection. I have now moved it to the e2e pipeline tests where the spaCy backend is properly tested. Let me know if there's anything else I should adjust! |
Related Issues
Proposed Changes:
Previously, the
NamedEntityExtractor(spaCy backend) would unconditionally callspacy.require_cpu()after execution. SincespaCyandThincuse a global state for device configuration, this would override any pre-existing user configuration (e.g., if the user was using a specific GPU for other parts of their application).This PR:
Opsstate at the start of the_select_devicecontext manager.Opsstate in thefinallyblock instead of forcing a reset to CPU.TODOregarding device restoration.How did you test it?
TestNamedEntityExtractorDeviceRestorationtotest/components/extractors/test_named_entity_extractor.py. This test sets a custom attribute on the globalOpsobject and verifies that it is preserved after the component's internal device switching logic.NamedEntityExtractortest suite (11 tests passed).NumpyOpsobjects are not replaced by fresh instances after component execution.Checklist
fix:.