feat: parallelize text and multimodal processing in process_document_complete#227
feat: parallelize text and multimodal processing in process_document_complete#227ndcorder wants to merge 2 commits intoHKUDS:mainfrom
Conversation
eede248 to
ab1167c
Compare
|
Thanks for your contribution! I found one P1 issue. In |
These two steps are independent so there's no reason to wait for text insertion before starting multimodal. Uses asyncio.gather with return_exceptions so one failing doesn't kill the other.
…owed asyncio.gather(..., return_exceptions=True) made process_document_complete silently report partially ingested documents as successful: the outer try/except never saw the failure, so on_document_error was skipped and on_document_complete still fired. Keep return_exceptions=True so a failure in one branch does not cancel the sibling (preserves the parallelism win), but after gather collect all task exceptions and re-raise. If both branches fail, raise a single RuntimeError that names the secondary failures and chains the first exception via __cause__. Update the regression test to assert that: - the non-failing branch still completes - the failure propagates out of process_document_complete - on_document_error fires and on_document_complete does not Add a new test covering the both-branches-failing aggregation path. Made-with: Cursor
ab1167c to
5a703a3
Compare
|
@ndcorder Thanks again for putting time into this. After a closer review (and another pass by Codex on the latest commit) we found that the parallelization as implemented has correctness issues that go deeper than just the swallowed-exception fix:
The "text and multimodal are independent" assumption in the PR description doesn't hold for the integration step — only the description-generation phase is truly independent. Separately, RAG-Anything's multimodal pipeline is now being merged into LightRAG itself (HKUDS/LightRAG#2830 merged into the Closing this PR for now. If you'd like to revisit parallelism after the upstream integration settles, the right shape is probably:
Really appreciate the contribution and the clean test suite — sorry this one isn't going in. |
Text insertion and multimodal processing in process_document_complete run sequentially right now but don't share any state. This runs them concurrently with asyncio.gather so total time is max(text, multimodal) instead of text + multimodal.
Uses return_exceptions=True so if one branch fails the other still completes.