Candidates Engine - #837
Draft
AdrianSosic wants to merge 296 commits into
Draft
Conversation
Add tests for: - duplicate parameter names (existing validation, missing coverage) - constraints referencing nonexistent parameters (missing validation)
Add tests for: - duplicate parameter names (existing validation, missing coverage) - constraints referencing nonexistent parameters (missing validation)
- validate_parameters is now the sole public entry point for parameter validation; the internal validate_parameter_names helper is inlined into it and removed. SearchSpace-level concerns (non-empty collection, TaskParameter count) are moved out of validate_parameters and into SearchSpace.__attrs_post_init__ and SearchSpace.from_product, where they semantically belong. - validate_constraints is now the sole public entry point for constraint validation; the internal helpers validate_cardinality_constraints_are_nonoverlapping and validate_cardinality_constraint_parameter_bounds are made private. - All field validators and classmethod constructors across SubspaceDiscrete, SubspaceContinuous, and SearchSpace consistently call these two high-level entry points. Redundant pre-validation calls in classmethod constructors are dropped except where they provide genuine fail-fast value before expensive operations such as build_constrained_product.
Multiple task parameters are now correctly rejected
Adds some missing validators and fixes defaults
* Only parameter that actually appear in constraints are relevant * Interpoint condition was missing
Replaces the silent argmax-on-zero fallback with an explicit check.
The subsampling path is currently blocking (see comment in code)
The logic in hybrid.py still relies critically on the pandas index (see comment that file), so there is no point of narwhalifying the function in any way.
pytest.warns installs warnings.simplefilter('always') on entry, which
shadows all pytest.ini filterwarnings ignores. For SubstanceParameter,
the first transform() call triggers heavy chemistry work via joblib,
emitting an unrelated DeprecationWarning that leaked into pytest.warns
and caused a spurious failure. Pre-computing expected before the context
manager avoids this.
Narwhalifies the recommendation layer, focusing on the core logic. That is, some methods/functions are narwhalified only at their API boundary, keeping an internal conversion to `pd.DataFrame`. These internals can be narhwhalified at any later point in time in the form of isolated PRs.
AdrianSosic
force-pushed
the
dev/candidates
branch
from
September 8, 2026 14:07
fa9783b to
3fc26cd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #793
PRs merged
SubspaceDiscrete.constraints#835DiscreteParameter.transform#862Upcoming PRs
get_candidates#915To be decided
is_constrainedproperty of the search space classes be dropped? Reasons:SubspaceContinuous.is_constrainedused to contain non-trivial logic but with the new design it's equivalent to a simpleif self.constraintscallSubspaceDiscrete.is_constrainedwas very much meaningless since theconstraintsattribute itself was flawed (DeprecateSubspaceDiscrete.constraints#835). And with both the legacy and new design, it's not obvious what it actually means!is_constrainedattribute only on some of the search space classes is asymmetricSubspaceDiscrete.batch_constraintsvsDiscreteBatchConstraintname conflict. Options:batch_constraintsto something else, e.g.recommendation_constraints. However,batch_constraintsis already a generic term. Perhaps we should rather ...DiscreteBatchConstraintto something more specific. The latter is actually rather a name for an abstract base class if we decide to add more batch-level constraints, and does not convey anything about what it does. Options would be in the direction ofDiscreteSharedValueConstraintn_batches_doneandn_fits_done?eval_during_creationandeval_during_modelingare currently not mutually exclusive, so the semantics are not 100% clear, hence theassertstatements insearchspace/discrete.py<-- clean up during constraint refactoring?complete unfiltered space,filtered spaceorpolicy-generated subset? Decision depends heavily on what is cheap and possible in a large lazy space but also what makes conceptually sense (i.e. should adding a hypothetical candidate that is removed through a filter, e.g. by policy or active values, change the induced scaling?). Also impacts methods likecomp_rep_bounds, which now behave differently compared tomain(Refactor candidates interface #840 (comment)). At the same time, the discrete version ofcomp_rep_boundsmay be dropped entirely since effectively unused at the moment (it's called inoptimize_acqf_mixedbut the discrete bounds should actually not matter since the candidates are explicitly piped in as separate argument --> needs investigation)EmptyCandidatesvsNullCandidatesencodevstransformvscomputational representationterminology. Transform is currently used for continuous-valued objects (e.g. target transforms) but also for in the parameter/searchspace context. However, the latter also usesencoding(e.g. discrete parameters have specified encodings, we have a correspondingly named base class, ...). We somehow need to make this more precise. Perhaps: transform for conti mappings and encode for discrete mappings? Also covers things like the_encoding_tablemethods etc.TODOs
SubspaceDiscreteand turncomp_repintocached_propertyFollow-up TODOs (after dev completion)