-
Notifications
You must be signed in to change notification settings - Fork 3
Tiled vae parameter validation #6
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
Conversation
And it's not a problem with the PR itself, but another thing I've noticed:
We don't seem to be reusing the context across tiles. It looks like that'd be controlled by the |
Yes I think so too. Maybe it would be worth investigating that in a separate PR. It might make vae tiling a bit faster |
Did a few tests, LGTM |
I just noticed the decoding tile size became too big when I used a relative factor 😕 W and H are being multiplied by 8 at the beginning of diff --git a/stable-diffusion.cpp b/stable-diffusion.cpp
index 9085bd3..b1fd72d 100644
--- a/stable-diffusion.cpp
+++ b/stable-diffusion.cpp
@@ -1488,7 +1492,7 @@ public:
if (!use_tiny_autoencoder) {
float tile_overlap;
int tile_size_x, tile_size_y;
- get_tile_sizes(tile_size_x, tile_size_y, tile_overlap, vae_tiling_params, W, H);
+ get_tile_sizes(tile_size_x, tile_size_y, tile_overlap, vae_tiling_params, W / 8, H / 8);
LOG_DEBUG("VAE Tile size: %dx%d", tile_size_x, tile_size_y); Or maybe we should use |
* implement tiling vae encode support * Tiling (vae/upscale): adaptative overlap * Tiling: fix edge case * Tiling: fix crash when less than 2 tiles per dim * remove extra dot * Tiling: fix edge cases for adaptative overlap * tiling: fix edge case * set vae tile size via env var * vae tiling: refactor again, base on smaller buffer for alignment * Use bigger tiles for encode (to match compute buffer size) * Fix edge case when tile is bigger than latent * non-square VAE tiling (#3) * refactor tile number calculation * support non-square tiles * add env var to change tile overlap * add safeguards and better error messages for SD_TILE_OVERLAP * add safeguards and include overlapping factor for SD_TILE_SIZE * avoid rounding issues when specifying SD_TILE_SIZE as a factor * lower SD_TILE_OVERLAP limit * zero-init empty output buffer * Fix decode latent size * fix encode * tile size params instead of env * Tiled vae parameter validation (#6) * avoid crash with invalid tile sizes, use 0 for default * refactor default tile size, limit overlap factor * remove explicit parameter for relative tile size * limit encoding tile to latent size * unify code style and format code * update docs * fix get_tile_sizes in decode_first_stage --------- Co-authored-by: Wagner Bruna <wbruna@users.noreply.github.com> Co-authored-by: leejet <leejet714@gmail.com>
I fixed the tiled parameter processing to limit both direct dimensions and relative factors, and added limits to the overlapping factor (I remember we shouldn't allow an overlapping factor larger than 0.5).
I also noticed the tile size bump for the encoding path wasn't being included on that limit, and pulled it into the auxiliary function too.
And since different rel_size ranges already have different effects on the calculation, I changed the explicit
relative
boolean to implicitrel_size > 0
tests.