Skip to content

add missing macros#253

Merged
Siel merged 22 commits into
mainfrom
feat/add-missing-macros
May 11, 2026
Merged

add missing macros#253
Siel merged 22 commits into
mainfrom
feat/add-missing-macros

Conversation

@Siel
Copy link
Copy Markdown
Member

@Siel Siel commented May 1, 2026

No description provided.

Copilot AI review requested due to automatic review settings May 1, 2026 07:16
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

🐰 Bencher Report

Branchfeat/add-missing-macros
Testbedmhovd-pgx

🚨 12 Alerts

BenchmarkMeasure
Units
ViewBenchmark Result
(Result Δ%)
Upper Boundary
(Limit %)
Conditional dose modificationLatency
microseconds (µs)
📈 plot
🚷 threshold
🚨 alert (🔔)
2.84 µs
(+134.86%)Baseline: 1.21 µs
1.27 µs
(224.68%)

Create large dataset (100 subjects)Latency
microseconds (µs)
📈 plot
🚷 threshold
🚨 alert (🔔)
91.48 µs
(+66.83%)Baseline: 54.83 µs
57.23 µs
(159.85%)

Data expand complex (1h intervals)Latency
microseconds (µs)
📈 plot
🚷 threshold
🚨 alert (🔔)
84.14 µs
(+200.49%)Baseline: 28.00 µs
30.27 µs
(278.00%)

Data expand simple (1h intervals)Latency
nanoseconds (ns)
📈 plot
🚷 threshold
🚨 alert (🔔)
1,341.30 ns
(+173.02%)Baseline: 491.28 ns
521.47 ns
(257.21%)

Data expand with additional timeLatency
microseconds (µs)
📈 plot
🚷 threshold
🚨 alert (🔔)
118.79 µs
(+205.60%)Baseline: 38.87 µs
42.11 µs
(282.09%)

Filter exclude subjectsLatency
microseconds (µs)
📈 plot
🚷 threshold
🚨 alert (🔔)
40.03 µs
(+30.04%)Baseline: 30.78 µs
31.50 µs
(127.05%)

Filter include subjectsLatency
microseconds (µs)
📈 plot
🚷 threshold
🚨 alert (🔔)
9.76 µs
(+22.86%)Baseline: 7.95 µs
8.38 µs
(116.53%)

Modify all bolus dosesLatency
microseconds (µs)
📈 plot
🚷 threshold
🚨 alert (🔔)
2.78 µs
(+136.04%)Baseline: 1.18 µs
1.22 µs
(226.91%)

Modify all infusion dosesLatency
microseconds (µs)
📈 plot
🚷 threshold
🚨 alert (🔔)
2.84 µs
(+135.07%)Baseline: 1.21 µs
1.26 µs
(225.64%)

SubjectBuilder multi-occasionLatency
nanoseconds (ns)
📈 plot
🚷 threshold
🚨 alert (🔔)
517.54 ns
(+95.38%)Baseline: 264.89 ns
275.21 ns
(188.06%)

SubjectBuilder simpleLatency
nanoseconds (ns)
📈 plot
🚷 threshold
🚨 alert (🔔)
202.01 ns
(+93.41%)Baseline: 104.45 ns
109.28 ns
(184.86%)

SubjectBuilder with covariatesLatency
nanoseconds (ns)
📈 plot
🚷 threshold
🚨 alert (🔔)
508.09 ns
(+83.08%)Baseline: 277.53 ns
294.58 ns
(172.48%)

Click to view all benchmark results
BenchmarkLatencyBenchmark Result
nanoseconds (ns)
(Result Δ%)
Upper Boundary
nanoseconds (ns)
(Limit %)
Conditional dose modification📈 view plot
🚷 view threshold
🚨 view alert (🔔)
2,843.90 ns
(+134.86%)Baseline: 1,210.88 ns
1,265.76 ns
(224.68%)

Create large dataset (100 subjects)📈 view plot
🚷 view threshold
🚨 view alert (🔔)
91,483.00 ns
(+66.83%)Baseline: 54,834.46 ns
57,230.64 ns
(159.85%)

Data expand complex (1h intervals)📈 view plot
🚷 view threshold
🚨 view alert (🔔)
84,138.00 ns
(+200.49%)Baseline: 28,000.24 ns
30,265.88 ns
(278.00%)

Data expand simple (1h intervals)📈 view plot
🚷 view threshold
🚨 view alert (🔔)
1,341.30 ns
(+173.02%)Baseline: 491.28 ns
521.47 ns
(257.21%)

Data expand with additional time📈 view plot
🚷 view threshold
🚨 view alert (🔔)
118,790.00 ns
(+205.60%)Baseline: 38,870.59 ns
42,111.34 ns
(282.09%)

Filter exclude subjects📈 view plot
🚷 view threshold
🚨 view alert (🔔)
40,026.00 ns
(+30.04%)Baseline: 30,780.84 ns
31,503.83 ns
(127.05%)

Filter include subjects📈 view plot
🚷 view threshold
🚨 view alert (🔔)
9,763.90 ns
(+22.86%)Baseline: 7,947.35 ns
8,379.02 ns
(116.53%)

Modify all bolus doses📈 view plot
🚷 view threshold
🚨 view alert (🔔)
2,775.80 ns
(+136.04%)Baseline: 1,175.97 ns
1,223.30 ns
(226.91%)

Modify all infusion doses📈 view plot
🚷 view threshold
🚨 view alert (🔔)
2,839.00 ns
(+135.07%)Baseline: 1,207.75 ns
1,258.22 ns
(225.64%)

SubjectBuilder multi-occasion📈 view plot
🚷 view threshold
🚨 view alert (🔔)
517.54 ns
(+95.38%)Baseline: 264.89 ns
275.21 ns
(188.06%)

SubjectBuilder simple📈 view plot
🚷 view threshold
🚨 view alert (🔔)
202.01 ns
(+93.41%)Baseline: 104.45 ns
109.28 ns
(184.86%)

SubjectBuilder with covariates📈 view plot
🚷 view threshold
🚨 view alert (🔔)
508.09 ns
(+83.08%)Baseline: 277.53 ns
294.58 ns
(172.48%)

likelihood/batch/cold/16📈 view plot
🚷 view threshold
110,950.00 ns
likelihood/batch/cold/256📈 view plot
🚷 view threshold
658,660.00 ns
likelihood/batch/cold/64📈 view plot
🚷 view threshold
249,150.00 ns
likelihood/batch/hot/16📈 view plot
🚷 view threshold
16,594.00 ns
likelihood/batch/hot/256📈 view plot
🚷 view threshold
136,380.00 ns
likelihood/batch/hot/64📈 view plot
🚷 view threshold
43,286.00 ns
likelihood/matrix/cold/16x32📈 view plot
🚷 view threshold
2,041,700.00 ns
likelihood/matrix/cold/64x128📈 view plot
🚷 view threshold
17,592,000.00 ns
likelihood/matrix/hot/16x32📈 view plot
🚷 view threshold
245,350.00 ns
likelihood/matrix/hot/64x128📈 view plot
🚷 view threshold
3,723,500.00 ns
nca_auc_cmax_metrics📈 view plot
🚷 view threshold
584.78 ns
(-0.46%)Baseline: 587.50 ns
615.81 ns
(94.96%)
nca_population/10📈 view plot
🚷 view threshold
44,900.00 ns
(-4.42%)Baseline: 46,974.94 ns
49,975.42 ns
(89.84%)
nca_population/100📈 view plot
🚷 view threshold
123,720.00 ns
(+0.98%)Baseline: 122,525.00 ns
127,813.68 ns
(96.80%)
nca_population/500📈 view plot
🚷 view threshold
350,220.00 ns
(-13.03%)Baseline: 402,696.11 ns
432,013.37 ns
(81.07%)
nca_single_subject📈 view plot
🚷 view threshold
999.22 ns
(-1.23%)Baseline: 1,011.70 ns
1,050.42 ns
(95.13%)
ode/runtime-breakdown/loglik-cold📈 view plot
🚷 view threshold
24,639.00 ns
ode/runtime-breakdown/loglik-hot📈 view plot
🚷 view threshold
379.57 ns
ode/runtime-breakdown/predict-cold📈 view plot
🚷 view threshold
23,031.00 ns
ode/runtime-breakdown/predict-hot📈 view plot
🚷 view threshold
238.19 ns
ode/runtime-breakdown/score-only📈 view plot
🚷 view threshold
88.31 ns
one_compartment📈 view plot
🚷 view threshold
29,851.00 ns
(+26.51%)Baseline: 23,595.73 ns
30,159.08 ns
(98.98%)
one_compartment_covariates📈 view plot
🚷 view threshold
44,802.00 ns
(+41.80%)Baseline: 31,594.68 ns
46,585.36 ns
(96.17%)
readme 20📈 view plot
🚷 view threshold
28,472.00 ns
(-91.38%)Baseline: 330,190.27 ns
351,966.08 ns
(8.09%)
two_compartment📈 view plot
🚷 view threshold
40,247.00 ns
(+49.84%)Baseline: 26,859.27 ns
41,887.41 ns
(96.08%)
🐰 View full continuous benchmarking report in Bencher

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands the “declaration-first” modeling surface by adding missing macros and aligning handwritten model APIs with DSL-style metadata, while also updating DSL authoring keywords and runtime route semantics so route/name lookups stay consistent across ODE/Analytical/SDE paths.

Changes:

  • Introduces a new shared handwritten model metadata system and wires it into ODE/Analytical/SDE (including name-based index lookups).
  • Adds/exports missing macros (analytical!, sde!) and adds macro-lowering parity tests against handwritten models.
  • Updates the DSL authoring surface (model=name=, kernel=structure=) and updates runtimes/ABI model info to carry richer route identity (declaration index/kind).

Reviewed changes

Copilot reviewed 45 out of 46 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/support/runtime_corpus.rs Updates embedded DSL fixtures to use name = ... / structure = ....
tests/support/bimodal_ke.rs Updates DSL fixture to name = ....
tests/sde_macro_lowering.rs Adds parity tests for sde! lowering vs handwritten SDE (metadata + predictions).
tests/ode_macro_lowering.rs Adds parity tests for ode! lowering vs handwritten ODE (metadata + predictions).
tests/browser-e2e/site/app.mjs Updates browser E2E DSL sources from model = to name =.
tests/analytical_macro_lowering.rs Adds parity tests for analytical! lowering vs handwritten analytical models.
src/test_fixtures.rs Updates fixture DSL kernelstructure.
src/simulator/equation/sde/mod.rs Adds metadata attachment + bolus injection mapping hook + SDE event handling changes.
src/simulator/equation/ode/mod.rs Adds metadata attachment and dimension validation for handwritten ODE models.
src/simulator/equation/mod.rs Renames meta module to metadata and re-exports DSL enums.
src/simulator/equation/metadata.rs New shared handwritten metadata builder + validation + lookup helpers.
src/simulator/equation/meta.rs Removes old Meta container.
src/simulator/equation/analytical/mod.rs Adds metadata attachment and validation for handwritten analytical models.
src/lib.rs Re-exports new macros and metadata types through crate root and prelude.
src/dsl/wasm_direct_emitter.rs Updates route-input load representation to the new ExecutionLoad::RouteInput { .. } form.
src/dsl/wasm_compile.rs Updates DSL test sources to use name = ....
src/dsl/wasm.rs Updates WASM tests and route metadata shape expectations (but currently introduces a compile error).
src/dsl/rust_backend.rs Updates route-input load representation to the new ExecutionLoad::RouteInput { .. } form.
src/dsl/native.rs Adds route-kind-aware input validation and refines injection semantics for compiled/native runtime.
src/dsl/model_info.rs Extends native model info route metadata (declaration index/kind) and improves explicit route usage detection.
src/dsl/jit.rs Updates JIT lowering for new ExecutionLoad::RouteInput { .. } and adds shared-channel test.
src/dsl/compiled_backend_abi.rs Updates ABI test fixtures for expanded route info fields.
pharmsol-macros/Cargo.toml Enables syn’s visit feature to support macro parsing/analysis.
pharmsol-dsl/tests/dsl_authoring_edge_cases.rs Updates DSL authoring fixtures to name = ....
pharmsol-dsl/src/test_fixtures.rs Updates fixtures to structure = ... and name = ....
pharmsol-dsl/src/semantic.rs Renames analytical kernel to structure and preserves route kind in typed IR.
pharmsol-dsl/src/parser.rs Renames analytical block key to structure and updates authoring tests to name = ....
pharmsol-dsl/src/ir.rs Extends typed IR to store optional RouteKind and renames analytical kernel to structure.
pharmsol-dsl/src/execution.rs Introduces declaration-index-aware route metadata, route-kind-aware channel assignment, and route-input load encoding.
pharmsol-dsl/src/authoring.rs Renames model = ...name = ..., kernel = ...structure = ..., and preserves route order/kind.
pharmsol-dsl/src/ast.rs Adds RouteKind and renames analytical kernel to structure in AST + formatter.
examples/two_compartment.rs Migrates example to declaration-first ode! with metadata-backed indices.
examples/sde_readme.rs New SDE macro example showing name-based indices + prediction calls.
examples/one_compartment.rs Migrates example to analytical!/ode! but currently introduces a compile error.
examples/ode_readme.rs Updates README-style ODE example to ode! and name-based indices.
examples/macro_vs_handwritten_two_cpt.rs New parity example comparing macro vs handwritten ODE for shared-channel dosing.
examples/macro_vs_handwritten_one_cpt.rs New parity example comparing macro vs handwritten ODE for one-compartment IV.
examples/dsl_runtime_jit.rs Updates embedded authoring DSL to name = ....
examples/covariates.rs Migrates covariates example to ode! with covariate declarations and name-based indices.
examples/compare_solvers.rs Migrates solver comparison example to declaration-first ode! and shared-channel route semantics.
examples/analytical_vs_ode.rs Migrates comparison example to macro surfaces and name-based indices.
examples/analytical_readme.rs New analytical macro example for README-style docs.
README.md Rewrites quick start to prefer macro surfaces and links to new examples/migration docs.
.gitignore Adds docs/ to ignored paths.
Comments suppressed due to low confidence (3)

src/dsl/wasm.rs:932

  • CompiledModelInfoEnvelope doesn’t define a name field; it requires model: NativeModelInfo. As written this won’t compile and it ignores the model_info variable defined just above. Use the model field here as in other call sites.
    fn rejects_compiled_metadata_abi_version_mismatch() {
        let model_info = loader_test_model_info("metadata_api_version_mismatch");
        let metadata = serde_json::to_vec(&CompiledModelInfoEnvelope {
            abi_version: WASM_API_VERSION + 1,
            name: "model_info",
            kernels: CompiledKernelAvailability {
                outputs: true,
                ..CompiledKernelAvailability::default()
            },
        })

src/dsl/wasm.rs:958

  • CompiledModelInfoEnvelope is being constructed with a nonexistent name field and without the required model field. This will fail to compile; pass the NativeModelInfo in the model field instead.
    fn rejects_kernel_metadata_mismatch_from_compiled_envelope() {
        let model_info = loader_test_model_info("kernel_metadata_mismatch");
        let metadata = serde_json::to_vec(&CompiledModelInfoEnvelope {
            abi_version: WASM_API_VERSION,
            name: "model_info",
            kernels: CompiledKernelAvailability {
                outputs: true,
                ..CompiledKernelAvailability::default()
            },
        })

src/dsl/wasm.rs:903

  • CompiledModelInfoEnvelope does not have a name field (it has model: NativeModelInfo). This test code will not compile and also drops the model_info value it just computed. Populate the model field instead (and remove the now-unused model_info binding if appropriate).
        let model_info = loader_test_model_info("api_version_export_mismatch");
        let metadata = serde_json::to_vec(&CompiledModelInfoEnvelope {
            abi_version: WASM_API_VERSION,
            name: "model_info",
            kernels: CompiledKernelAvailability {
                outputs: true,
                ..CompiledKernelAvailability::default()
            },
        })

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread examples/one_compartment.rs Outdated
Comment thread pharmsol-dsl/src/authoring.rs Outdated
Comment thread pharmsol-dsl/src/authoring.rs Outdated
Comment thread src/dsl/native.rs Outdated
Comment on lines +384 to +387
Err(PharmsolError::OtherError(format!(
"model `{}` does not declare a {:?} route for input channel {}",
self.info.name, kind, input
)))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is so common of an error that we may want to be able to match on it

@Siel Siel force-pushed the feat/add-missing-macros branch from e58f327 to 8517fa8 Compare May 11, 2026 09:18
@Siel Siel merged commit 5a6177e into main May 11, 2026
3 of 4 checks passed
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.

3 participants