Commit 5fe0dd79 authored by AUTOMATIC's avatar AUTOMATIC
Browse files

rename CPU RNG to RNG source in settings, add infotext and parameters...

rename CPU RNG to RNG source in settings, add infotext and parameters copypaste support to RNG source
parent cb9571e3
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ def randn(seed, shape):
    from modules.shared import opts

    torch.manual_seed(seed)
    if opts.use_cpu_randn or device.type == 'mps':
    if opts.randn_source == "CPU" or device.type == 'mps':
        return torch.randn(shape, device=cpu).to(device)
    return torch.randn(shape, device=device)

@@ -103,7 +103,7 @@ def randn(seed, shape):
def randn_without_seed(shape):
    from modules.shared import opts

    if opts.use_cpu_randn or device.type == 'mps':
    if opts.randn_source == "CPU" or device.type == 'mps':
        return torch.randn(shape, device=cpu).to(device)
    return torch.randn(shape, device=device)

+5 −0
Original line number Diff line number Diff line
@@ -284,6 +284,10 @@ Steps: 20, Sampler: Euler a, CFG scale: 7, Seed: 965400086, Size: 512x512, Model

    restore_old_hires_fix_params(res)

    # Missing RNG means the default was set, which is GPU RNG
    if "RNG" not in res:
        res["RNG"] = "GPU"

    return res


@@ -304,6 +308,7 @@ infotext_to_setting_name_mapping = [
    ('UniPC skip type', 'uni_pc_skip_type'),
    ('UniPC order', 'uni_pc_order'),
    ('UniPC lower order final', 'uni_pc_lower_order_final'),
    ('RNG', 'randn_source'),
]


+2 −1
Original line number Diff line number Diff line
@@ -477,7 +477,8 @@ def create_infotext(p, all_prompts, all_seeds, all_subseeds, comments=None, iter
        "Conditional mask weight": getattr(p, "inpainting_mask_weight", shared.opts.inpainting_mask_weight) if p.is_using_inpainting_conditioning else None,
        "Clip skip": None if clip_skip <= 1 else clip_skip,
        "ENSD": None if opts.eta_noise_seed_delta == 0 else opts.eta_noise_seed_delta,
        "Init image hash": getattr(p, 'init_img_hash', None)
        "Init image hash": getattr(p, 'init_img_hash', None),
        "RNG": (opts.randn_source if opts.randn_source != "GPU" else None)
    }

    generation_params.update(p.extra_generation_params)
+2 −1
Original line number Diff line number Diff line
@@ -61,7 +61,8 @@ def store_latent(decoded):
class InterruptedException(BaseException):
    pass

if opts.use_cpu_randn:

if opts.randn_source == "CPU":
    import torchsde._brownian.brownian_interval

    def torchsde_randn(size, dtype, device, seed):
+1 −1
Original line number Diff line number Diff line
@@ -190,7 +190,7 @@ class TorchHijack:
            if noise.shape == x.shape:
                return noise

        if opts.use_cpu_randn or x.device.type == 'mps':
        if opts.randn_source == "CPU" or x.device.type == 'mps':
            return torch.randn_like(x, device=devices.cpu).to(x.device)
        else:
            return torch.randn_like(x)
Loading