Skip to content

Repository files navigation

nvQSP v0.2.0

GPU-accelerated stiff ODE solvers for Quantitative Systems Pharmacology (QSP) and PBPK population studies, with first-class gradient support. This release provides a sparse polynomial RODAS4 solver (prebuilt; no CUDA Toolkit needed at runtime) and a model-specialized dense adaptive TSIT5 solver, each with gradient exposure.

Distribution

ChannelInstall
PyPIpip install nvqsp
GitHub Releasenvqsp_0.2.0_amd64.deb (C/C++ headers + lib)
GitHub Releaselibsparse_rodas4.so (standalone shared library)

AI Agent Skill

This repository includes source for a skill that helps AI agents translate QSP/PBPK compartmental models into nvQSP's A0, A1, and A2 coefficient form.

The reviewable source for the skill lives in skills/nvqsp/. Maintainers should edit that source tree directly.

The skill does not change nvQSP runtime requirements; users still need the Python package or C/C++ library installed as described below.

All binaries are fat binaries with native code for:

  • sm_80 — Ampere (A100, A10)
  • sm_89 — Ada Lovelace (L4, L40, RTX 4090)
  • sm_90 — Hopper (H100, H200)
  • compute_90 PTX — forward compatibility for future architectures (Blackwell, etc.)

Requirements

  • Linux x86_64
  • NVIDIA GPU: Ampere (sm_80), Ada Lovelace (sm_89), or Hopper (sm_90)
  • NVIDIA driver 525+ (CUDA runtime 12.0+)
  • Python 3.8+ with NumPy (for the Python API)
  • PyTorch 2.0+ only when using the optional autograd bridge
  • CUDA Toolkit (nvcc) only when building a dense TSIT5 model library

The sparse RODAS4 solver needs no CUDA Toolkit at runtime — it ships as a prebuilt library. Only nvqsp.tsit5.build_model() (dense TSIT5 model specialization) and building from source require nvcc.

Quick Install

Python (from PyPI):

pip install nvqsp

C/C++ (Debian/Ubuntu):

Download nvqsp_0.2.0_amd64.deb from the GitHub release, then:

sudo dpkg -i nvqsp_0.2.0_amd64.deb

See INSTALL.md for full details.

Quick Start

importnumpyasnpfromscipy.sparseimportcsr_matrixfromnvqspimportsparsefromnvqsp.optionsimportSparseOptions# Two-compartment model: dy/dt = A0 + A1*y + A2*(y x y)neq=2A0=np.array([0.0, 0.0])
A1=csr_matrix([[-0.3, 0.1], [0.3, -0.1]])
A1_rowptr=A1.indptr.astype(np.int32)
A1_col=A1.indices.astype(np.int32)
A1_val=A1.data.astype(np.float64)
# A2 must have >= 1 entry; use epsilon for purely linear modelsA2_rowptr=np.array([0, 1, 1], dtype=np.int32)
A2_col1=np.array([0], dtype=np.int32)
A2_col2=np.array([0], dtype=np.int32)
A2_val=np.array([1e-30])
# 100 patients, 48 time points, dose of 100 mg at t=0result=sparse.solve(
A0=A0,
A1_csr=(A1_rowptr, A1_col, A1_val),
A2_csr=(A2_rowptr, A2_col1, A2_col2, A2_val),
y0=np.tile([10.0, 0.0], (100, 1)),
times=np.linspace(1.0, 24.0, 48),
doses=[(0.0, 100.0)],
opts=SparseOptions(rtol=1e-6, atol=1e-9),
)
print(result.y.shape) # (100, 48, 2)print(result.steps) # total ODE steps across all patients

See API_REFERENCE.md for the complete Python and C API.

Gradient Exposure

nvqsp.gradients computes continuous forward sensitivities of the same polynomial model in a single augmented GPU solve. Supply the derivatives of the direct coefficients and the initial state with respect to each user parameter:

importnumpyasnpfromnvqspimportCoefficientDerivatives, gradients# The parameter axis P is always last. This example differentiates a single# clearance parameter carried through the sparse A1 values.dA1=np.zeros((A1_val.size, 1)) # (A1_nnz, P)dA1[0, 0] =-1.0gradient_result=gradients.solve(
A0=A0,
A1_csr=(A1_rowptr, A1_col, A1_val),
A2_csr=(A2_rowptr, A2_col1, A2_col2, A2_val),
y0=np.array([10.0, 0.0]),
times=np.linspace(1.0, 24.0, 48),
derivatives=CoefficientDerivatives(
parameter_names=("clearance",),
dA1=dA1,
),
)
print(gradient_result.y.shape) # (1, 48, 2)print(gradient_result.dy_dtheta.shape) # (1, 48, 2, 1)

The augmented system holds the original neq states plus one neq-state sensitivity block per parameter, so memory and work grow linearly with the number of differentiated parameters P. Forward mode is intended for a modest number of parameters. These are derivatives of the continuous ODE solution; adaptive step-size and controller decisions are not differentiation targets.

For training, install the optional dependency (pip install "nvqsp[torch]") and use nvqsp.torch.solve. It accepts direct coefficient tensors and y0, returns an ordinary PyTorch tensor, and uses the same continuous sensitivities during backpropagation. SensitivityTargets restricts differentiation to selected coefficient slots to bound augmented-system size. Importing nvqsp never imports PyTorch, so inference-only deployments keep the minimal dependency set. The bridge supports first-order VJPs and rejects higher-order autograd.

Fixed dose schedules may be used during a gradient solve, but dose times and dose amounts are not differentiation targets in this release.

Dense TSIT5 Solver (with gradients)

For general (non-stiff and mildly stiff) systems, nvqsp.tsit5 runs an adaptive 5th-order TSIT5 integrator as a model-specialized CUDA library and exposes central-finite-difference gradients with respect to parameters (theta) or initial conditions (y0).

Unlike the sparse RODAS4 solver — which ships as one prebuilt library — dense TSIT5 is specialized per model: nvqsp.tsit5.build_model() generates and compiles CUDA for your model, so it requires a CUDA Toolkit (nvcc). Solving and differentiating an already-built library does not.

importnumpyasnpfromnvqspimporttsit5, GradientRequest, GradientTarget# 1) Build a model-specialized library once (requires nvcc).build=tsit5.build_model(model, "artifacts/", cuda_arch="sm_80")
# 2) Solve a batch of trajectories on the GPU.solve=tsit5.solve(
build.library_path,
y0=y0, # (neq,) or (batch, neq)theta=theta, # (P,) or (batch, P)times=np.linspace(0.0, 10.0, 64),
)
print(solve.y.shape) # (batch, n_times, neq)# 3) Gradients w.r.t. selected parameters.grad=tsit5.solve_with_gradients(
build.library_path,
y0=y0,
theta=theta,
times=np.linspace(0.0, 10.0, 64),
request=GradientRequest(target=GradientTarget.THETA, indices=None),
)
print(grad.gradients.shape) # (batch, time, state, n_selected)

nvqsp.tsit5.reference_solve_model_with_gradients() and validate_gradients() cross-check TSIT5 gradients against a tight SciPy CPU reference, and nvqsp.tsit5.solve_torch exposes the solver as a differentiable PyTorch operation. The gradient method is central finite differences; cost scales with the number of requested coordinates.

Model Form

The solver handles polynomial ODE systems of the form:

dy/dt = A0 + A1 * y + A2 * (y x y)
TermShapeMeaning
A0(neq,)Zeroth-order: constant synthesis, zero-order infusion
A1(neq, neq) sparse CSRFirst-order: linear elimination, transfer rates
A2(neq, neq, neq) sparse CSRSecond-order: bilinear / mass-action terms

Covers: all linear PBPK models, first-order absorption, IV bolus/infusion, bimolecular mass-action kinetics (drug-receptor binding, target-mediated disposition with second-order approximation).

Does not cover: Michaelis-Menten elimination, Hill-function PD, TMDD with quasi-steady-state, indirect response models, DAE systems.

Documentation

License

This software is licensed under the NVIDIA Software License Agreement and the Product-Specific Terms for AI Products. By downloading, installing, or using this software you agree to the terms of both licenses.

About

GPU-accelerated Quantitative Systems Pharmacology (QSP) ODE solvers.

Resources

Stars

18 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
GitHub - NVIDIA-BioNeMo/nvQSP: GPU-accelerated Quantitative Systems Pharmacology (QSP) ODE solvers. · GitHub
Skip to content

Repository files navigation

nvQSP v0.2.0

GPU-accelerated stiff ODE solvers for Quantitative Systems Pharmacology (QSP) and PBPK population studies, with first-class gradient support. This release provides a sparse polynomial RODAS4 solver (prebuilt; no CUDA Toolkit needed at runtime) and a model-specialized dense adaptive TSIT5 solver, each with gradient exposure.

Distribution

ChannelInstall
PyPIpip install nvqsp
GitHub Releasenvqsp_0.2.0_amd64.deb (C/C++ headers + lib)
GitHub Releaselibsparse_rodas4.so (standalone shared library)

AI Agent Skill

This repository includes source for a skill that helps AI agents translate QSP/PBPK compartmental models into nvQSP's A0, A1, and A2 coefficient form.

The reviewable source for the skill lives in skills/nvqsp/. Maintainers should edit that source tree directly.

The skill does not change nvQSP runtime requirements; users still need the Python package or C/C++ library installed as described below.

All binaries are fat binaries with native code for:

  • sm_80 — Ampere (A100, A10)
  • sm_89 — Ada Lovelace (L4, L40, RTX 4090)
  • sm_90 — Hopper (H100, H200)
  • compute_90 PTX — forward compatibility for future architectures (Blackwell, etc.)

Requirements

  • Linux x86_64
  • NVIDIA GPU: Ampere (sm_80), Ada Lovelace (sm_89), or Hopper (sm_90)
  • NVIDIA driver 525+ (CUDA runtime 12.0+)
  • Python 3.8+ with NumPy (for the Python API)
  • PyTorch 2.0+ only when using the optional autograd bridge
  • CUDA Toolkit (nvcc) only when building a dense TSIT5 model library

The sparse RODAS4 solver needs no CUDA Toolkit at runtime — it ships as a prebuilt library. Only nvqsp.tsit5.build_model() (dense TSIT5 model specialization) and building from source require nvcc.

Quick Install

Python (from PyPI):

pip install nvqsp

C/C++ (Debian/Ubuntu):

Download nvqsp_0.2.0_amd64.deb from the GitHub release, then:

sudo dpkg -i nvqsp_0.2.0_amd64.deb

See INSTALL.md for full details.

Quick Start

importnumpyasnpfromscipy.sparseimportcsr_matrixfromnvqspimportsparsefromnvqsp.optionsimportSparseOptions# Two-compartment model: dy/dt = A0 + A1*y + A2*(y x y)neq=2A0=np.array([0.0, 0.0])
A1=csr_matrix([[-0.3, 0.1], [0.3, -0.1]])
A1_rowptr=A1.indptr.astype(np.int32)
A1_col=A1.indices.astype(np.int32)
A1_val=A1.data.astype(np.float64)
# A2 must have >= 1 entry; use epsilon for purely linear modelsA2_rowptr=np.array([0, 1, 1], dtype=np.int32)
A2_col1=np.array([0], dtype=np.int32)
A2_col2=np.array([0], dtype=np.int32)
A2_val=np.array([1e-30])
# 100 patients, 48 time points, dose of 100 mg at t=0result=sparse.solve(
A0=A0,
A1_csr=(A1_rowptr, A1_col, A1_val),
A2_csr=(A2_rowptr, A2_col1, A2_col2, A2_val),
y0=np.tile([10.0, 0.0], (100, 1)),
times=np.linspace(1.0, 24.0, 48),
doses=[(0.0, 100.0)],
opts=SparseOptions(rtol=1e-6, atol=1e-9),
)
print(result.y.shape) # (100, 48, 2)print(result.steps) # total ODE steps across all patients

See API_REFERENCE.md for the complete Python and C API.

Gradient Exposure

nvqsp.gradients computes continuous forward sensitivities of the same polynomial model in a single augmented GPU solve. Supply the derivatives of the direct coefficients and the initial state with respect to each user parameter:

importnumpyasnpfromnvqspimportCoefficientDerivatives, gradients# The parameter axis P is always last. This example differentiates a single# clearance parameter carried through the sparse A1 values.dA1=np.zeros((A1_val.size, 1)) # (A1_nnz, P)dA1[0, 0] =-1.0gradient_result=gradients.solve(
A0=A0,
A1_csr=(A1_rowptr, A1_col, A1_val),
A2_csr=(A2_rowptr, A2_col1, A2_col2, A2_val),
y0=np.array([10.0, 0.0]),
times=np.linspace(1.0, 24.0, 48),
derivatives=CoefficientDerivatives(
parameter_names=("clearance",),
dA1=dA1,
),
)
print(gradient_result.y.shape) # (1, 48, 2)print(gradient_result.dy_dtheta.shape) # (1, 48, 2, 1)

The augmented system holds the original neq states plus one neq-state sensitivity block per parameter, so memory and work grow linearly with the number of differentiated parameters P. Forward mode is intended for a modest number of parameters. These are derivatives of the continuous ODE solution; adaptive step-size and controller decisions are not differentiation targets.

For training, install the optional dependency (pip install "nvqsp[torch]") and use nvqsp.torch.solve. It accepts direct coefficient tensors and y0, returns an ordinary PyTorch tensor, and uses the same continuous sensitivities during backpropagation. SensitivityTargets restricts differentiation to selected coefficient slots to bound augmented-system size. Importing nvqsp never imports PyTorch, so inference-only deployments keep the minimal dependency set. The bridge supports first-order VJPs and rejects higher-order autograd.

Fixed dose schedules may be used during a gradient solve, but dose times and dose amounts are not differentiation targets in this release.

Dense TSIT5 Solver (with gradients)

For general (non-stiff and mildly stiff) systems, nvqsp.tsit5 runs an adaptive 5th-order TSIT5 integrator as a model-specialized CUDA library and exposes central-finite-difference gradients with respect to parameters (theta) or initial conditions (y0).

Unlike the sparse RODAS4 solver — which ships as one prebuilt library — dense TSIT5 is specialized per model: nvqsp.tsit5.build_model() generates and compiles CUDA for your model, so it requires a CUDA Toolkit (nvcc). Solving and differentiating an already-built library does not.

importnumpyasnpfromnvqspimporttsit5, GradientRequest, GradientTarget# 1) Build a model-specialized library once (requires nvcc).build=tsit5.build_model(model, "artifacts/", cuda_arch="sm_80")
# 2) Solve a batch of trajectories on the GPU.solve=tsit5.solve(
build.library_path,
y0=y0, # (neq,) or (batch, neq)theta=theta, # (P,) or (batch, P)times=np.linspace(0.0, 10.0, 64),
)
print(solve.y.shape) # (batch, n_times, neq)# 3) Gradients w.r.t. selected parameters.grad=tsit5.solve_with_gradients(
build.library_path,
y0=y0,
theta=theta,
times=np.linspace(0.0, 10.0, 64),
request=GradientRequest(target=GradientTarget.THETA, indices=None),
)
print(grad.gradients.shape) # (batch, time, state, n_selected)

nvqsp.tsit5.reference_solve_model_with_gradients() and validate_gradients() cross-check TSIT5 gradients against a tight SciPy CPU reference, and nvqsp.tsit5.solve_torch exposes the solver as a differentiable PyTorch operation. The gradient method is central finite differences; cost scales with the number of requested coordinates.

Model Form

The solver handles polynomial ODE systems of the form:

dy/dt = A0 + A1 * y + A2 * (y x y)
TermShapeMeaning
A0(neq,)Zeroth-order: constant synthesis, zero-order infusion
A1(neq, neq) sparse CSRFirst-order: linear elimination, transfer rates
A2(neq, neq, neq) sparse CSRSecond-order: bilinear / mass-action terms

Covers: all linear PBPK models, first-order absorption, IV bolus/infusion, bimolecular mass-action kinetics (drug-receptor binding, target-mediated disposition with second-order approximation).

Does not cover: Michaelis-Menten elimination, Hill-function PD, TMDD with quasi-steady-state, indirect response models, DAE systems.

Documentation

License

This software is licensed under the NVIDIA Software License Agreement and the Product-Specific Terms for AI Products. By downloading, installing, or using this software you agree to the terms of both licenses.

About

GPU-accelerated Quantitative Systems Pharmacology (QSP) ODE solvers.

Resources

Stars

18 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - NVIDIA-BioNeMo/nvQSP: GPU-accelerated Quantitative Systems Pharmacology (QSP) ODE solvers. · GitHub
Skip to content

Repository files navigation

nvQSP v0.2.0

GPU-accelerated stiff ODE solvers for Quantitative Systems Pharmacology (QSP) and PBPK population studies, with first-class gradient support. This release provides a sparse polynomial RODAS4 solver (prebuilt; no CUDA Toolkit needed at runtime) and a model-specialized dense adaptive TSIT5 solver, each with gradient exposure.

Distribution

ChannelInstall
PyPIpip install nvqsp
GitHub Releasenvqsp_0.2.0_amd64.deb (C/C++ headers + lib)
GitHub Releaselibsparse_rodas4.so (standalone shared library)

AI Agent Skill

This repository includes source for a skill that helps AI agents translate QSP/PBPK compartmental models into nvQSP's A0, A1, and A2 coefficient form.

The reviewable source for the skill lives in skills/nvqsp/. Maintainers should edit that source tree directly.

The skill does not change nvQSP runtime requirements; users still need the Python package or C/C++ library installed as described below.

All binaries are fat binaries with native code for:

  • sm_80 — Ampere (A100, A10)
  • sm_89 — Ada Lovelace (L4, L40, RTX 4090)
  • sm_90 — Hopper (H100, H200)
  • compute_90 PTX — forward compatibility for future architectures (Blackwell, etc.)

Requirements

  • Linux x86_64
  • NVIDIA GPU: Ampere (sm_80), Ada Lovelace (sm_89), or Hopper (sm_90)
  • NVIDIA driver 525+ (CUDA runtime 12.0+)
  • Python 3.8+ with NumPy (for the Python API)
  • PyTorch 2.0+ only when using the optional autograd bridge
  • CUDA Toolkit (nvcc) only when building a dense TSIT5 model library

The sparse RODAS4 solver needs no CUDA Toolkit at runtime — it ships as a prebuilt library. Only nvqsp.tsit5.build_model() (dense TSIT5 model specialization) and building from source require nvcc.

Quick Install

Python (from PyPI):

pip install nvqsp

C/C++ (Debian/Ubuntu):

Download nvqsp_0.2.0_amd64.deb from the GitHub release, then:

sudo dpkg -i nvqsp_0.2.0_amd64.deb

See INSTALL.md for full details.

Quick Start

importnumpyasnpfromscipy.sparseimportcsr_matrixfromnvqspimportsparsefromnvqsp.optionsimportSparseOptions# Two-compartment model: dy/dt = A0 + A1*y + A2*(y x y)neq=2A0=np.array([0.0, 0.0])
A1=csr_matrix([[-0.3, 0.1], [0.3, -0.1]])
A1_rowptr=A1.indptr.astype(np.int32)
A1_col=A1.indices.astype(np.int32)
A1_val=A1.data.astype(np.float64)
# A2 must have >= 1 entry; use epsilon for purely linear modelsA2_rowptr=np.array([0, 1, 1], dtype=np.int32)
A2_col1=np.array([0], dtype=np.int32)
A2_col2=np.array([0], dtype=np.int32)
A2_val=np.array([1e-30])
# 100 patients, 48 time points, dose of 100 mg at t=0result=sparse.solve(
A0=A0,
A1_csr=(A1_rowptr, A1_col, A1_val),
A2_csr=(A2_rowptr, A2_col1, A2_col2, A2_val),
y0=np.tile([10.0, 0.0], (100, 1)),
times=np.linspace(1.0, 24.0, 48),
doses=[(0.0, 100.0)],
opts=SparseOptions(rtol=1e-6, atol=1e-9),
)
print(result.y.shape) # (100, 48, 2)print(result.steps) # total ODE steps across all patients

See API_REFERENCE.md for the complete Python and C API.

Gradient Exposure

nvqsp.gradients computes continuous forward sensitivities of the same polynomial model in a single augmented GPU solve. Supply the derivatives of the direct coefficients and the initial state with respect to each user parameter:

importnumpyasnpfromnvqspimportCoefficientDerivatives, gradients# The parameter axis P is always last. This example differentiates a single# clearance parameter carried through the sparse A1 values.dA1=np.zeros((A1_val.size, 1)) # (A1_nnz, P)dA1[0, 0] =-1.0gradient_result=gradients.solve(
A0=A0,
A1_csr=(A1_rowptr, A1_col, A1_val),
A2_csr=(A2_rowptr, A2_col1, A2_col2, A2_val),
y0=np.array([10.0, 0.0]),
times=np.linspace(1.0, 24.0, 48),
derivatives=CoefficientDerivatives(
parameter_names=("clearance",),
dA1=dA1,
),
)
print(gradient_result.y.shape) # (1, 48, 2)print(gradient_result.dy_dtheta.shape) # (1, 48, 2, 1)

The augmented system holds the original neq states plus one neq-state sensitivity block per parameter, so memory and work grow linearly with the number of differentiated parameters P. Forward mode is intended for a modest number of parameters. These are derivatives of the continuous ODE solution; adaptive step-size and controller decisions are not differentiation targets.

For training, install the optional dependency (pip install "nvqsp[torch]") and use nvqsp.torch.solve. It accepts direct coefficient tensors and y0, returns an ordinary PyTorch tensor, and uses the same continuous sensitivities during backpropagation. SensitivityTargets restricts differentiation to selected coefficient slots to bound augmented-system size. Importing nvqsp never imports PyTorch, so inference-only deployments keep the minimal dependency set. The bridge supports first-order VJPs and rejects higher-order autograd.

Fixed dose schedules may be used during a gradient solve, but dose times and dose amounts are not differentiation targets in this release.

Dense TSIT5 Solver (with gradients)

For general (non-stiff and mildly stiff) systems, nvqsp.tsit5 runs an adaptive 5th-order TSIT5 integrator as a model-specialized CUDA library and exposes central-finite-difference gradients with respect to parameters (theta) or initial conditions (y0).

Unlike the sparse RODAS4 solver — which ships as one prebuilt library — dense TSIT5 is specialized per model: nvqsp.tsit5.build_model() generates and compiles CUDA for your model, so it requires a CUDA Toolkit (nvcc). Solving and differentiating an already-built library does not.

importnumpyasnpfromnvqspimporttsit5, GradientRequest, GradientTarget# 1) Build a model-specialized library once (requires nvcc).build=tsit5.build_model(model, "artifacts/", cuda_arch="sm_80")
# 2) Solve a batch of trajectories on the GPU.solve=tsit5.solve(
build.library_path,
y0=y0, # (neq,) or (batch, neq)theta=theta, # (P,) or (batch, P)times=np.linspace(0.0, 10.0, 64),
)
print(solve.y.shape) # (batch, n_times, neq)# 3) Gradients w.r.t. selected parameters.grad=tsit5.solve_with_gradients(
build.library_path,
y0=y0,
theta=theta,
times=np.linspace(0.0, 10.0, 64),
request=GradientRequest(target=GradientTarget.THETA, indices=None),
)
print(grad.gradients.shape) # (batch, time, state, n_selected)

nvqsp.tsit5.reference_solve_model_with_gradients() and validate_gradients() cross-check TSIT5 gradients against a tight SciPy CPU reference, and nvqsp.tsit5.solve_torch exposes the solver as a differentiable PyTorch operation. The gradient method is central finite differences; cost scales with the number of requested coordinates.

Model Form

The solver handles polynomial ODE systems of the form:

dy/dt = A0 + A1 * y + A2 * (y x y)
TermShapeMeaning
A0(neq,)Zeroth-order: constant synthesis, zero-order infusion
A1(neq, neq) sparse CSRFirst-order: linear elimination, transfer rates
A2(neq, neq, neq) sparse CSRSecond-order: bilinear / mass-action terms

Covers: all linear PBPK models, first-order absorption, IV bolus/infusion, bimolecular mass-action kinetics (drug-receptor binding, target-mediated disposition with second-order approximation).

Does not cover: Michaelis-Menten elimination, Hill-function PD, TMDD with quasi-steady-state, indirect response models, DAE systems.

Documentation

License

This software is licensed under the NVIDIA Software License Agreement and the Product-Specific Terms for AI Products. By downloading, installing, or using this software you agree to the terms of both licenses.

About

GPU-accelerated Quantitative Systems Pharmacology (QSP) ODE solvers.

Resources

Stars

18 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - NVIDIA-BioNeMo/nvQSP: GPU-accelerated Quantitative Systems Pharmacology (QSP) ODE solvers. · GitHub
Skip to content

Repository files navigation

nvQSP v0.2.0

GPU-accelerated stiff ODE solvers for Quantitative Systems Pharmacology (QSP) and PBPK population studies, with first-class gradient support. This release provides a sparse polynomial RODAS4 solver (prebuilt; no CUDA Toolkit needed at runtime) and a model-specialized dense adaptive TSIT5 solver, each with gradient exposure.

Distribution

ChannelInstall
PyPIpip install nvqsp
GitHub Releasenvqsp_0.2.0_amd64.deb (C/C++ headers + lib)
GitHub Releaselibsparse_rodas4.so (standalone shared library)

AI Agent Skill

This repository includes source for a skill that helps AI agents translate QSP/PBPK compartmental models into nvQSP's A0, A1, and A2 coefficient form.

The reviewable source for the skill lives in skills/nvqsp/. Maintainers should edit that source tree directly.

The skill does not change nvQSP runtime requirements; users still need the Python package or C/C++ library installed as described below.

All binaries are fat binaries with native code for:

  • sm_80 — Ampere (A100, A10)
  • sm_89 — Ada Lovelace (L4, L40, RTX 4090)
  • sm_90 — Hopper (H100, H200)
  • compute_90 PTX — forward compatibility for future architectures (Blackwell, etc.)

Requirements

  • Linux x86_64
  • NVIDIA GPU: Ampere (sm_80), Ada Lovelace (sm_89), or Hopper (sm_90)
  • NVIDIA driver 525+ (CUDA runtime 12.0+)
  • Python 3.8+ with NumPy (for the Python API)
  • PyTorch 2.0+ only when using the optional autograd bridge
  • CUDA Toolkit (nvcc) only when building a dense TSIT5 model library

The sparse RODAS4 solver needs no CUDA Toolkit at runtime — it ships as a prebuilt library. Only nvqsp.tsit5.build_model() (dense TSIT5 model specialization) and building from source require nvcc.

Quick Install

Python (from PyPI):

pip install nvqsp

C/C++ (Debian/Ubuntu):

Download nvqsp_0.2.0_amd64.deb from the GitHub release, then:

sudo dpkg -i nvqsp_0.2.0_amd64.deb

See INSTALL.md for full details.

Quick Start

importnumpyasnpfromscipy.sparseimportcsr_matrixfromnvqspimportsparsefromnvqsp.optionsimportSparseOptions# Two-compartment model: dy/dt = A0 + A1*y + A2*(y x y)neq=2A0=np.array([0.0, 0.0])
A1=csr_matrix([[-0.3, 0.1], [0.3, -0.1]])
A1_rowptr=A1.indptr.astype(np.int32)
A1_col=A1.indices.astype(np.int32)
A1_val=A1.data.astype(np.float64)
# A2 must have >= 1 entry; use epsilon for purely linear modelsA2_rowptr=np.array([0, 1, 1], dtype=np.int32)
A2_col1=np.array([0], dtype=np.int32)
A2_col2=np.array([0], dtype=np.int32)
A2_val=np.array([1e-30])
# 100 patients, 48 time points, dose of 100 mg at t=0result=sparse.solve(
A0=A0,
A1_csr=(A1_rowptr, A1_col, A1_val),
A2_csr=(A2_rowptr, A2_col1, A2_col2, A2_val),
y0=np.tile([10.0, 0.0], (100, 1)),
times=np.linspace(1.0, 24.0, 48),
doses=[(0.0, 100.0)],
opts=SparseOptions(rtol=1e-6, atol=1e-9),
)
print(result.y.shape) # (100, 48, 2)print(result.steps) # total ODE steps across all patients

See API_REFERENCE.md for the complete Python and C API.

Gradient Exposure

nvqsp.gradients computes continuous forward sensitivities of the same polynomial model in a single augmented GPU solve. Supply the derivatives of the direct coefficients and the initial state with respect to each user parameter:

importnumpyasnpfromnvqspimportCoefficientDerivatives, gradients# The parameter axis P is always last. This example differentiates a single# clearance parameter carried through the sparse A1 values.dA1=np.zeros((A1_val.size, 1)) # (A1_nnz, P)dA1[0, 0] =-1.0gradient_result=gradients.solve(
A0=A0,
A1_csr=(A1_rowptr, A1_col, A1_val),
A2_csr=(A2_rowptr, A2_col1, A2_col2, A2_val),
y0=np.array([10.0, 0.0]),
times=np.linspace(1.0, 24.0, 48),
derivatives=CoefficientDerivatives(
parameter_names=("clearance",),
dA1=dA1,
),
)
print(gradient_result.y.shape) # (1, 48, 2)print(gradient_result.dy_dtheta.shape) # (1, 48, 2, 1)

The augmented system holds the original neq states plus one neq-state sensitivity block per parameter, so memory and work grow linearly with the number of differentiated parameters P. Forward mode is intended for a modest number of parameters. These are derivatives of the continuous ODE solution; adaptive step-size and controller decisions are not differentiation targets.

For training, install the optional dependency (pip install "nvqsp[torch]") and use nvqsp.torch.solve. It accepts direct coefficient tensors and y0, returns an ordinary PyTorch tensor, and uses the same continuous sensitivities during backpropagation. SensitivityTargets restricts differentiation to selected coefficient slots to bound augmented-system size. Importing nvqsp never imports PyTorch, so inference-only deployments keep the minimal dependency set. The bridge supports first-order VJPs and rejects higher-order autograd.

Fixed dose schedules may be used during a gradient solve, but dose times and dose amounts are not differentiation targets in this release.

Dense TSIT5 Solver (with gradients)

For general (non-stiff and mildly stiff) systems, nvqsp.tsit5 runs an adaptive 5th-order TSIT5 integrator as a model-specialized CUDA library and exposes central-finite-difference gradients with respect to parameters (theta) or initial conditions (y0).

Unlike the sparse RODAS4 solver — which ships as one prebuilt library — dense TSIT5 is specialized per model: nvqsp.tsit5.build_model() generates and compiles CUDA for your model, so it requires a CUDA Toolkit (nvcc). Solving and differentiating an already-built library does not.

importnumpyasnpfromnvqspimporttsit5, GradientRequest, GradientTarget# 1) Build a model-specialized library once (requires nvcc).build=tsit5.build_model(model, "artifacts/", cuda_arch="sm_80")
# 2) Solve a batch of trajectories on the GPU.solve=tsit5.solve(
build.library_path,
y0=y0, # (neq,) or (batch, neq)theta=theta, # (P,) or (batch, P)times=np.linspace(0.0, 10.0, 64),
)
print(solve.y.shape) # (batch, n_times, neq)# 3) Gradients w.r.t. selected parameters.grad=tsit5.solve_with_gradients(
build.library_path,
y0=y0,
theta=theta,
times=np.linspace(0.0, 10.0, 64),
request=GradientRequest(target=GradientTarget.THETA, indices=None),
)
print(grad.gradients.shape) # (batch, time, state, n_selected)

nvqsp.tsit5.reference_solve_model_with_gradients() and validate_gradients() cross-check TSIT5 gradients against a tight SciPy CPU reference, and nvqsp.tsit5.solve_torch exposes the solver as a differentiable PyTorch operation. The gradient method is central finite differences; cost scales with the number of requested coordinates.

Model Form

The solver handles polynomial ODE systems of the form:

dy/dt = A0 + A1 * y + A2 * (y x y)
TermShapeMeaning
A0(neq,)Zeroth-order: constant synthesis, zero-order infusion
A1(neq, neq) sparse CSRFirst-order: linear elimination, transfer rates
A2(neq, neq, neq) sparse CSRSecond-order: bilinear / mass-action terms

Covers: all linear PBPK models, first-order absorption, IV bolus/infusion, bimolecular mass-action kinetics (drug-receptor binding, target-mediated disposition with second-order approximation).

Does not cover: Michaelis-Menten elimination, Hill-function PD, TMDD with quasi-steady-state, indirect response models, DAE systems.

Documentation

License

This software is licensed under the NVIDIA Software License Agreement and the Product-Specific Terms for AI Products. By downloading, installing, or using this software you agree to the terms of both licenses.

About

GPU-accelerated Quantitative Systems Pharmacology (QSP) ODE solvers.

Resources

Stars

18 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' GitHub - NVIDIA-BioNeMo/nvQSP: GPU-accelerated Quantitative Systems Pharmacology (QSP) ODE solvers. · GitHub
Skip to content

Repository files navigation

nvQSP v0.2.0

GPU-accelerated stiff ODE solvers for Quantitative Systems Pharmacology (QSP) and PBPK population studies, with first-class gradient support. This release provides a sparse polynomial RODAS4 solver (prebuilt; no CUDA Toolkit needed at runtime) and a model-specialized dense adaptive TSIT5 solver, each with gradient exposure.

Distribution

ChannelInstall
PyPIpip install nvqsp
GitHub Releasenvqsp_0.2.0_amd64.deb (C/C++ headers + lib)
GitHub Releaselibsparse_rodas4.so (standalone shared library)

AI Agent Skill

This repository includes source for a skill that helps AI agents translate QSP/PBPK compartmental models into nvQSP's A0, A1, and A2 coefficient form.

The reviewable source for the skill lives in skills/nvqsp/. Maintainers should edit that source tree directly.

The skill does not change nvQSP runtime requirements; users still need the Python package or C/C++ library installed as described below.

All binaries are fat binaries with native code for:

  • sm_80 — Ampere (A100, A10)
  • sm_89 — Ada Lovelace (L4, L40, RTX 4090)
  • sm_90 — Hopper (H100, H200)
  • compute_90 PTX — forward compatibility for future architectures (Blackwell, etc.)

Requirements

  • Linux x86_64
  • NVIDIA GPU: Ampere (sm_80), Ada Lovelace (sm_89), or Hopper (sm_90)
  • NVIDIA driver 525+ (CUDA runtime 12.0+)
  • Python 3.8+ with NumPy (for the Python API)
  • PyTorch 2.0+ only when using the optional autograd bridge
  • CUDA Toolkit (nvcc) only when building a dense TSIT5 model library

The sparse RODAS4 solver needs no CUDA Toolkit at runtime — it ships as a prebuilt library. Only nvqsp.tsit5.build_model() (dense TSIT5 model specialization) and building from source require nvcc.

Quick Install

Python (from PyPI):

pip install nvqsp

C/C++ (Debian/Ubuntu):

Download nvqsp_0.2.0_amd64.deb from the GitHub release, then:

sudo dpkg -i nvqsp_0.2.0_amd64.deb

See INSTALL.md for full details.

Quick Start

importnumpyasnpfromscipy.sparseimportcsr_matrixfromnvqspimportsparsefromnvqsp.optionsimportSparseOptions# Two-compartment model: dy/dt = A0 + A1*y + A2*(y x y)neq=2A0=np.array([0.0, 0.0])
A1=csr_matrix([[-0.3, 0.1], [0.3, -0.1]])
A1_rowptr=A1.indptr.astype(np.int32)
A1_col=A1.indices.astype(np.int32)
A1_val=A1.data.astype(np.float64)
# A2 must have >= 1 entry; use epsilon for purely linear modelsA2_rowptr=np.array([0, 1, 1], dtype=np.int32)
A2_col1=np.array([0], dtype=np.int32)
A2_col2=np.array([0], dtype=np.int32)
A2_val=np.array([1e-30])
# 100 patients, 48 time points, dose of 100 mg at t=0result=sparse.solve(
A0=A0,
A1_csr=(A1_rowptr, A1_col, A1_val),
A2_csr=(A2_rowptr, A2_col1, A2_col2, A2_val),
y0=np.tile([10.0, 0.0], (100, 1)),
times=np.linspace(1.0, 24.0, 48),
doses=[(0.0, 100.0)],
opts=SparseOptions(rtol=1e-6, atol=1e-9),
)
print(result.y.shape) # (100, 48, 2)print(result.steps) # total ODE steps across all patients

See API_REFERENCE.md for the complete Python and C API.

Gradient Exposure

nvqsp.gradients computes continuous forward sensitivities of the same polynomial model in a single augmented GPU solve. Supply the derivatives of the direct coefficients and the initial state with respect to each user parameter:

importnumpyasnpfromnvqspimportCoefficientDerivatives, gradients# The parameter axis P is always last. This example differentiates a single# clearance parameter carried through the sparse A1 values.dA1=np.zeros((A1_val.size, 1)) # (A1_nnz, P)dA1[0, 0] =-1.0gradient_result=gradients.solve(
A0=A0,
A1_csr=(A1_rowptr, A1_col, A1_val),
A2_csr=(A2_rowptr, A2_col1, A2_col2, A2_val),
y0=np.array([10.0, 0.0]),
times=np.linspace(1.0, 24.0, 48),
derivatives=CoefficientDerivatives(
parameter_names=("clearance",),
dA1=dA1,
),
)
print(gradient_result.y.shape) # (1, 48, 2)print(gradient_result.dy_dtheta.shape) # (1, 48, 2, 1)

The augmented system holds the original neq states plus one neq-state sensitivity block per parameter, so memory and work grow linearly with the number of differentiated parameters P. Forward mode is intended for a modest number of parameters. These are derivatives of the continuous ODE solution; adaptive step-size and controller decisions are not differentiation targets.

For training, install the optional dependency (pip install "nvqsp[torch]") and use nvqsp.torch.solve. It accepts direct coefficient tensors and y0, returns an ordinary PyTorch tensor, and uses the same continuous sensitivities during backpropagation. SensitivityTargets restricts differentiation to selected coefficient slots to bound augmented-system size. Importing nvqsp never imports PyTorch, so inference-only deployments keep the minimal dependency set. The bridge supports first-order VJPs and rejects higher-order autograd.

Fixed dose schedules may be used during a gradient solve, but dose times and dose amounts are not differentiation targets in this release.

Dense TSIT5 Solver (with gradients)

For general (non-stiff and mildly stiff) systems, nvqsp.tsit5 runs an adaptive 5th-order TSIT5 integrator as a model-specialized CUDA library and exposes central-finite-difference gradients with respect to parameters (theta) or initial conditions (y0).

Unlike the sparse RODAS4 solver — which ships as one prebuilt library — dense TSIT5 is specialized per model: nvqsp.tsit5.build_model() generates and compiles CUDA for your model, so it requires a CUDA Toolkit (nvcc). Solving and differentiating an already-built library does not.

importnumpyasnpfromnvqspimporttsit5, GradientRequest, GradientTarget# 1) Build a model-specialized library once (requires nvcc).build=tsit5.build_model(model, "artifacts/", cuda_arch="sm_80")
# 2) Solve a batch of trajectories on the GPU.solve=tsit5.solve(
build.library_path,
y0=y0, # (neq,) or (batch, neq)theta=theta, # (P,) or (batch, P)times=np.linspace(0.0, 10.0, 64),
)
print(solve.y.shape) # (batch, n_times, neq)# 3) Gradients w.r.t. selected parameters.grad=tsit5.solve_with_gradients(
build.library_path,
y0=y0,
theta=theta,
times=np.linspace(0.0, 10.0, 64),
request=GradientRequest(target=GradientTarget.THETA, indices=None),
)
print(grad.gradients.shape) # (batch, time, state, n_selected)

nvqsp.tsit5.reference_solve_model_with_gradients() and validate_gradients() cross-check TSIT5 gradients against a tight SciPy CPU reference, and nvqsp.tsit5.solve_torch exposes the solver as a differentiable PyTorch operation. The gradient method is central finite differences; cost scales with the number of requested coordinates.

Model Form

The solver handles polynomial ODE systems of the form:

dy/dt = A0 + A1 * y + A2 * (y x y)
TermShapeMeaning
A0(neq,)Zeroth-order: constant synthesis, zero-order infusion
A1(neq, neq) sparse CSRFirst-order: linear elimination, transfer rates
A2(neq, neq, neq) sparse CSRSecond-order: bilinear / mass-action terms

Covers: all linear PBPK models, first-order absorption, IV bolus/infusion, bimolecular mass-action kinetics (drug-receptor binding, target-mediated disposition with second-order approximation).

Does not cover: Michaelis-Menten elimination, Hill-function PD, TMDD with quasi-steady-state, indirect response models, DAE systems.

Documentation

License

This software is licensed under the NVIDIA Software License Agreement and the Product-Specific Terms for AI Products. By downloading, installing, or using this software you agree to the terms of both licenses.

About

GPU-accelerated Quantitative Systems Pharmacology (QSP) ODE solvers.

Resources

Stars

18 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - NVIDIA-BioNeMo/nvQSP: GPU-accelerated Quantitative Systems Pharmacology (QSP) ODE solvers. · GitHub
Skip to content

Repository files navigation

nvQSP v0.2.0

GPU-accelerated stiff ODE solvers for Quantitative Systems Pharmacology (QSP) and PBPK population studies, with first-class gradient support. This release provides a sparse polynomial RODAS4 solver (prebuilt; no CUDA Toolkit needed at runtime) and a model-specialized dense adaptive TSIT5 solver, each with gradient exposure.

Distribution

ChannelInstall
PyPIpip install nvqsp
GitHub Releasenvqsp_0.2.0_amd64.deb (C/C++ headers + lib)
GitHub Releaselibsparse_rodas4.so (standalone shared library)

AI Agent Skill

This repository includes source for a skill that helps AI agents translate QSP/PBPK compartmental models into nvQSP's A0, A1, and A2 coefficient form.

The reviewable source for the skill lives in skills/nvqsp/. Maintainers should edit that source tree directly.

The skill does not change nvQSP runtime requirements; users still need the Python package or C/C++ library installed as described below.

All binaries are fat binaries with native code for:

  • sm_80 — Ampere (A100, A10)
  • sm_89 — Ada Lovelace (L4, L40, RTX 4090)
  • sm_90 — Hopper (H100, H200)
  • compute_90 PTX — forward compatibility for future architectures (Blackwell, etc.)

Requirements

  • Linux x86_64
  • NVIDIA GPU: Ampere (sm_80), Ada Lovelace (sm_89), or Hopper (sm_90)
  • NVIDIA driver 525+ (CUDA runtime 12.0+)
  • Python 3.8+ with NumPy (for the Python API)
  • PyTorch 2.0+ only when using the optional autograd bridge
  • CUDA Toolkit (nvcc) only when building a dense TSIT5 model library

The sparse RODAS4 solver needs no CUDA Toolkit at runtime — it ships as a prebuilt library. Only nvqsp.tsit5.build_model() (dense TSIT5 model specialization) and building from source require nvcc.

Quick Install

Python (from PyPI):

pip install nvqsp

C/C++ (Debian/Ubuntu):

Download nvqsp_0.2.0_amd64.deb from the GitHub release, then:

sudo dpkg -i nvqsp_0.2.0_amd64.deb

See INSTALL.md for full details.

Quick Start

importnumpyasnpfromscipy.sparseimportcsr_matrixfromnvqspimportsparsefromnvqsp.optionsimportSparseOptions# Two-compartment model: dy/dt = A0 + A1*y + A2*(y x y)neq=2A0=np.array([0.0, 0.0])
A1=csr_matrix([[-0.3, 0.1], [0.3, -0.1]])
A1_rowptr=A1.indptr.astype(np.int32)
A1_col=A1.indices.astype(np.int32)
A1_val=A1.data.astype(np.float64)
# A2 must have >= 1 entry; use epsilon for purely linear modelsA2_rowptr=np.array([0, 1, 1], dtype=np.int32)
A2_col1=np.array([0], dtype=np.int32)
A2_col2=np.array([0], dtype=np.int32)
A2_val=np.array([1e-30])
# 100 patients, 48 time points, dose of 100 mg at t=0result=sparse.solve(
A0=A0,
A1_csr=(A1_rowptr, A1_col, A1_val),
A2_csr=(A2_rowptr, A2_col1, A2_col2, A2_val),
y0=np.tile([10.0, 0.0], (100, 1)),
times=np.linspace(1.0, 24.0, 48),
doses=[(0.0, 100.0)],
opts=SparseOptions(rtol=1e-6, atol=1e-9),
)
print(result.y.shape) # (100, 48, 2)print(result.steps) # total ODE steps across all patients

See API_REFERENCE.md for the complete Python and C API.

Gradient Exposure

nvqsp.gradients computes continuous forward sensitivities of the same polynomial model in a single augmented GPU solve. Supply the derivatives of the direct coefficients and the initial state with respect to each user parameter:

importnumpyasnpfromnvqspimportCoefficientDerivatives, gradients# The parameter axis P is always last. This example differentiates a single# clearance parameter carried through the sparse A1 values.dA1=np.zeros((A1_val.size, 1)) # (A1_nnz, P)dA1[0, 0] =-1.0gradient_result=gradients.solve(
A0=A0,
A1_csr=(A1_rowptr, A1_col, A1_val),
A2_csr=(A2_rowptr, A2_col1, A2_col2, A2_val),
y0=np.array([10.0, 0.0]),
times=np.linspace(1.0, 24.0, 48),
derivatives=CoefficientDerivatives(
parameter_names=("clearance",),
dA1=dA1,
),
)
print(gradient_result.y.shape) # (1, 48, 2)print(gradient_result.dy_dtheta.shape) # (1, 48, 2, 1)

The augmented system holds the original neq states plus one neq-state sensitivity block per parameter, so memory and work grow linearly with the number of differentiated parameters P. Forward mode is intended for a modest number of parameters. These are derivatives of the continuous ODE solution; adaptive step-size and controller decisions are not differentiation targets.

For training, install the optional dependency (pip install "nvqsp[torch]") and use nvqsp.torch.solve. It accepts direct coefficient tensors and y0, returns an ordinary PyTorch tensor, and uses the same continuous sensitivities during backpropagation. SensitivityTargets restricts differentiation to selected coefficient slots to bound augmented-system size. Importing nvqsp never imports PyTorch, so inference-only deployments keep the minimal dependency set. The bridge supports first-order VJPs and rejects higher-order autograd.

Fixed dose schedules may be used during a gradient solve, but dose times and dose amounts are not differentiation targets in this release.

Dense TSIT5 Solver (with gradients)

For general (non-stiff and mildly stiff) systems, nvqsp.tsit5 runs an adaptive 5th-order TSIT5 integrator as a model-specialized CUDA library and exposes central-finite-difference gradients with respect to parameters (theta) or initial conditions (y0).

Unlike the sparse RODAS4 solver — which ships as one prebuilt library — dense TSIT5 is specialized per model: nvqsp.tsit5.build_model() generates and compiles CUDA for your model, so it requires a CUDA Toolkit (nvcc). Solving and differentiating an already-built library does not.

importnumpyasnpfromnvqspimporttsit5, GradientRequest, GradientTarget# 1) Build a model-specialized library once (requires nvcc).build=tsit5.build_model(model, "artifacts/", cuda_arch="sm_80")
# 2) Solve a batch of trajectories on the GPU.solve=tsit5.solve(
build.library_path,
y0=y0, # (neq,) or (batch, neq)theta=theta, # (P,) or (batch, P)times=np.linspace(0.0, 10.0, 64),
)
print(solve.y.shape) # (batch, n_times, neq)# 3) Gradients w.r.t. selected parameters.grad=tsit5.solve_with_gradients(
build.library_path,
y0=y0,
theta=theta,
times=np.linspace(0.0, 10.0, 64),
request=GradientRequest(target=GradientTarget.THETA, indices=None),
)
print(grad.gradients.shape) # (batch, time, state, n_selected)

nvqsp.tsit5.reference_solve_model_with_gradients() and validate_gradients() cross-check TSIT5 gradients against a tight SciPy CPU reference, and nvqsp.tsit5.solve_torch exposes the solver as a differentiable PyTorch operation. The gradient method is central finite differences; cost scales with the number of requested coordinates.

Model Form

The solver handles polynomial ODE systems of the form:

dy/dt = A0 + A1 * y + A2 * (y x y)
TermShapeMeaning
A0(neq,)Zeroth-order: constant synthesis, zero-order infusion
A1(neq, neq) sparse CSRFirst-order: linear elimination, transfer rates
A2(neq, neq, neq) sparse CSRSecond-order: bilinear / mass-action terms

Covers: all linear PBPK models, first-order absorption, IV bolus/infusion, bimolecular mass-action kinetics (drug-receptor binding, target-mediated disposition with second-order approximation).

Does not cover: Michaelis-Menten elimination, Hill-function PD, TMDD with quasi-steady-state, indirect response models, DAE systems.

Documentation

License

This software is licensed under the NVIDIA Software License Agreement and the Product-Specific Terms for AI Products. By downloading, installing, or using this software you agree to the terms of both licenses.

About

GPU-accelerated Quantitative Systems Pharmacology (QSP) ODE solvers.

Resources

Stars

18 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - NVIDIA-BioNeMo/nvQSP: GPU-accelerated Quantitative Systems Pharmacology (QSP) ODE solvers. · GitHub
Skip to content

Repository files navigation

nvQSP v0.2.0

GPU-accelerated stiff ODE solvers for Quantitative Systems Pharmacology (QSP) and PBPK population studies, with first-class gradient support. This release provides a sparse polynomial RODAS4 solver (prebuilt; no CUDA Toolkit needed at runtime) and a model-specialized dense adaptive TSIT5 solver, each with gradient exposure.

Distribution

ChannelInstall
PyPIpip install nvqsp
GitHub Releasenvqsp_0.2.0_amd64.deb (C/C++ headers + lib)
GitHub Releaselibsparse_rodas4.so (standalone shared library)

AI Agent Skill

This repository includes source for a skill that helps AI agents translate QSP/PBPK compartmental models into nvQSP's A0, A1, and A2 coefficient form.

The reviewable source for the skill lives in skills/nvqsp/. Maintainers should edit that source tree directly.

The skill does not change nvQSP runtime requirements; users still need the Python package or C/C++ library installed as described below.

All binaries are fat binaries with native code for:

  • sm_80 — Ampere (A100, A10)
  • sm_89 — Ada Lovelace (L4, L40, RTX 4090)
  • sm_90 — Hopper (H100, H200)
  • compute_90 PTX — forward compatibility for future architectures (Blackwell, etc.)

Requirements

  • Linux x86_64
  • NVIDIA GPU: Ampere (sm_80), Ada Lovelace (sm_89), or Hopper (sm_90)
  • NVIDIA driver 525+ (CUDA runtime 12.0+)
  • Python 3.8+ with NumPy (for the Python API)
  • PyTorch 2.0+ only when using the optional autograd bridge
  • CUDA Toolkit (nvcc) only when building a dense TSIT5 model library

The sparse RODAS4 solver needs no CUDA Toolkit at runtime — it ships as a prebuilt library. Only nvqsp.tsit5.build_model() (dense TSIT5 model specialization) and building from source require nvcc.

Quick Install

Python (from PyPI):

pip install nvqsp

C/C++ (Debian/Ubuntu):

Download nvqsp_0.2.0_amd64.deb from the GitHub release, then:

sudo dpkg -i nvqsp_0.2.0_amd64.deb

See INSTALL.md for full details.

Quick Start

importnumpyasnpfromscipy.sparseimportcsr_matrixfromnvqspimportsparsefromnvqsp.optionsimportSparseOptions# Two-compartment model: dy/dt = A0 + A1*y + A2*(y x y)neq=2A0=np.array([0.0, 0.0])
A1=csr_matrix([[-0.3, 0.1], [0.3, -0.1]])
A1_rowptr=A1.indptr.astype(np.int32)
A1_col=A1.indices.astype(np.int32)
A1_val=A1.data.astype(np.float64)
# A2 must have >= 1 entry; use epsilon for purely linear modelsA2_rowptr=np.array([0, 1, 1], dtype=np.int32)
A2_col1=np.array([0], dtype=np.int32)
A2_col2=np.array([0], dtype=np.int32)
A2_val=np.array([1e-30])
# 100 patients, 48 time points, dose of 100 mg at t=0result=sparse.solve(
A0=A0,
A1_csr=(A1_rowptr, A1_col, A1_val),
A2_csr=(A2_rowptr, A2_col1, A2_col2, A2_val),
y0=np.tile([10.0, 0.0], (100, 1)),
times=np.linspace(1.0, 24.0, 48),
doses=[(0.0, 100.0)],
opts=SparseOptions(rtol=1e-6, atol=1e-9),
)
print(result.y.shape) # (100, 48, 2)print(result.steps) # total ODE steps across all patients

See API_REFERENCE.md for the complete Python and C API.

Gradient Exposure

nvqsp.gradients computes continuous forward sensitivities of the same polynomial model in a single augmented GPU solve. Supply the derivatives of the direct coefficients and the initial state with respect to each user parameter:

importnumpyasnpfromnvqspimportCoefficientDerivatives, gradients# The parameter axis P is always last. This example differentiates a single# clearance parameter carried through the sparse A1 values.dA1=np.zeros((A1_val.size, 1)) # (A1_nnz, P)dA1[0, 0] =-1.0gradient_result=gradients.solve(
A0=A0,
A1_csr=(A1_rowptr, A1_col, A1_val),
A2_csr=(A2_rowptr, A2_col1, A2_col2, A2_val),
y0=np.array([10.0, 0.0]),
times=np.linspace(1.0, 24.0, 48),
derivatives=CoefficientDerivatives(
parameter_names=("clearance",),
dA1=dA1,
),
)
print(gradient_result.y.shape) # (1, 48, 2)print(gradient_result.dy_dtheta.shape) # (1, 48, 2, 1)

The augmented system holds the original neq states plus one neq-state sensitivity block per parameter, so memory and work grow linearly with the number of differentiated parameters P. Forward mode is intended for a modest number of parameters. These are derivatives of the continuous ODE solution; adaptive step-size and controller decisions are not differentiation targets.

For training, install the optional dependency (pip install "nvqsp[torch]") and use nvqsp.torch.solve. It accepts direct coefficient tensors and y0, returns an ordinary PyTorch tensor, and uses the same continuous sensitivities during backpropagation. SensitivityTargets restricts differentiation to selected coefficient slots to bound augmented-system size. Importing nvqsp never imports PyTorch, so inference-only deployments keep the minimal dependency set. The bridge supports first-order VJPs and rejects higher-order autograd.

Fixed dose schedules may be used during a gradient solve, but dose times and dose amounts are not differentiation targets in this release.

Dense TSIT5 Solver (with gradients)

For general (non-stiff and mildly stiff) systems, nvqsp.tsit5 runs an adaptive 5th-order TSIT5 integrator as a model-specialized CUDA library and exposes central-finite-difference gradients with respect to parameters (theta) or initial conditions (y0).

Unlike the sparse RODAS4 solver — which ships as one prebuilt library — dense TSIT5 is specialized per model: nvqsp.tsit5.build_model() generates and compiles CUDA for your model, so it requires a CUDA Toolkit (nvcc). Solving and differentiating an already-built library does not.

importnumpyasnpfromnvqspimporttsit5, GradientRequest, GradientTarget# 1) Build a model-specialized library once (requires nvcc).build=tsit5.build_model(model, "artifacts/", cuda_arch="sm_80")
# 2) Solve a batch of trajectories on the GPU.solve=tsit5.solve(
build.library_path,
y0=y0, # (neq,) or (batch, neq)theta=theta, # (P,) or (batch, P)times=np.linspace(0.0, 10.0, 64),
)
print(solve.y.shape) # (batch, n_times, neq)# 3) Gradients w.r.t. selected parameters.grad=tsit5.solve_with_gradients(
build.library_path,
y0=y0,
theta=theta,
times=np.linspace(0.0, 10.0, 64),
request=GradientRequest(target=GradientTarget.THETA, indices=None),
)
print(grad.gradients.shape) # (batch, time, state, n_selected)

nvqsp.tsit5.reference_solve_model_with_gradients() and validate_gradients() cross-check TSIT5 gradients against a tight SciPy CPU reference, and nvqsp.tsit5.solve_torch exposes the solver as a differentiable PyTorch operation. The gradient method is central finite differences; cost scales with the number of requested coordinates.

Model Form

The solver handles polynomial ODE systems of the form:

dy/dt = A0 + A1 * y + A2 * (y x y)
TermShapeMeaning
A0(neq,)Zeroth-order: constant synthesis, zero-order infusion
A1(neq, neq) sparse CSRFirst-order: linear elimination, transfer rates
A2(neq, neq, neq) sparse CSRSecond-order: bilinear / mass-action terms

Covers: all linear PBPK models, first-order absorption, IV bolus/infusion, bimolecular mass-action kinetics (drug-receptor binding, target-mediated disposition with second-order approximation).

Does not cover: Michaelis-Menten elimination, Hill-function PD, TMDD with quasi-steady-state, indirect response models, DAE systems.

Documentation

License

This software is licensed under the NVIDIA Software License Agreement and the Product-Specific Terms for AI Products. By downloading, installing, or using this software you agree to the terms of both licenses.

About

GPU-accelerated Quantitative Systems Pharmacology (QSP) ODE solvers.

Resources

Stars

18 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); GitHub - NVIDIA-BioNeMo/nvQSP: GPU-accelerated Quantitative Systems Pharmacology (QSP) ODE solvers. · GitHub
Skip to content

Repository files navigation

nvQSP v0.2.0

GPU-accelerated stiff ODE solvers for Quantitative Systems Pharmacology (QSP) and PBPK population studies, with first-class gradient support. This release provides a sparse polynomial RODAS4 solver (prebuilt; no CUDA Toolkit needed at runtime) and a model-specialized dense adaptive TSIT5 solver, each with gradient exposure.

Distribution

ChannelInstall
PyPIpip install nvqsp
GitHub Releasenvqsp_0.2.0_amd64.deb (C/C++ headers + lib)
GitHub Releaselibsparse_rodas4.so (standalone shared library)

AI Agent Skill

This repository includes source for a skill that helps AI agents translate QSP/PBPK compartmental models into nvQSP's A0, A1, and A2 coefficient form.

The reviewable source for the skill lives in skills/nvqsp/. Maintainers should edit that source tree directly.

The skill does not change nvQSP runtime requirements; users still need the Python package or C/C++ library installed as described below.

All binaries are fat binaries with native code for:

  • sm_80 — Ampere (A100, A10)
  • sm_89 — Ada Lovelace (L4, L40, RTX 4090)
  • sm_90 — Hopper (H100, H200)
  • compute_90 PTX — forward compatibility for future architectures (Blackwell, etc.)

Requirements

  • Linux x86_64
  • NVIDIA GPU: Ampere (sm_80), Ada Lovelace (sm_89), or Hopper (sm_90)
  • NVIDIA driver 525+ (CUDA runtime 12.0+)
  • Python 3.8+ with NumPy (for the Python API)
  • PyTorch 2.0+ only when using the optional autograd bridge
  • CUDA Toolkit (nvcc) only when building a dense TSIT5 model library

The sparse RODAS4 solver needs no CUDA Toolkit at runtime — it ships as a prebuilt library. Only nvqsp.tsit5.build_model() (dense TSIT5 model specialization) and building from source require nvcc.

Quick Install

Python (from PyPI):

pip install nvqsp

C/C++ (Debian/Ubuntu):

Download nvqsp_0.2.0_amd64.deb from the GitHub release, then:

sudo dpkg -i nvqsp_0.2.0_amd64.deb

See INSTALL.md for full details.

Quick Start

importnumpyasnpfromscipy.sparseimportcsr_matrixfromnvqspimportsparsefromnvqsp.optionsimportSparseOptions# Two-compartment model: dy/dt = A0 + A1*y + A2*(y x y)neq=2A0=np.array([0.0, 0.0])
A1=csr_matrix([[-0.3, 0.1], [0.3, -0.1]])
A1_rowptr=A1.indptr.astype(np.int32)
A1_col=A1.indices.astype(np.int32)
A1_val=A1.data.astype(np.float64)
# A2 must have >= 1 entry; use epsilon for purely linear modelsA2_rowptr=np.array([0, 1, 1], dtype=np.int32)
A2_col1=np.array([0], dtype=np.int32)
A2_col2=np.array([0], dtype=np.int32)
A2_val=np.array([1e-30])
# 100 patients, 48 time points, dose of 100 mg at t=0result=sparse.solve(
A0=A0,
A1_csr=(A1_rowptr, A1_col, A1_val),
A2_csr=(A2_rowptr, A2_col1, A2_col2, A2_val),
y0=np.tile([10.0, 0.0], (100, 1)),
times=np.linspace(1.0, 24.0, 48),
doses=[(0.0, 100.0)],
opts=SparseOptions(rtol=1e-6, atol=1e-9),
)
print(result.y.shape) # (100, 48, 2)print(result.steps) # total ODE steps across all patients

See API_REFERENCE.md for the complete Python and C API.

Gradient Exposure

nvqsp.gradients computes continuous forward sensitivities of the same polynomial model in a single augmented GPU solve. Supply the derivatives of the direct coefficients and the initial state with respect to each user parameter:

importnumpyasnpfromnvqspimportCoefficientDerivatives, gradients# The parameter axis P is always last. This example differentiates a single# clearance parameter carried through the sparse A1 values.dA1=np.zeros((A1_val.size, 1)) # (A1_nnz, P)dA1[0, 0] =-1.0gradient_result=gradients.solve(
A0=A0,
A1_csr=(A1_rowptr, A1_col, A1_val),
A2_csr=(A2_rowptr, A2_col1, A2_col2, A2_val),
y0=np.array([10.0, 0.0]),
times=np.linspace(1.0, 24.0, 48),
derivatives=CoefficientDerivatives(
parameter_names=("clearance",),
dA1=dA1,
),
)
print(gradient_result.y.shape) # (1, 48, 2)print(gradient_result.dy_dtheta.shape) # (1, 48, 2, 1)

The augmented system holds the original neq states plus one neq-state sensitivity block per parameter, so memory and work grow linearly with the number of differentiated parameters P. Forward mode is intended for a modest number of parameters. These are derivatives of the continuous ODE solution; adaptive step-size and controller decisions are not differentiation targets.

For training, install the optional dependency (pip install "nvqsp[torch]") and use nvqsp.torch.solve. It accepts direct coefficient tensors and y0, returns an ordinary PyTorch tensor, and uses the same continuous sensitivities during backpropagation. SensitivityTargets restricts differentiation to selected coefficient slots to bound augmented-system size. Importing nvqsp never imports PyTorch, so inference-only deployments keep the minimal dependency set. The bridge supports first-order VJPs and rejects higher-order autograd.

Fixed dose schedules may be used during a gradient solve, but dose times and dose amounts are not differentiation targets in this release.

Dense TSIT5 Solver (with gradients)

For general (non-stiff and mildly stiff) systems, nvqsp.tsit5 runs an adaptive 5th-order TSIT5 integrator as a model-specialized CUDA library and exposes central-finite-difference gradients with respect to parameters (theta) or initial conditions (y0).

Unlike the sparse RODAS4 solver — which ships as one prebuilt library — dense TSIT5 is specialized per model: nvqsp.tsit5.build_model() generates and compiles CUDA for your model, so it requires a CUDA Toolkit (nvcc). Solving and differentiating an already-built library does not.

importnumpyasnpfromnvqspimporttsit5, GradientRequest, GradientTarget# 1) Build a model-specialized library once (requires nvcc).build=tsit5.build_model(model, "artifacts/", cuda_arch="sm_80")
# 2) Solve a batch of trajectories on the GPU.solve=tsit5.solve(
build.library_path,
y0=y0, # (neq,) or (batch, neq)theta=theta, # (P,) or (batch, P)times=np.linspace(0.0, 10.0, 64),
)
print(solve.y.shape) # (batch, n_times, neq)# 3) Gradients w.r.t. selected parameters.grad=tsit5.solve_with_gradients(
build.library_path,
y0=y0,
theta=theta,
times=np.linspace(0.0, 10.0, 64),
request=GradientRequest(target=GradientTarget.THETA, indices=None),
)
print(grad.gradients.shape) # (batch, time, state, n_selected)

nvqsp.tsit5.reference_solve_model_with_gradients() and validate_gradients() cross-check TSIT5 gradients against a tight SciPy CPU reference, and nvqsp.tsit5.solve_torch exposes the solver as a differentiable PyTorch operation. The gradient method is central finite differences; cost scales with the number of requested coordinates.

Model Form

The solver handles polynomial ODE systems of the form:

dy/dt = A0 + A1 * y + A2 * (y x y)
TermShapeMeaning
A0(neq,)Zeroth-order: constant synthesis, zero-order infusion
A1(neq, neq) sparse CSRFirst-order: linear elimination, transfer rates
A2(neq, neq, neq) sparse CSRSecond-order: bilinear / mass-action terms

Covers: all linear PBPK models, first-order absorption, IV bolus/infusion, bimolecular mass-action kinetics (drug-receptor binding, target-mediated disposition with second-order approximation).

Does not cover: Michaelis-Menten elimination, Hill-function PD, TMDD with quasi-steady-state, indirect response models, DAE systems.

Documentation

License

This software is licensed under the NVIDIA Software License Agreement and the Product-Specific Terms for AI Products. By downloading, installing, or using this software you agree to the terms of both licenses.

About

GPU-accelerated Quantitative Systems Pharmacology (QSP) ODE solvers.

Resources

Stars

18 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages