Generative objective (flow/ddpm/wgan) is a bare string, not a plugin #32
Notifications
Due Date
No due date set.
Depends on
Reference: lars/giant#32
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This is the big one.
generator ∈ {"flow", "ddpm", "wgan"}is tested as a bare string in ~72 placesacross 15 files. Excluding
config.py/cli.py(where a string is correct),the hot spots are
models.py(22),sample.py(13),builders.py(6),trainers.py(6),stage2_inputs.py(4).Each of those sites independently re-derives some consequence of the choice:
has_time = generator in ("flow", "ddpm"), written out three times inmodels.py(lines 89, 191, 357)in_dim = noise_dim if generator == "wgan" else x_dim, three more timesstage2_trunk_sec_diminmodels.py,_type_foldedinsample.py,_assemble_stage2_ar_targetinstage2_inputs.py: three implementations of one rulesample_stage1/sample_stage2dispatch chainsFlowDDPMStageTrainervsWGANStageTrainer, ~500 lines of near-parallel structureAdding a fourth objective — rectified flow, consistency distillation, a shortcut
model, anything in the "hit the 10× native-Geant4 eval budget" family that the
roadmap is explicitly chasing — means finding and correctly editing all five
groups. That is exactly the kind of change the branch should make cheap and
currently makes expensive.
Proposal:
giant/model/objectives.py, mirroringrouters.py:FlowObjective/DdpmObjective/WganObjectiveare then three small classes,and one
StageTrainerparameterised by an objective replaces the two subclasses(the optimizer topology difference becomes
build_critic() is not None).Payoff: a new objective is one file plus one registry line, testable against
the existing per-objective tests without touching the stage models at all.
Risk: the largest change in this document — touches the trainers, which are
the least-covered-by-fast-tests part of the codebase. Sequence it after the
trunk-registry and conditioning-injection issues (small, independent) so the
refactor lands on a codebase where the other plug points are already
registry-shaped. Keep
model.generator_kindas the persisted string so nocheckpoint changes.
Migrated from
issues.md(v0.3.0 branch review, 2026-08-13), Issue 7.The
Routercontract (giant/model/routers.py:21-110) is already the modelof what good looks like here — an ABC with working defaults, a registry, a
name-keyed factory that filters kwargs by signature so per-type
hyperparameters coexist without special-casing. Every Part B proposal from
that review is "extend the
Routerpattern to the axis that doesn't have ityet." None of them requires inventing a new idea, and none of them breaks a
checkpoint: the config string stays the registry key.