Error that should never happen

32 views
Skip to first unread message

Tamara Tromp

unread,
Nov 13, 2025, 8:04:11 AMNov 13
to mcx-users
Dear Dr. Fang,

We are working with the svmc package, but find that we often have an error that should never happen. This is occuring on our Nividia GeForce RTX 2080 SUPER graphics card on a PC that doesn't show this error when running in regular square voxels.

Progress: [========================================>                     ]  65%ERROR: should never happen! mediaid=0 idx1d=7FFFFFFF isreflect=1 gcfg->doreflect=1 n1=1.390000 n2=1.390000 isdet=0 flipdir[3]=2 p=(122.600266 125.151924 118.794746)[122 125 118]

Do you know what might cause this and if it's anything to worry about or fix?  

we see its coming from line 2465 in mcx_core.cu:
if (mediaid == 0 || idx1d == OUTSIDE_VOLUME_MIN || idx1d == OUTSIDE_VOLUME_MAX)

but don't have intuition on what the error means and how it's more in some of our SVMC volumes than others. Any advice here is helpful.

We can provide a script that can generate this if needed, but that may require a large data transfer with the volume in question.  

Best,
Tamara

Qianqian Fang

unread,
Nov 13, 2025, 9:31:44 AMNov 13
to mcx-...@googlegroups.com, Tamara Tromp

hi Tamara,

can you confirm you are using the latest mcx/mcxlab release (v2025.10)?

was the svmc volume generated by mcxsvmc.m?

if you can briefly describe the domain settings (size, medium types, and object shapes), I may be able to understand what might go wrong to trigger this error. but to be able to fix it, I would like a small reproducer - if you cut down the volume and this bug disappeared, you may have to share the full volume, or the script that I can regenerate. in this case, please use a shared drive/url to share, you can email me directly.

Qianqian

Tamara --
You received this message because you are subscribed to the Google Groups "mcx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mcx-users+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/mcx-users/5cce3e14-3bb0-4d9f-b0e6-ea8938ff67ecn%40googlegroups.com.

Qianqian Fang

unread,
Nov 14, 2025, 3:14:56 PMNov 14
to mcx-...@googlegroups.com, Tamara Tromp

hi Tamara,

I received your exported cfg, and ran it on 3 of my GPUs (2080Super, Titan, 5090, Titan V) on two different machines, all of them completed without showing this error.

can you try on a different PC? or a Linux machine?


a=loadjson('Error_should_never_happen_mcfg.json');
a.vol=uint8(a.vol);
flux=mcxlab(a);


Launching MCXLAB - Monte Carlo eXtreme for MATLAB & GNU Octave ...
Running simulations for configuration #1 ...
mcx.dim=[100 25 200];
mcx.mediabyte=97;
WARNING: redundant field 'dim'
mcx.medianum=3;
mcx.issrcfrom0=1;
mcx.unitinmm=0.002;
WARNING: redundant field 'mediabyte'
mcx.tstart=0;
mcx.tend=5e-09;
mcx.tstep=5e-09;
mcx.srctype='planar';
mcx.srcpos=[0 0 0 1];
mcx.srcdir=[0 0 1 0];
mcx.srcparam1=[400 0 0 0];
mcx.srcparam2=[0 400 0 0];
mcx.nphoton=1e+08;
mcx.respin=1;
mcx.isreflect=1;
mcx.bc='cc_cc_001000';
WARNING: redundant field 'isnormalize'
mcx.seed=42;
mcx.maxdetphoton=1e+08;
mcx.autopilot=1;
mcx.outputtype='energy';
mcx.savedetflag=52;
mcx.debuglevel=4;
mcx.issavedet=1;
mcx.issaveseed=1;
WARNING: redundant field 'verb'
mcx.gpuid=2;
###############################################################################
#                      Monte Carlo eXtreme (MCX) -- CUDA                      #
#          Copyright (c) 2009-2025 Qianqian Fang <q.fang at neu.edu>          #
#                https://mcx.space/  &  https://neurojson.io                  #
#                                                                             #
# Computational Optics & Translational Imaging (COTI) Lab- http://fanglab.org #
#   Department of Bioengineering, Northeastern University, Boston, MA, USA    #
###############################################################################
#    The MCX Project is funded by the NIH/NIGMS under grant R01-GM114365      #
###############################################################################
#  Open-source codes and reusable scientific data are essential for research, #
# MCX proudly developed human-readable JSON-based data formats for easy reuse.#
#                                                                             #
#Please visit our free scientific data sharing portal at https://neurojson.io #
# and consider sharing your public datasets in standardized JSON/JData format #
###############################################################################
$Rev::76f8b4$v2025.9 $Date::2025-09-28 17:14:21 -04$ by $Author::Qianqian Fang$
###############################################################################
- code name: [Kilo-Kelvin] compiled by nvcc [11.3] for CUDA-arch [350] on [Sep 30 2025]
- compiled with: RNG [xorshift128+] seed length [4]

GPU=2 (NVIDIA GeForce RTX 2080 SUPER) threadph=1017 extra=24832 np=100000000 nthread=98304 maxgate=1 repetition=1
initializing streams ...    init complete : 1 ms
requesting shared memory: 1280 bytes
launching MCX simulation for time window [0.00e+00ns 5.00e+00ns] ...
simulation run# 1 ...

kernel complete:      63690 ms
retrieving fields ...     transfer complete:    63691 ms
normalizing raw data ...    source 1, normalization factor alpha=0.000000
data normalization complete : 63698 ms
simulated 100000000 photons (100000000) with 98304 threads (repeat x1)
MCX simulation speed: 1570.67 photon/ms
total simulated energy: 99987796.00    absorbed: 33.10317%
(loss due to initial specular reflection is excluded in the total)

--------------------------------

GPU=1 (NVIDIA GeForce RTX 5090) threadph=143 extra=426240 np=100000000 nthread=696320 maxgate=1 repetition=1
initializing streams ...    init complete : 1 ms
requesting shared memory: 1280 bytes
launching MCX simulation for time window [0.00e+00ns 5.00e+00ns] ...
simulation run# 1 ...

kernel complete:      10792 ms
retrieving fields ...     transfer complete:    10797 ms
normalizing raw data ...    source 1, normalization factor alpha=0.000000
data normalization complete : 10816 ms
simulated 100000000 photons (100000000) with 696320 threads (repeat x1)
MCX simulation speed: 9359.79 photon/ms
total simulated energy: 99998474.00    absorbed: 33.09943%
(loss due to initial specular reflection is excluded in the total)

--------------------------------

GPU=1 (NVIDIA TITAN V) threadph=610 extra=57600 np=100000000 nthread=163840 maxgate=1 repetition=1
initializing streams ...    init complete : 1 ms
requesting shared memory: 1280 bytes
launching MCX simulation for time window [0.00e+00ns 5.00e+00ns] ...
simulation run# 1 ...

kernel complete:      64545 ms
retrieving fields ...     transfer complete:    64546 ms
normalizing raw data ...    source 1, normalization factor alpha=0.000000
data normalization complete : 64550 ms
simulated 100000000 photons (100000000) with 163840 threads (repeat x1)
MCX simulation speed: 1549.83 photon/ms
total simulated energy: 99994736.00    absorbed: 33.09635%
(loss due to initial specular reflection is excluded in the total)

Tamara Tromp

unread,
Nov 18, 2025, 12:04:35 PMNov 18
to mcx-users
Dear dr. Fang,
We ran the cfg I sent you on three different pcs (2 Windows, one Linux). The error occurred on all three pcs (although there were less errors on the Linux machine).
 
Pc 1 (Windows):
GPU information:
=============================   GPU Information  ========================
Device 1 of 1:          NVIDIA GeForce RTX 2080 SUPER
Compute Capability:     7.5
Global Memory:          8589606912 B
Constant Memory:        65536 B
Shared Memory:          49152 B
Registers:              65536
Clock Speed:            1.81 GHz
Number of SMs:          48
Number of Cores:        3072
Auto-thread:            98304
Auto-block:             64
[{'name': 'NVIDIA GeForce RTX 2080 SUPER', 'id': 1, 'devcount': 1, 'major': 7, 'minor': 5, 'globalmem': 8589606912, 'constmem': 65536, 'sharedmem': 49152, 'regcount': 65536, 'clock': 1815000, 'sm': 48, 'core': 3072, 'autoblock': 64, 'autothread': 98304, 'maxgate': 0}]

Output:
nphoton: 1e+08
tstart: 0
tstep: 5e-09
tend: 5e-09
maxdetphoton: 1e+08
respin: 1
isreflect: 1
issrcfrom0: 1
autopilot: 1
unitinmm: 0.002
issavedet: 1
issaveseed: 1

###############################################################################
#                      Monte Carlo eXtreme (MCX) -- CUDA                      #
#          Copyright (c) 2009-2025 Qianqian Fang <q.fang at neu.edu>          #
#                https://mcx.space/  &  https://neurojson.io                  #
#                                                                             #
# Computational Optics & Translational Imaging (COTI) Lab- http://fanglab.org #
#   Department of Bioengineering, Northeastern University, Boston, MA, USA    #
###############################################################################
#    The MCX Project is funded by the NIH/NIGMS under grant R01-GM114365      #
###############################################################################
#  Open-source codes and reusable scientific data are essential for research, #
# MCX proudly developed human-readable JSON-based data formats for easy reuse.#
#                                                                             #
#Please visit our free scientific data sharing portal at https://neurojson.io #
###############################################################################
- code name: [Fermi MCX] compiled by nvcc [10.2] for CUDA-arch [350] on [Oct 11 2025]

- compiled with: RNG [xorshift128+] seed length [4]

GPU=1 (NVIDIA GeForce RTX 2080 SUPER) threadph=1017 extra=24832 np=100000000 nthread=98304 maxgate=1 repetition=1

initializing streams ...        init complete : 1 ms
requesting shared memory: 2816 bytes

launching MCX simulation for time window [0.00e+00ns 5.00e+00ns] ...
simulation run# 1 ...
Progress: [=====>                                                        ]   8%ERROR: should never happen! mediaid=0 idx1d=7FFFFFFF isreflect=1 gcfg->doreflect=1 n1=1.500000 n2=1.500000 isdet=0 flipdir[3]=2 p=(62.412613 25.138458 147.541748)[62 25 147]    
Progress: [===========>                                                  ]  18%ERROR: should never happen! mediaid=0 idx1d=7FFFFFFF isreflect=1 gcfg->doreflect=1 n1=1.500000 n2=1.500000 isdet=0 flipdir[3]=2 p=(25.650911 25.021519 132.628326)[25 25 132]    
Progress: [======================================================>       ]  88%ERROR: should never happen! mediaid=0 idx1d=7FFFFFFF isreflect=1 gcfg->doreflect=1 n1=1.500000 n2=1.500000 isdet=0 flipdir[3]=2 p=(52.451462 25.017277 150.500107)[52 25 150]    
Progress: [==============================================================] 100%
kernel complete:        16561 ms
retrieving fields ...   detected 2679403 photons, total: 2679403        transfer complete:      18258 ms

normalizing raw data ...        source 1, normalization factor alpha=0.000000
data normalization complete : 18266 ms

simulated 100000000 photons (100000000) with 98304 threads (repeat x1)
MCX simulation speed: 6051.07 photon/ms
total simulated energy: 99991845.00     absorbed: 34.82850%

(loss due to initial specular reflection is excluded in the total)

Pc 2 (Windows):
GPU information:
pc2_gpu_info.png
Output:
pc2_error_ext.png 

Pc 3 (Linux): 
GPU information:
=============================   GPU Information  =========================
Device 1 of 2:          NVIDIA GeForce GTX 1080
Compute Capability:     6.1
Global Memory:          8513978368 B
Constant Memory:        65536 B
Shared Memory:          49152 B
Registers:              65536
Clock Speed:            1.76 GHz
Number of SMs:          20
Number of Cores:        2560
Auto-thread:            40960
Auto-block:             64
{'name': 'NVIDIA GeForce GTX 1080', 'id': 1, 'devcount': 2, 'major': 6, 'minor': 1, 'globalmem': 8513978368, 'constmem': 65536, 'sharedmem': 49152, 'regcount': 65536, 'clock': 1759000, 'sm': 20, 'core': 2560, 'autoblock': 64, 'autothread': 40960, 'maxgate': 0}

Output:
nphoton: 1e+08
tstart: 0
tstep: 5e-09
tend: 5e-09
maxdetphoton: 1e+08
respin: 1
isreflect: 1
issrcfrom0: 1
autopilot: 1
unitinmm: 0.002
issavedet: 1
issaveseed: 1

###############################################################################
#                      Monte Carlo eXtreme (MCX) -- CUDA                      #
#          Copyright (c) 2009-2024 Qianqian Fang <q.fang at neu.edu>          #
#                https://mcx.space/  &  https://neurojson.io/                 #

#                                                                             #
# Computational Optics & Translational Imaging (COTI) Lab- http://fanglab.org #
#   Department of Bioengineering, Northeastern University, Boston, MA, USA    #
###############################################################################
#    The MCX Project is funded by the NIH/NIGMS under grant R01-GM114365      #
###############################################################################
#  Open-source codes and reusable scientific data are essential for research, #
# MCX proudly developed human-readable JSON-based data formats for easy reuse.#
#                                                                             #
#Please visit our free scientific data sharing portal at https://neurojson.io/#

# and consider sharing your public datasets in standardized JSON/JData format #
###############################################################################
$Rev::eae5b2$v2024.2 $Date::2024-03-15 00:07:15 -04$ by $Author::Qianqian Fang$
###############################################################################
- code name: [Fermi MCX] compiled by nvcc [9.2] for CUDA-arch [350] on [Mar 15 2024]
- compiled with: RNG [xorshift128+] with Seed Length [4]

GPU=1 (NVIDIA GeForce GTX 1080) threadph=2441 extra=16640 np=100000000 nthread=40960 maxgate=1 repetition=1
initializing streams ...        init complete : 0 ms
requesting 2816 bytes of shared memory

launching MCX simulation for time window [0.00e+00ns 5.00e+00ns] ...
simulation run# 1 ...
Progress: [=================>                                            ]  28%ERROR: should never happen! mediaid=0 idx1d=7FFFFFFF isreflect=1 gcfg->doreflect=1 n1=1.500000 n2=1.500000 isdet=0 flipdir[3]=2 p=(68.641335 25.788504 142.855103)[68 25 142]
Progress: [======================================================>       ]  88%ERROR: should never happen! mediaid=0 idx1d=7FFFFFFF isreflect=1 gcfg->doreflect=1 n1=1.500000 n2=1.500000 isdet=0 flipdir[3]=2 p=(25.498375 25.297171 121.784027)[25 25 121]
Progress: [==============================================================] 100%
kernel complete:        43041 ms
retrieving fields ...   detected 2681315 photons, total: 2681315        transfer complete:      45901 ms

normalizing raw data ...        source 1, normalization factor alpha=0.000000
data normalization complete : 45907 ms
simulated 100000000 photons (100000000) with 40960 threads (repeat x1)
MCX simulation speed: 2324.99 photon/ms
total simulated energy: 99973279.00     absorbed: 34.82863%

(loss due to initial specular reflection is excluded in the total)


I hope this helps, please let me know if any further information is needed. 

Best,
Tamara

Qianqian Fang

unread,
Nov 20, 2025, 11:46:45 PM (12 days ago) Nov 20
to mcx-...@googlegroups.com, Tamara Tromp

hi Tamara,

thanks for the follow up. I was indeed able to see the message on my 2080S - I previously missed it because it was printed in the terminal.

I am still in the process of debugging it. It appears to be related to the logic of handling of boundary conditions in the svmc mode.

it happens very rarely, should have negligible impact to the results.

Qianqian

Reply all
Reply to author
Forward
0 new messages