Skip to content

Use the generate config sampler instead of the undefined train_config in GenerateProcess#936

Open
rajakshay wants to merge 1 commit into
ostris:mainfrom
rajakshay:fix-generateprocess-undefined-train-config
Open

Use the generate config sampler instead of the undefined train_config in GenerateProcess#936
rajakshay wants to merge 1 commit into
ostris:mainfrom
rajakshay:fix-generateprocess-undefined-train-config

Conversation

@rajakshay

Copy link
Copy Markdown

What

In GenerateProcess.__init__ (jobs/process/GenerateProcess.py), the sampler-building branch references self.train_config.noise_scheduler, but GenerateProcess never sets self.train_config (only training processes do).

Why it breaks

Running a generate job that reaches this branch crashes at construction:

AttributeError: 'GenerateProcess' object has no attribute 'train_config'

Fix

Use self.generate_config.sampler, which is already built earlier in the same __init__. GenerateConfig defines sampler (default 'ddpm'), which is exactly what get_sampler(...) expects.

Note on the previous attempt (#498)

This revives the fix reported in #416 and attempted in #498 (closed for inactivity). It intentionally uses generate_config.sampler rather than generate_config.noise_scheduler (as in #498): GenerateConfig has a sampler attribute but no noise_scheduler attribute, so .sampler actually resolves the crash instead of moving it to a different AttributeError.

Regression safety

This branch currently always crashes, so no working path is affected.

Validation

  • Before: a FLUX generate job crashes at init with the AttributeError above.
  • After: the generate job constructs, loads the model, and produces images (validated with a FLUX generate run that produced a full batch).

Refs #416. Supersedes the approach in #498.

… in GenerateProcess

The sampler-building branch in GenerateProcess.__init__ referenced
`self.train_config.noise_scheduler`, but GenerateProcess never defines
`self.train_config` (only training processes do). Running a `generate`
job that hits this branch crashes at construction:

    AttributeError: 'GenerateProcess' object has no attribute 'train_config'

Use the sampler from `self.generate_config`, which is already built
earlier in the same __init__. This branch currently always crashes, so
no working path is affected.
@rajakshay

Copy link
Copy Markdown
Author

Reproduction (no models or data, CPU-only)

get_model_class is stubbed so no weights load and so the model class has no get_train_scheduler (which forces the sampler else-branch containing the bug). The crash happens before any model would be loaded. Run from the repo root.

repro.py
import importlib
from collections import OrderedDict

# import_module returns the real submodule even though jobs.process re-exports the class
GP = importlib.import_module("jobs.process.GenerateProcess")


class DummyModel:  # no get_train_scheduler -> forces the sampler else-branch
    def __init__(self, *a, **k):
        pass


GP.get_model_class = lambda cfg: DummyModel  # no weights loaded


class FakeJob:
    name = "repro"
    meta = OrderedDict()
    device = "cpu"


config = OrderedDict({
    "output_folder": "/tmp/repro_out",
    "model": OrderedDict({"name_or_path": "stub", "is_flux": True}),
    "generate": OrderedDict({"prompts": ["a photo"], "sampler": "ddpm"}),
    "dtype": "float16",
})

try:
    GP.GenerateProcess(0, FakeJob(), config)
    print("PASSED: GenerateProcess constructed; sampler built from generate_config.sampler")
except AttributeError as e:
    print("REPRODUCED AttributeError:", str(e))
except Exception as e:
    print("OTHER:", type(e).__name__, "-", str(e).splitlines()[0])

Result:

# BEFORE (current main)
REPRODUCED AttributeError: 'GenerateProcess' object has no attribute 'train_config'

# AFTER (this PR)
PASSED: GenerateProcess constructed; sampler built from generate_config.sampler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant