deepmodeling / deepmodeling/dftio
[Code scan] Make mhcustom honor burn-in state and nsamples
- Dominant language
- Jupyter Notebook
- Stars
- 16
- Forks
- 14
- PR merge metrics
- No merged PRs in 30d
Description
This issue comes from a Codex global repository scan.
## Problem
The vendored MCMC custom sampler computes a post-burn-in state, then discards it and collects the wrong number of samples:
https://github.com/deepmodeling/dftio/blob/c9d128f24a74ef2911e1a28f5640357488beb196/dftio/dep/_xitorch/_impls/integrate/mcsamples/mcmc.py#L76-L77
It calls `_mhcustom_sample(..., x0, ..., nburnout, ..., True)` instead of starting from `x` and collecting `nsamples`. Whenever `nsamples != nburnout`, the returned chain has the wrong length and starts from the unburned initial state.
## Reproduction
Use `custom_step=lambda x: x + 1`, `x0=0`, `nsamples=3`, and `nburnout=2`; the current output has length 2 and starts at `[0, 1]`.
## Suggested fix
Collect from the burned-in state and use `nsamples`:
```python
xsamples = _mhcustom_sample(logpfcn, x, pparams, nsamples, custom_step, True)
```
Contributor guide
Research direction
Open dftio/dep/_xitorch/_impls/integrate/mcsamples/mcmc.py around lines 76-77 and trace the burn-in and sampling calls. Reproduce the issue with custom_step=lambda x: x + 1, x0=0, nsamples=3, and nburnout=2. Done means the returned chain has nsamples entries and begins from the burned-in state.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100