|
9 | 9 | from enum import Enum |
10 | 10 | from typing import List, Literal, NamedTuple, Optional, Union |
11 | 11 | import asyncio |
12 | | -from contextlib import nullcontext |
13 | 12 |
|
14 | 13 | import torch |
15 | 14 |
|
@@ -521,19 +520,14 @@ def pre_execute_cb(call_index): |
521 | 520 | # TODO - How to handle this with async functions without contextvars (which requires Python 3.12)? |
522 | 521 | GraphBuilder.set_default_prefix(unique_id, call_index, 0) |
523 | 522 |
|
524 | | - #Do comfy_aimdo mempool chunking here on the per-node level. Multi-model workflows |
525 | | - #will cause all sorts of incompatible memory shapes to fragment the pytorch alloc |
526 | | - #that we just want to cull out each model run. |
527 | | - allocator = comfy.memory_management.aimdo_allocator |
528 | | - with nullcontext() if allocator is None else torch.cuda.use_mem_pool(torch.cuda.MemPool(allocator.allocator())): |
529 | | - try: |
530 | | - output_data, output_ui, has_subgraph, has_pending_tasks = await get_output_data(prompt_id, unique_id, obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb, v3_data=v3_data) |
531 | | - finally: |
532 | | - if allocator is not None: |
533 | | - if args.verbose == "DEBUG": |
534 | | - comfy_aimdo.model_vbar.vbars_analyze() |
535 | | - comfy.model_management.reset_cast_buffers() |
536 | | - comfy_aimdo.model_vbar.vbars_reset_watermark_limits() |
| 523 | + try: |
| 524 | + output_data, output_ui, has_subgraph, has_pending_tasks = await get_output_data(prompt_id, unique_id, obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb, v3_data=v3_data) |
| 525 | + finally: |
| 526 | + if comfy.memory_management.aimdo_enabled: |
| 527 | + if args.verbose == "DEBUG": |
| 528 | + comfy_aimdo.control.analyze() |
| 529 | + comfy.model_management.reset_cast_buffers() |
| 530 | + comfy_aimdo.model_vbar.vbars_reset_watermark_limits() |
537 | 531 |
|
538 | 532 | if has_pending_tasks: |
539 | 533 | pending_async_nodes[unique_id] = output_data |
|
0 commit comments