732d5f1cd2
CI / Format (ruff format) (push) Successful in 30s
CI / Lint (ruff check) (push) Successful in 34s
CI / Sync project version with tag (push) Has been skipped
CI / Type check (ty) (push) Successful in 42s
CI / Lint (ruff check) (pull_request) Successful in 41s
CI / Format (ruff format) (pull_request) Successful in 46s
CI / Sync project version with tag (pull_request) Has been skipped
CI / Type check (ty) (pull_request) Successful in 43s
CI / Tests (push) Successful in 5m12s
CI / Tests (pull_request) Successful in 5m10s
CI / Bump version, tag, and update changelog on merge to master (push) Has been skipped
CI / Bump version, tag, and update changelog on merge to master (pull_request) Has been skipped
Turns "is this component earning its parameters?" into a one-line config flip for each of the three pluggable network components: - router.type = "none" (NoneRouter, giant/model/routers.py): still builds n_experts expert trunks via RoutedTrunk, but replaces the learned gate with a uniform 1/n_experts weight for every row — no centers/embeddings/classifier. Distinct from router.enabled=false (which drops routing/mixing entirely): this isolates whether the *learned routing signal* specifically is earning its parameters, holding expert count fixed. - stage2_model.autoregressive.history = "none" (NoHistory, giant/model/history.py): ignores feat/has_prev entirely and always returns zeros, ablating whether the AR decoder's history conditioning earns its parameters. Already validated for free by gitea #35's generic HISTORY_REGISTRY membership check. - trunk.type = "linear" (LinearTrunk, giant/model/trunks.py): a bare nn.Linear(in_dim + cond_dim, out_dim) body, no ResBlock stack. Per gitea #33's design, this composes for free with router.enabled=true ("mixture of trivial linear experts"). Both blocking issues (#33 trunk registry, #35 pluggable history encoder) are closed, so this was unblocked.
143 lines
3.2 KiB
Python
143 lines
3.2 KiB
Python
"""Re-export shim.
|
|
|
|
`network.py` used to hold every network-related class in one 1742-line file.
|
|
It's now split by concern into `giant/model/{layers,encoders,routers,trunks,
|
|
history,models,_legacy,builders}.py` (issues.md Issue 8); this module just
|
|
re-exports the public surface so every existing `from giant.model.network
|
|
import X` call site keeps working unchanged.
|
|
"""
|
|
|
|
from giant.model._legacy import _migrate_legacy_model_config, migrate_legacy_state_dict
|
|
from giant.model.builders import build_critics, build_models
|
|
from giant.model.encoders import ConditionEncoder
|
|
from giant.model.history import (
|
|
HISTORY_REGISTRY,
|
|
AttentionHistory,
|
|
HistoryEncoder,
|
|
MarkovHistory,
|
|
NoHistory,
|
|
_CausalAttnBlock,
|
|
build_history,
|
|
register_history,
|
|
)
|
|
from giant.model.layers import (
|
|
BLOCK_REGISTRY,
|
|
AdaLNResBlock,
|
|
ContextAdapter,
|
|
FilmResBlock,
|
|
ResBlock,
|
|
SinusoidalEmbedding,
|
|
_make_axis_mlp,
|
|
build_block,
|
|
build_mlp_head,
|
|
register_block,
|
|
)
|
|
from giant.model.models import (
|
|
CriticModel,
|
|
Stage1Model,
|
|
Stage2Autoregressive,
|
|
Stage2OneShot,
|
|
StageModel,
|
|
resolve_type_n_classes,
|
|
stage2_trunk_sec_dim,
|
|
stage2_type_dim,
|
|
)
|
|
from giant.model.objectives import (
|
|
OBJECTIVE_REGISTRY,
|
|
DdpmObjective,
|
|
FlowObjective,
|
|
Objective,
|
|
WganObjective,
|
|
build_objective,
|
|
register_objective,
|
|
)
|
|
from giant.model.routers import (
|
|
ROUTER_REGISTRY,
|
|
ComposedRouter,
|
|
EnergyRouter,
|
|
NoneRouter,
|
|
PdgRouter,
|
|
ProcessRouter,
|
|
Router,
|
|
_build_router_from_cfg,
|
|
_check_router_conditioning_compat,
|
|
_parse_composed_axes,
|
|
build_composed_router,
|
|
build_router,
|
|
register_router,
|
|
)
|
|
from giant.model.trunks import (
|
|
TRUNK_REGISTRY,
|
|
ExpertTrunk,
|
|
LinearTrunk,
|
|
RoutedTrunk,
|
|
Trunk,
|
|
_route_forward,
|
|
build_expert_body,
|
|
build_trunk,
|
|
register_trunk,
|
|
)
|
|
|
|
__all__ = [
|
|
"AdaLNResBlock",
|
|
"AttentionHistory",
|
|
"BLOCK_REGISTRY",
|
|
"ComposedRouter",
|
|
"ConditionEncoder",
|
|
"ContextAdapter",
|
|
"CriticModel",
|
|
"DdpmObjective",
|
|
"EnergyRouter",
|
|
"ExpertTrunk",
|
|
"FilmResBlock",
|
|
"FlowObjective",
|
|
"HISTORY_REGISTRY",
|
|
"HistoryEncoder",
|
|
"LinearTrunk",
|
|
"MarkovHistory",
|
|
"NoHistory",
|
|
"NoneRouter",
|
|
"OBJECTIVE_REGISTRY",
|
|
"Objective",
|
|
"PdgRouter",
|
|
"ProcessRouter",
|
|
"ROUTER_REGISTRY",
|
|
"ResBlock",
|
|
"RoutedTrunk",
|
|
"Router",
|
|
"SinusoidalEmbedding",
|
|
"Stage1Model",
|
|
"Stage2Autoregressive",
|
|
"Stage2OneShot",
|
|
"StageModel",
|
|
"TRUNK_REGISTRY",
|
|
"Trunk",
|
|
"WganObjective",
|
|
"_CausalAttnBlock",
|
|
"_build_router_from_cfg",
|
|
"_check_router_conditioning_compat",
|
|
"_make_axis_mlp",
|
|
"_migrate_legacy_model_config",
|
|
"_parse_composed_axes",
|
|
"_route_forward",
|
|
"build_block",
|
|
"build_composed_router",
|
|
"build_critics",
|
|
"build_expert_body",
|
|
"build_history",
|
|
"build_mlp_head",
|
|
"build_models",
|
|
"build_objective",
|
|
"build_router",
|
|
"build_trunk",
|
|
"migrate_legacy_state_dict",
|
|
"register_block",
|
|
"register_history",
|
|
"register_objective",
|
|
"register_router",
|
|
"register_trunk",
|
|
"resolve_type_n_classes",
|
|
"stage2_trunk_sec_dim",
|
|
"stage2_type_dim",
|
|
]
|