Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

advanced params refactoring + prevent users from skipping/stopping other users tasks in queue #981

Conversation

mashb1t
Copy link
Collaborator

@mashb1t mashb1t commented Nov 18, 2023

Relates to #826
Fixes #713
Fixes #501

fixes inconsistency in behaviour of stop_button and skip_button as it was possible to skip or stop other users processes while still being in queue.

Expected:
sessions are completely separate, no interference or control by other users except yourself

Actual:
one can skip and stop tasks of others

Steps to reproduce:

  1. open 2 tabs
  2. click "generate" in tab 1
  3. click "generate" in tab 2
  4. see skip/stop button in tab 2
  5. click skip/stop button in tab 2, task for tab1 skips/stops

this is also possible using x tabs, where the last tab clicking "generate" can skip all previous queued tasks

…ess starts

fix inconsistency in behaviour of stop_button and skip_button as it was possible to skip or stop other users processes while still being in queue
@lllyasviel
Copy link
Owner

yes this is a reasonable problem and should fix.
nevertheless this also disable me from stopping a task rightly after click generate.
previously i can click stop rightly after generate, though a bit laggy

@mashb1t
Copy link
Collaborator Author

mashb1t commented Nov 18, 2023

shared.last_stop could be handled not in shared but in the AsyncTask object to achieve true separation. Then skip_clicked and stop_clicked could set the property on AsyncTask and the worker could handle the process accordingly.

What would be your proposal?

@mashb1t mashb1t force-pushed the hotfix/prevent-skipping-and-stopping-by-other-users branch from 26c0cff to f5c17fb Compare November 18, 2023 19:50
@mashb1t mashb1t force-pushed the hotfix/prevent-skipping-and-stopping-by-other-users branch from f5c17fb to ebad9ea Compare November 18, 2023 19:52
@mashb1t mashb1t changed the title prevent users from skipping/stopping other users tasks in queue WIP prevent users from skipping/stopping other users tasks in queue Nov 18, 2023
@mashb1t mashb1t changed the title WIP prevent users from skipping/stopping other users tasks in queue prevent users from skipping/stopping other users tasks in queue Nov 18, 2023
@mashb1t
Copy link
Collaborator Author

mashb1t commented Nov 18, 2023

@lllyasviel skipping/stopping is now completely isolated, but a user can't skip/stop before the task is processed. I tried many things but in the end it comes down to the task not being updated while still queued via click on e.g. skip, despite being passed by reference as object.
I assume that this is not possible due to gradio queue for the generate button action.
It could also be possible to use an unique identifier per job and then update the task in the queue if it's not updatable via state, but i didn't go down that rabbit hole.

TL;DR: isolation works, stopping/skipping is possible only when processing started

Please merge or adjust if you think it's fine or have a different solution in mind, thanks :)

@@ -81,6 +84,7 @@ def generate_clicked(*args):
css=modules.html.css).queue()

with shared.gradio_root:
currentTask = gr.State(worker.AsyncTask(args=[]))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi this can also be empty, just to prevent future checks for e.g. processing or last_stop

@thiner

This comment was marked as off-topic.

@mashb1t

This comment was marked as off-topic.

@thiner

This comment was marked as off-topic.

…ping-and-stopping-by-other-users

# Conflicts:
#	modules/async_worker.py
#	webui.py
modules/async_worker.py Outdated Show resolved Hide resolved
@mashb1t
Copy link
Collaborator Author

mashb1t commented Jan 22, 2024

@lllyasviel i've extracted all advanced_parameters to ctrls and added a PID based handling for class patch.py (overrides) to make it possible to separate the settings for each worker and job.
This not only could enable future parallelisation with multiple GPUs, but is also IMHO a clean way of user separation in Fooocus.

Skipping/stopping is now possible whenever you want, not only when processing.

Your feedback is welcome!

@mashb1t mashb1t requested a review from thiner January 22, 2024 20:38
@mashb1t mashb1t changed the title prevent users from skipping/stopping other users tasks in queue prevent users from skipping/stopping other users tasks in queue + advanced params refactoring Jan 22, 2024
@mashb1t mashb1t changed the title prevent users from skipping/stopping other users tasks in queue + advanced params refactoring advanced params refactoring + prevent users from skipping/stopping other users tasks in queue Jan 23, 2024
@mashb1t mashb1t mentioned this pull request Jan 26, 2024
@mashb1t
Copy link
Collaborator Author

mashb1t commented Jan 28, 2024

@lllyasviel i saw you just added

parser.add_argument("--multi-user", action="store_true")
yesterday. Please re-evaluate this PR as it solves the need for global variables for advanced_parameters and removes them altogether. Thanks!

@mashb1t mashb1t added the Size L large change, may depend on other changes, thoroughly test label Feb 9, 2024
…g-by-other-users

# Conflicts:
#	modules/async_worker.py
@mashb1t mashb1t added this to the 2.2.0 milestone Feb 24, 2024
@mashb1t mashb1t changed the base branch from main to develop February 24, 2024 17:59
@mashb1t mashb1t merged commit 513b312 into lllyasviel:develop Feb 24, 2024
mashb1t added a commit that referenced this pull request Feb 24, 2024
…ing other users tasks in queue (#981)

* only make stop_button and skip_button interactive when rendering process starts

fix inconsistency in behaviour of stop_button and skip_button as it was possible to skip or stop other users processes while still being in queue

* use AsyncTask for last_stop handling instead of shared

* Revert "only make stop_button and skip_button interactive when rendering process starts"

This reverts commit d3f9156.

* introduce state for task skipping/stopping

* fix return parameters of stop_clicked

* code cleanup, do not disable skip/stop on stop_clicked

* reset last_stop when skipping for further processing

* fix: replace fcbh with ldm_patched

* fix: use currentTask instead of ctrls after merging upstream

* feat: extract attribute disable_preview

* feat: extract attribute adm_scaler_positive

* feat: extract attribute adm_scaler_negative

* feat: extract attribute adm_scaler_end

* feat: extract attribute adaptive_cfg

* feat: extract attribute sampler_name

* feat: extract attribute scheduler_name

* feat: extract attribute generate_image_grid

* feat: extract attribute overwrite_step

* feat: extract attribute overwrite_switch

* feat: extract attribute overwrite_width

* feat: extract attribute overwrite_height

* feat: extract attribute overwrite_vary_strength

* feat: extract attribute overwrite_upscale_strength

* feat: extract attribute mixing_image_prompt_and_vary_upscale

* feat: extract attribute mixing_image_prompt_and_inpaint

* feat: extract attribute debugging_cn_preprocessor

* feat: extract attribute skipping_cn_preprocessor

* feat: extract attribute canny_low_threshold

* feat: extract attribute canny_high_threshold

* feat: extract attribute refiner_swap_method

* feat: extract freeu_ctrls attributes

freeu_enabled, freeu_b1, freeu_b2, freeu_s1, freeu_s2

* feat: extract inpaint_ctrls attributes

debugging_inpaint_preprocessor, inpaint_disable_initial_latent, inpaint_engine, inpaint_strength, inpaint_respective_field, inpaint_mask_upload_checkbox, invert_mask_checkbox, inpaint_erode_or_dilate

* wip: add TODOs

* chore: cleanup code

* feat: extract attribute controlnet_softness

* feat: extract remaining attributes, do not use globals in patch

* fix: resolve circular import, patch_all now in async_worker

* chore: cleanup pid code
@patrickchamp
Copy link

patrickchamp commented Mar 6, 2024

As an iPad user, the browser page will often refresh when returning to the tab (low memory can’t keep it alive) which prevents me from stopping a task that was running before the refresh.

I’d like to somehow be able to stop the activity that I kicked off before the tab refresh. Since im the only remote user, being able to disable the queue isolation entirely would work for me. E.g. via command line arg. Or e.g. if it could allow queue cancellations originating from the same device.

Currently, to cancel the queue, I launch Remote Desktop on my iPad then close/restart fooocus. I can enter this as a feature request if that’s preferable.

@mashb1t mashb1t deleted the hotfix/prevent-skipping-and-stopping-by-other-users branch March 6, 2024 18:26
@mashb1t
Copy link
Collaborator Author

mashb1t commented Mar 6, 2024

@freshp124 I hope you can understand that this is by design so users don't cancel themselves when being in a multi-user environment and isolation was implemented to fix previous behavior.
Of course it's unfortunate that your browser tab automatically refreshes when reopening. Feel free to make a feature request, but it most likely is not going to be worked on soon, only if you or some community members assemble and form a team to inplement a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Size L large change, may depend on other changes, thoroughly test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Queue Errors -> Session Hijacking [BUG]The returned image is not currently requested
4 participants