[BugFix] Fix Helios Cholesky positive-definite crashes and CPU LAPACK… (#4921)

Signed-off-by: akshatvishu <akshatnayak197@gmail.com>
Co-authored-by: Hongsheng Liu <liuhongsheng4@huawei.com>
This commit is contained in:
akshatvishuandHongsheng Liu authored and GitHub committed 2026-07-24 19:41:56 +08:00
1 parent 784c27f493
commit 536daea107
1 file changed
+6 -5
@@ -1561,11 +1561,12 @@ class HeliosPipeline(
device = generator.device if generator is not None else self.device
cov = torch.eye(block_size) * (1 + gamma) - torch.ones(block_size, block_size) * gamma
cov += torch.eye(block_size) * 1e-8
cov = cov.float() # Upcast to fp32 for numerical stability — cholesky is unreliable in fp16/bf16.
L = torch.linalg.cholesky(cov).to(device)
# Allocate directly on the execution device in float32 to use the device solver
# and avoid fp16/bf16 Cholesky on the covariance matrix.
eye = torch.eye(block_size, device=device, dtype=torch.float32)
cov = eye * (1 + gamma) - torch.ones(block_size, block_size, device=device, dtype=torch.float32) * gamma
cov += eye * 1e-8
L = torch.linalg.cholesky(cov)
block_number = batch_size * channel * num_frames * (height // ph) * (width // pw)
z = torch.randn(block_number, block_size, generator=generator, device=device)
noise = z @ L.T