Skip to content

Declarative DeepNetwork API, fused pipeline, and batch-synchronous sweeps#402

Merged
LegrandNico merged 1 commit into
masterfrom
feat/deep-network-declarative-api
Jul 8, 2026
Merged

Declarative DeepNetwork API, fused pipeline, and batch-synchronous sweeps#402
LegrandNico merged 1 commit into
masterfrom
feat/deep-network-declarative-api

Conversation

@LegrandNico

@LegrandNico LegrandNico commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Declarative DeepNetwork API, mixed/fused pipelines, and batch-synchronous learning

Extends the vectorised DeepNetwork backend with a declarative construction API and a way to compose PyHGF networks with frozen calculations into larger models (up to a full Transformer), trained locally without backprop or autodiff.

What's new

  • Declarative construction (builder.py) — LayerConfig, resolve_coupling_fn, and DeepNetwork.from_configs / from_dict: build networks from JSON/YAML-serializable configs for reproducible sweeps.
  • Weight transplant (transplant.py) — from_linear, from_feedforward, from_embedding: build a DeepNetwork that reproduces a trained Equinox module's forward pass in PyHGF's layer layout.
  • Mixed pipelines (hybrid.py) — PCModule with DeepNetworkAdapter (learning) / EquinoxAdapter (frozen), PCSequential, Residual, and the linear_/layer_norm_/gelu_adapter helpers. Errors are routed part-by-part with hand-derived backward formulas; no global computation graph.
  • Transformer (transformer.py) — MultiHeadAttention, HybridGPT, hybrid_from_gpt: assemble a GPT from mixed parts, any slot frozen or learning.
  • Fused executor (fused.py) — FusedPipeline + step_report: run a part tree as a single compiled program per training step, with all state threaded explicitly.
  • New belief-propagation entry points (vectorized_belief_propagation.py, learning.py) — batch-synchronous batch_step / sample_step, split prediction_sweep / update_sweep / learn_sweep, input_prediction_error, and rank-one vectorized_weight_gradient_factors. Surfaced on DeepNetwork as prediction, update, input_error, batch_update, predict_states.

Also

  • Categorical layers restricted to the output layer (softmax = single N-way choice).
  • All new public symbols are documented in docs/source/api.rst.
  • Tests for builder, hybrid, fused, transplant, batch learning, and the PCModule state contract.

@LegrandNico LegrandNico force-pushed the feat/equinox-transplant branch from 84cfa0f to 88acae1 Compare July 8, 2026 21:51
@LegrandNico LegrandNico force-pushed the feat/deep-network-declarative-api branch from d6713da to 291396b Compare July 8, 2026 21:51
@LegrandNico LegrandNico force-pushed the feat/equinox-transplant branch from 88acae1 to c5c554c Compare July 8, 2026 22:11
Base automatically changed from feat/equinox-transplant to master July 8, 2026 22:14
@LegrandNico LegrandNico force-pushed the feat/deep-network-declarative-api branch from 291396b to 96f6501 Compare July 8, 2026 22:21
@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.90361% with 140 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pyhgf/model/fused.py 64.48% 62 Missing and 3 partials ⚠️
pyhgf/model/transformer.py 45.90% 33 Missing ⚠️
pyhgf/model/deep_network.py 69.87% 12 Missing and 13 partials ⚠️
pyhgf/model/hybrid.py 86.74% 11 Missing ⚠️
pyhgf/utils/vectorized_belief_propagation.py 95.31% 3 Missing and 3 partials ⚠️
Files with missing lines Coverage Δ
pyhgf/model/__init__.py 86.66% <100.00%> (+4.84%) ⬆️
pyhgf/model/builder.py 100.00% <100.00%> (ø)
pyhgf/updates/vectorized/learning.py 100.00% <100.00%> (ø)
pyhgf/utils/vectorized_belief_propagation.py 93.38% <95.31%> (-0.11%) ⬇️
pyhgf/model/hybrid.py 86.74% <86.74%> (ø)
pyhgf/model/deep_network.py 87.50% <69.87%> (-7.53%) ⬇️
pyhgf/model/transformer.py 45.90% <45.90%> (ø)
pyhgf/model/fused.py 64.48% <64.48%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@LegrandNico LegrandNico force-pushed the feat/deep-network-declarative-api branch from 96f6501 to 91237d2 Compare July 8, 2026 23:01
@LegrandNico LegrandNico merged commit b26f5ae into master Jul 8, 2026
21 checks passed
@LegrandNico LegrandNico deleted the feat/deep-network-declarative-api branch July 8, 2026 23:06
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