feat(train): the Keras backend gives a Loss that needs a PRNG key one per step
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- keras, python
- Domain
- backend-api-design, machine-learning
Research direction
Start with packages/pipekit-train/src/pipekit_train/backends/keras/_losses.py, reading bridge_loss, aux_names, and aux_metrics; then check call_loss in packages/pipekit-train/src/pipekit_train/losses/_losses.py and the Keras adapter design sections cited in the issue. Add per-call keys for training, probing, and validation, then run the train-extras tests and the listed lint, format, and type checks. Done means required-key losses train and receive a fresh key each step.
Written by the indexing model from the issue text.
Description
Problem / Request
The Keras backend (#320) bridges a pipekit_train.Loss into a Keras loss, but a Keras loss is called (y_true, y_pred) with no PRNG key. A Loss whose key argument is required, such as a sample-based divergence, therefore cannot train under backend="keras"; #320 refuses it with an error that names this issue. A Loss whose key defaults to None (KL with an analytic divergence) already trains.
User Story
As someone training an amortized posterior with a sample-based loss, I want
backend="keras"to hand myLossa fresh key each step, as the Equinox backend does, so that the same loss trains under both backends.
Design Snapshot
- Keep a
keras.random.SeedGenerator(loop.seed)in the bridged loss and the auxiliary metrics, and callcall_loss(loss, y_pred, y_true, key=seed_generator.next())inside the traced train step. The Equinox backend splitsjax.random.key(loop.seed)once per step; matching its key sequence exactly is not required, but one key per step and per call is. - The auxiliary-name probe before
compilepasses a fixed key. - Validation passes a key too, so that a stochastic validation metric is defined.
- Remove the refusal added in #320.
References & Existing Code
packages/pipekit-train/src/pipekit_train/backends/keras/_losses.py(bridge_loss,aux_names,aux_metrics)packages/pipekit-train/src/pipekit_train/losses/_losses.py(call_loss,KL)- Design:
packages/pipekit-train/docs/design/keras_adapter.md§8.2 and §10 ("losses that take a key")
Definition of Done
- A
Losswith a requiredkeytrains underbackend="keras" - Tests pass with
train-extras; lint, format and typecheck pass
Testing
- A loss that adds
jax.random.normal(key, ()) * 0trains, and receives a different key each step -
KLwith its sample-based fallback trains on a toy amortized posterior
Relationships
- Parent (theme epic): #317
- Blocked by: #320
- Dominant language
- Python
- Stars
- 0
- Forks
- 0
- Avg merge
- 3h 50m
- Merged PRs (30d)
- 143
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from jejjohnson/pipekit
-
area:code layer:0-primitives priority:p2 type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
jejjohnson/pipekit#296 ·
Maintainers usually reply within 1 day
-
area:code type:feature
Difficulty 3/5 1-2 days Newbie friendliness 57/100
jejjohnson/pipekit#411 ·
Maintainers usually reply within 1 day
-
area:code type:feature
Difficulty 4/5 3-5 days Newbie friendliness 48/100
jejjohnson/pipekit#410 ·
Maintainers usually reply within 1 day
-
area:code type:feature
Difficulty 5/5 Over a week Newbie friendliness 38/100
jejjohnson/pipekit#409 ·
Maintainers usually reply within 1 day
-
area:code type:feature
Difficulty 3/5 1-2 days Newbie friendliness 75/100
jejjohnson/pipekit#408 ·
Maintainers usually reply within 1 day
All issues in jejjohnson/pipekit
Similar issues
-
bug(operator): VolterraOperator built inside jax.jit with a concrete decay raises TracerBoolConversionErrorPossibly taken @jejjohnson claimed this today. Opentype:bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
jejjohnson/integrix#144 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
finos/ai-governance-framework#459 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
autowarefoundation/autoware_carla_scenario#2963 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
freelawproject/litigant-portal#1307 ·
Maintainers usually reply within 2 days
-
type/bug
Difficulty 1/5 Under an hour Newbie friendliness 86/100
h2oai/h2o-llmstudio#1163 ·
Maintainers usually reply within 1 day