Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

API/Enums: wire-name kebab-case transforms, strict non-numeric parsing, and allowed-values diagnostics force per-enum Reflector boilerplate #148

Backlog

Description

@clockblocker

Part of #138
Popularity: 1/7 corpus consumers (cuda-quantum)

Problem

Upstream reflect-cpp (v0.25.0) has three ergonomics gaps for C++ enum class wire serialization in user-facing config files:

  1. No built-in wire-name transform (e.g. snake_case -> kebab-case, such as dep_analysis -> "dep-analysis", two_qubit_gate_count -> "two-qubit-gate-count", single_qubit -> "single-qubit") or out-of-band enumerator rename table.
  2. Default enum deserialization accepts numeric fallback spellings or lacks a clean way to strictly reject non-matching/numeric strings without writing a custom rfl::Reflector<E>.
  3. Error messages on invalid enum strings do not list the allowed wire values (unknown value 'foo' (allowed: ...)).

As a result, consumers hand-write a full rfl::Reflector<E> specialization with a switch statement for every enum, plus a shared linear-scan helper using rfl::get_enumerator_array<E>().

Observed Downstream Workarounds

NVIDIA/cuda-quantum (90e4aa08)

  • cudaq/lib/Target/Yaml/TargetConfigYamlAdapters.h#L27-L108: shared detail::enumFromYamlName<E>() (iterating rfl::get_enumerator_array<E>(), rejecting numeric spellings, and formatting (allowed: ...)) plus manual rfl::Reflector specializations for TargetFeatureFlag and ArgumentType:
    /// Matches a YAML enum name against the names that `rfl::Reflector<E>::from`
    /// gives each enumerator. Unmatched (including numeric) spellings are
    /// rejected.
    template <typename E>
      requires std::is_enum_v<E>
    E enumFromYamlName(const std::string &name) {
      ...
      throw std::runtime_error("unknown value '" + name + "' (allowed: " + allowed +
                               ")");
    }
  • cudaq/lib/Target/Yaml/v2/QuakeUnmappedProfileYaml.h#L17-L53: manual rfl::Reflector specializations for CostModel (t_count -> "t-count", two_qubit_gate_count -> "two-qubit-gate-count", gate_count -> "gate-count") and LoopUnrolling (index_use -> "index-use").
  • cudaq/lib/Target/Yaml/v2/QuakeReferenceSemanticsProfileYaml.h#L16-L32: manual rfl::Reflector specialization for MeasurementForm (single_qubit -> "single-qubit").

Related Fork Work

Upstream Overlap

Activity

  1. added
    enhancement
    needs-triage
    known-downstream-workarounds
    on Nov 29, 2026
  2. clockblocker commented on Nov 29, 2026

    @clockblocker
    OwnerAuthor

    Tracking & PR Cross-Reference

    Status: Fully addressed across merged upstream PRs + upstream-queue (Draft PR #191).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementknown-downstream-workaroundsneeds-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions