diff --git a/dimod/binary_quadratic_model.py b/dimod/binary_quadratic_model.py
index be17433b..1288c6ef 100644
--- a/dimod/binary_quadratic_model.py
+++ b/dimod/binary_quadratic_model.py
@@ -53,7 +53,7 @@ try:
 except ImportError:
     import collections as abc
 
-from numbers import Number
+from numbers import Integral, Number
 
 import numpy as np
 
@@ -65,6 +65,7 @@ from dimod.sampleset import as_samples
 from dimod.utilities import resolve_label_conflict, LockableDict
 from dimod.views.bqm import LinearView, QuadraticView, AdjacencyView
 from dimod.views.samples import SampleView
+from dimod.variables import iter_serialize_variables
 from dimod.vartypes import Vartype
 
 __all__ = ['BinaryQuadraticModel', 'BQM']
@@ -1739,11 +1740,13 @@ class BinaryQuadraticModel(abc.Sized, abc.Container, abc.Iterable):
         from dimod.package_info import __version__
         schema_version = "2.0.0"
 
+        variables = list(iter_serialize_variables(self.variables))
+
         try:
-            variables = sorted(self.variables)
+            variables.sort()
         except TypeError:
-            # sorting unlike types in py3
-            variables = list(self.variables)
+            # cannot unlike types in py3
+            pass
 
         num_variables = len(variables)
 
diff --git a/dimod/sampleset.py b/dimod/sampleset.py
index b257fb87..c2efd78f 100644
--- a/dimod/sampleset.py
+++ b/dimod/sampleset.py
@@ -1359,7 +1359,7 @@ class SampleSet(abc.Iterable, abc.Sized):
                 "info": self.info,
                 "version": {"dimod": __version__,
                             "sampleset_schema": schema_version},
-                "variable_labels": list(self.variables),
+                "variable_labels": self.variables.to_serializable(),
                 "use_bytes": bool(use_bytes)}
 
     def _asdict(self):
diff --git a/dimod/variables.py b/dimod/variables.py
index b40060ce..b7b054bd 100644
--- a/dimod/variables.py
+++ b/dimod/variables.py
@@ -13,6 +13,8 @@
 #    limitations under the License.
 #
 # =============================================================================
+from numbers import Integral, Number
+
 try:
     import collections.abc as abc
 except ImportError:
@@ -26,6 +28,8 @@ from dimod.utilities import resolve_label_conflict
 from six import PY3
 from six.moves import map
 
+__all__ = ['Variables']
+
 
 class CallableDict(abc.Callable, dict):
     """Dict that can be accessed like a function."""
@@ -37,6 +41,23 @@ class CallableDict(abc.Callable, dict):
         return self[v]
 
 
+def iter_serialize_variables(variables):
+    # want to handle things like numpy numbers and fractions that do not
+    # serialize so easy
+    for v in variables:
+        if isinstance(v, Integral):
+            yield int(v)
+        elif isinstance(v, Number):
+            yield float(v)
+        elif isinstance(v, str):
+            yield v
+        # we want Collection, but that's not available in py2.7
+        elif isinstance(v, (abc.Sequence, abc.Set)):
+            yield tuple(iter_serialize_variables(v))
+        else:
+            yield v
+
+
 class Variables(abc.Sequence, abc.Set):
     """set-like and list-like variable tracking.
 
@@ -116,6 +137,9 @@ class Variables(abc.Sequence, abc.Set):
         # everything is unique
         return int(v in self)
 
+    def to_serializable(self):
+        return list(iter_serialize_variables(self))
+
     @lockable_method
     def relabel(self, mapping):
 

sampleset.to_serializable to check variable indices
when using to_serializable, seems like it doesn't check the type of variable indices.
if np.int64 is sent it as variable indices, sampleset.to_serializable() remains not bson compatible. 

would be nice if we can check that and convert during the process
diff --git a/tests/test_binary_quadratic_model.py b/tests/test_binary_quadratic_model.py
index 37a69a69..a761cf5c 100644
--- a/tests/test_binary_quadratic_model.py
+++ b/tests/test_binary_quadratic_model.py
@@ -14,14 +14,15 @@
 #
 # ================================================================================================
 
-import unittest
-import random
+import collections
+import fractions
 import itertools
-import tempfile
-import shutil
 import json
-import collections
 import pickle
+import random
+import shutil
+import tempfile
+import unittest
 
 from os import path
 
@@ -2221,6 +2222,16 @@ class TestSerialization(unittest.TestCase):
         self.assertEqual(bqm, new)
         self.assertEqual(new.info, {"tag": 5})
 
+    def test_variable_labels(self):
+        h = {0: 0, 1: 1, np.int64(2): 2, np.float(3): 3,
+             fractions.Fraction(4, 1): 4, fractions.Fraction(5, 2): 5,
+             '6': 6}
+        J = {}
+
+        bqm = dimod.BinaryQuadraticModel.from_ising(h, J)
+
+        json.dumps(bqm.to_serializable())
+
 
 class TestZeroField(unittest.TestCase):
     # test when there are only quadratic biases
diff --git a/tests/test_sampleset.py b/tests/test_sampleset.py
index 22f3be24..2f03c9c6 100644
--- a/tests/test_sampleset.py
+++ b/tests/test_sampleset.py
@@ -14,6 +14,7 @@
 #
 # ================================================================================================
 import unittest
+import fractions
 import json
 import pickle
 
@@ -648,6 +649,15 @@ class TestSerialization(unittest.TestCase):
 
         self.assertEqual(sampleset, new)
 
+    def test_numpy_variable_labels(self):
+        h = {0: 0, 1: 1, np.int64(2): 2, np.float(3): 3,
+             fractions.Fraction(4, 1): 4, fractions.Fraction(5, 2): 5,
+             '6': 6}
+
+        sampleset = dimod.NullSampler().sample_ising(h, {})
+
+        json.dumps(sampleset.to_serializable())
+
 
 @unittest.skipUnless(_pandas, "no pandas present")
 class TestPandas(unittest.TestCase):

pip install -e .[all]
parse_log_pytest
requirements.txt
pytest pytest-cov
apt-get update apt-get install -y libboost-dev
3.6
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs==22.2.0
certifi==2021.5.30
charset-normalizer==2.0.12
codecov==2.1.13
coverage==6.2
Cython==3.0.12
decorator==5.1.1
-e git+https://github.com/dwavesystems/dimod.git@4920d4e490a40ae69fafb4709ff8cc91059feb79#egg=dimod
idna==3.10
importlib-metadata==4.8.3
iniconfig==1.1.1
jsonschema==2.6.0
mock==2.0.0
networkx==2.0
numpy==1.15.0
packaging==21.3
pandas==0.22.0
pbr==6.1.1
pluggy==1.0.0
py==1.11.0
pymongo==3.7.1
pyparsing==3.1.4
pytest==7.0.1
pytest-cov==4.0.0
python-dateutil==2.9.0.post0
pytz==2025.2
requests==2.27.1
simplejson==3.16.0
six==1.11.0
tomli==1.2.3
typing_extensions==4.1.1
urllib3==1.26.20
zipp==3.6.0

name: dimod
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - attrs==22.2.0
      - charset-normalizer==2.0.12
      - codecov==2.1.13
      - coverage==6.2
      - cython==3.0.12
      - decorator==5.1.1
      - idna==3.10
      - importlib-metadata==4.8.3
      - iniconfig==1.1.1
      - jsonschema==2.6.0
      - mock==2.0.0
      - networkx==2.0
      - numpy==1.15.0
      - packaging==21.3
      - pandas==0.22.0
      - pbr==6.1.1
      - pluggy==1.0.0
      - py==1.11.0
      - pymongo==3.7.1
      - pyparsing==3.1.4
      - pytest==7.0.1
      - pytest-cov==4.0.0
      - python-dateutil==2.9.0.post0
      - pytz==2025.2
      - requests==2.27.1
      - simplejson==3.16.0
      - six==1.11.0
      - tomli==1.2.3
      - typing-extensions==4.1.1
      - urllib3==1.26.20
      - zipp==3.6.0
prefix: /opt/conda/envs/dimod

tests/test_binary_quadratic_model.py::TestSerialization::test_variable_labels tests/test_sampleset.py::TestSerialization::test_numpy_variable_labels
tests/test_binary_quadratic_model.py::TestLockableDict::test__delitem__ tests/test_binary_quadratic_model.py::TestLockableDict::test__setitem__ tests/test_binary_quadratic_model.py::TestLockableDict::test_clear tests/test_binary_quadratic_model.py::TestLockableDict::test_pop tests/test_binary_quadratic_model.py::TestLockableDict::test_popitem tests/test_binary_quadratic_model.py::TestLockableDict::test_setdefault tests/test_binary_quadratic_model.py::TestLockableDict::test_update tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test__contains__ tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test__eq__ tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test__iter__ tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test__len__ tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test__repr__ tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_add_interaction tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_add_interaction_counterpart tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_add_interactions_from tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_add_offset tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_add_variable tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_add_variable_counterpart tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_add_variables_from tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_binary_property tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_binary_property_relabel tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_change_vartype tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_consistency_after_retrieve tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_construction tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_construction_quadratic tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_construction_vartype tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_contract_variables tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_copy tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_fix_variable tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_fix_variables tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_flip_variable tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_normalize tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_normalize_exclusions tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_partial_relabel_copy tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_partial_relabel_inplace tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_pickle_empty tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_pickle_full tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_relabel_typical tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_relabel_typical_copy tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_relabel_typical_inplace tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_relabel_with_identity tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_relabel_with_overlap tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_remove_interaction tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_remove_interactions_from tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_remove_offset tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_remove_variable tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_remove_variables_from tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_scale tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_scale_exclusions tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_spin_property tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_spin_property_relabel tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_update tests/test_binary_quadratic_model.py::TestBinaryQuadraticModel::test_variables tests/test_binary_quadratic_model.py::TestConvert::test_coo_functional_file_BINARY tests/test_binary_quadratic_model.py::TestConvert::test_coo_functional_file_SPIN tests/test_binary_quadratic_model.py::TestConvert::test_coo_functional_file_empty_BINARY tests/test_binary_quadratic_model.py::TestConvert::test_coo_functional_file_empty_SPIN tests/test_binary_quadratic_model.py::TestConvert::test_coo_functional_string_BINARY tests/test_binary_quadratic_model.py::TestConvert::test_coo_functional_string_SPIN tests/test_binary_quadratic_model.py::TestConvert::test_coo_functional_string_empty_BINARY tests/test_binary_quadratic_model.py::TestConvert::test_coo_functional_string_empty_SPIN tests/test_binary_quadratic_model.py::TestConvert::test_coo_functional_two_digit_integers_string tests/test_binary_quadratic_model.py::TestConvert::test_empty tests/test_binary_quadratic_model.py::TestConvert::test_energies_all_ordering tests/test_binary_quadratic_model.py::TestConvert::test_energies_cpp tests/test_binary_quadratic_model.py::TestConvert::test_energies_misordered tests/test_binary_quadratic_model.py::TestConvert::test_from_coo_file tests/test_binary_quadratic_model.py::TestConvert::test_from_coo_string tests/test_binary_quadratic_model.py::TestConvert::test_from_ising tests/test_binary_quadratic_model.py::TestConvert::test_from_numpy_matrix tests/test_binary_quadratic_model.py::TestConvert::test_from_numpy_vectors tests/test_binary_quadratic_model.py::TestConvert::test_from_numpy_vectors_labels tests/test_binary_quadratic_model.py::TestConvert::test_from_qubo tests/test_binary_quadratic_model.py::TestConvert::test_info tests/test_binary_quadratic_model.py::TestConvert::test_to_coo_string_empty_BINARY tests/test_binary_quadratic_model.py::TestConvert::test_to_coo_string_empty_SPIN tests/test_binary_quadratic_model.py::TestConvert::test_to_coo_string_typical_BINARY tests/test_binary_quadratic_model.py::TestConvert::test_to_coo_string_typical_SPIN tests/test_binary_quadratic_model.py::TestConvert::test_to_ising_binary_to_ising tests/test_binary_quadratic_model.py::TestConvert::test_to_ising_spin_to_ising tests/test_binary_quadratic_model.py::TestConvert::test_to_networkx_graph tests/test_binary_quadratic_model.py::TestConvert::test_to_numpy_matrix tests/test_binary_quadratic_model.py::TestConvert::test_to_numpy_vectors tests/test_binary_quadratic_model.py::TestConvert::test_to_numpy_vectors_labels_sorted tests/test_binary_quadratic_model.py::TestConvert::test_to_numpy_vectors_sorted tests/test_binary_quadratic_model.py::TestConvert::test_to_pandas_dataframe tests/test_binary_quadratic_model.py::TestConvert::test_to_qubo_binary_to_qubo tests/test_binary_quadratic_model.py::TestConvert::test_to_qubo_spin_to_qubo tests/test_binary_quadratic_model.py::TestSerialization::test_from_serializable_bytes_empty_v1 tests/test_binary_quadratic_model.py::TestSerialization::test_from_serializable_bytes_empty_v2 tests/test_binary_quadratic_model.py::TestSerialization::test_from_serializable_bytes_v1 tests/test_binary_quadratic_model.py::TestSerialization::test_from_serializable_bytes_v2 tests/test_binary_quadratic_model.py::TestSerialization::test_from_serializable_empty_v1 tests/test_binary_quadratic_model.py::TestSerialization::test_from_serializable_empty_v2 tests/test_binary_quadratic_model.py::TestSerialization::test_from_serializable_v1 tests/test_binary_quadratic_model.py::TestSerialization::test_from_serializable_v2 tests/test_binary_quadratic_model.py::TestSerialization::test_functional tests/test_binary_quadratic_model.py::TestSerialization::test_functional_bytes tests/test_binary_quadratic_model.py::TestSerialization::test_functional_bytes_empty tests/test_binary_quadratic_model.py::TestSerialization::test_functional_bytes_info tests/test_binary_quadratic_model.py::TestSerialization::test_functional_empty tests/test_binary_quadratic_model.py::TestSerialization::test_functional_info tests/test_binary_quadratic_model.py::TestZeroField::test_one_interaction tests/test_binary_quadratic_model.py::TestFromNetworkxGraph::test_empty tests/test_binary_quadratic_model.py::TestFromNetworkxGraph::test_functional tests/test_binary_quadratic_model.py::TestFromNetworkxGraph::test_no_biases tests/test_binary_quadratic_model.py::TestIsWriteable::test_already_existing_biases tests/test_binary_quadratic_model.py::TestIsWriteable::test_biases tests/test_binary_quadratic_model.py::TestIsWriteable::test_info tests/test_binary_quadratic_model.py::TestIsWriteable::test_offset tests/test_sampleset.py::Test_as_samples::test_copy_false tests/test_sampleset.py::Test_as_samples::test_dict_with_inconsistent_labels tests/test_sampleset.py::Test_as_samples::test_dict_with_labels tests/test_sampleset.py::Test_as_samples::test_empty_dict tests/test_sampleset.py::Test_as_samples::test_empty_list tests/test_sampleset.py::Test_as_samples::test_empty_list_labelled tests/test_sampleset.py::Test_as_samples::test_empty_ndarray tests/test_sampleset.py::Test_as_samples::test_iterator tests/test_sampleset.py::Test_as_samples::test_iterator_labelled tests/test_sampleset.py::Test_as_samples::test_list_of_empty tests/test_sampleset.py::Test_as_samples::test_mixed_sampletype tests/test_sampleset.py::Test_as_samples::test_ndarray tests/test_sampleset.py::Test_as_samples::test_ndarray_labelled tests/test_sampleset.py::TestConstruction::test_from_bqm_single_sample tests/test_sampleset.py::TestConstruction::test_from_bqm_with_sorting tests/test_sampleset.py::TestConstruction::test_from_samples tests/test_sampleset.py::TestConstruction::test_from_samples_empty tests/test_sampleset.py::TestConstruction::test_from_samples_fields_multiple tests/test_sampleset.py::TestConstruction::test_from_samples_fields_single tests/test_sampleset.py::TestConstruction::test_from_samples_iterator tests/test_sampleset.py::TestConstruction::test_from_samples_single_sample tests/test_sampleset.py::TestConstruction::test_from_samples_str_labels tests/test_sampleset.py::TestConstruction::test_from_samples_with_aggregation tests/test_sampleset.py::TestConstruction::test_mismatched_shapes tests/test_sampleset.py::TestConstruction::test_shorter_samples tests/test_sampleset.py::TestEq::test_ordered tests/test_sampleset.py::TestAggregate::test_aggregate_simple tests/test_sampleset.py::TestAggregate::test_num_occurences tests/test_sampleset.py::TestAggregate::test_order_preservation tests/test_sampleset.py::TestAggregate::test_order_preservation_2x2_unique tests/test_sampleset.py::TestAggregate::test_order_preservation_doubled tests/test_sampleset.py::TestAppend::test_overlapping_variables tests/test_sampleset.py::TestAppend::test_sampleset1_append1 tests/test_sampleset.py::TestAppend::test_sampleset2_append1 tests/test_sampleset.py::TestAppend::test_sampleset2_append2 tests/test_sampleset.py::TestAppend::test_sampleset2_append3 tests/test_sampleset.py::TestAppend::test_two_samplesets tests/test_sampleset.py::TestLowest::test_all_equal tests/test_sampleset.py::TestLowest::test_empty tests/test_sampleset.py::TestLowest::test_tolerance tests/test_sampleset.py::TestPickle::test_without_future tests/test_sampleset.py::TestTruncate::test_typical tests/test_sampleset.py::TestTruncate::test_unordered tests/test_sampleset.py::TestSlice::test_custom_ordering tests/test_sampleset.py::TestSlice::test_kwargs tests/test_sampleset.py::TestSlice::test_null_slice tests/test_sampleset.py::TestSlice::test_slice_range tests/test_sampleset.py::TestSlice::test_slice_stop_only tests/test_sampleset.py::TestSlice::test_slice_stride tests/test_sampleset.py::TestSlice::test_typical tests/test_sampleset.py::TestSlice::test_unordered tests/test_sampleset.py::TestIteration::test_data_reverse tests/test_sampleset.py::TestIteration::test_iterator tests/test_sampleset.py::TestSerialization::test_empty_with_bytes tests/test_sampleset.py::TestSerialization::test_from_serializable_empty_v1 tests/test_sampleset.py::TestSerialization::test_from_serializable_empty_variables_v1 tests/test_sampleset.py::TestSerialization::test_from_serializable_triu_v1 tests/test_sampleset.py::TestSerialization::test_functional_json tests/test_sampleset.py::TestSerialization::test_functional_simple_shapes tests/test_sampleset.py::TestSerialization::test_functional_str tests/test_sampleset.py::TestSerialization::test_functional_with_info tests/test_sampleset.py::TestSerialization::test_triu_with_bytes tests/test_sampleset.py::TestSerialization::test_tuple_variable_labels tests/test_sampleset.py::TestPandas::test_sample_column tests/test_sampleset.py::TestPandas::test_simple tests/test_sampleset.py::TestFirst::test_empty tests/test_sampleset.py::TestDataVectors::test_empty tests/test_sampleset.py::TestDataVectors::test_view tests/test_sampleset.py::Test_concatenate::test_empty tests/test_sampleset.py::Test_concatenate::test_simple tests/test_sampleset.py::Test_concatenate::test_variables_order tests/test_sampleset.py::Test_concatenate::test_variables_order_and_vartype tests/test_sampleset.py::TestWriteable::test_locked
dimod/binary_quadratic_model.py dimod/sampleset.py dimod/variables.py
dimod/binary_quadratic_model.py dimod/sampleset.py dimod/variables.py