A compound of formula I, or a pharmaceutically acceptable salt thereof, wherein: X is CR or N; A is O, S, SO 2, SO, -NRC, -NRSO 2, or N; or A is absent; R 3 is H, C 1-6 aliphatic, C 3-10 aryl, a 3-8 membered saturated or partially unsaturated carbocyclic ring, or a 3-7 membered heterocylic ring having 1-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur; each of which is optionally substituted; or R 3 is halogen, - haloalkyl, -OR, -SR, -CN, -NO 2, -SO 2 R, -SOR, -C R, -CO 2 R, -C N 2, -NRC R, -NRC N 2, -NRSO 2 R, or -N 2; or when A is -NRC, -NRSO 2, or N; then R and R 3, together with the atoms to which each is attached, may form a 3-7 membered heterocylic ring having 1-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur, or a 5-6 membered monocyclic heteroaryl ring having 1-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur; each of which is optionally substituted; X' is CR or N; Ring Z is a 3-7 membered heterocylic ring having 1-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur, or a 5-6 membered monocyclic heteroaryl ring having 1-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur; each of which is optionally substituted; R 1 is -R, halogen, -haloalkyl, -OR, -SR, -CN, -NO 2, -SO 2 R, -SOR, -C R, -CO 2 R, -C N 2, -NRC R, -NRC N 2, -NRSO 2 R, or -N 2; R a is absent, -R, halogen, -haloalkyl, -OR, -SR, -CN, -NO 2, -SO 2 R, -SOR, -C R, -CO 2 R, -C N 2, -NRC R, -NRC N 2, -NRSO 2 R, or -N 2; Ring Y is an optionally substituted pyridyl, pyrazole or thiadiazole; R 2 is -R, halogen, -haloalkyl, -OR, -SR, -CN, -NO 2, -SO 2 R, -SOR, -C R, -CO 2 R, -C N 2, -NRC R, -NRC N 2, -NRSO 2 R, or -N 2; R b is absent, -R, halogen, -haloalkyl, -OR, -SR, -CN, -NO 2, -SO 2 R, -SOR, -C R, -CO 2 R, -C N 2, -NRC R, -NRC N 2, -NRSO 2 R, or -N 2;; each R is independently hydrogen, C 1-6 aliphatic, C 3-10 aryl, a 3-8 membered saturated or partially unsaturated carbocyclic ring, a 3-7 membered heterocylic ring having 1-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur, or a 5-6 membered monocyclic heteroaryl ring having 1-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur; each of which is optionally substituted; or two R groups on the same atom are taken together with the atom to which they are attached to form a C 3-10 aryl, a 3-8 membered saturated or partially unsaturated carbocyclic ring, a 3-7 membered heterocylic ring having 1-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur, or a 5-6 membered monocyclic heteroaryl ring having 1-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur; each of which is optionally substituted; wherein when X is N and A is absent, then R 3 is not H. X is CR or N; A is O, S, SO 2, SO, -NRC, -NRSO 2, or N; or A is absent; R 3 is H, C 1-6 aliphatic, C 3-10 aryl, a 3-8 membered saturated or partially unsaturated carbocyclic ring, or a 3-7 membered heterocylic ring having 1-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur; each of which is optionally substituted; or R 3 is halogen, - haloalkyl, -OR, -SR, -CN, -NO 2, -SO 2 R, -SOR, -C R, -CO 2 R, -C N 2, -NRC R, -NRC N 2, -NRSO 2 R, or -N 2; or when A is -NRC, -NRSO 2, or N; then R and R 3, together with the atoms to which each is attached, may form a 3-7 membered heterocylic ring having 1-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur, or a 5-6 membered monocyclic heteroaryl ring having 1-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur; each of which is optionally substituted; X' is CR or N; Ring Z is a 3-7 membered heterocylic ring having 1-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur, or a 5-6 membered monocyclic heteroaryl ring having 1-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur; each of which is optionally substituted; R 1 is -R, halogen, -haloalkyl, -OR, -SR, -CN, -NO 2, -SO 2 R, -SOR, -C R, -CO 2 R, -C N 2, -NRC R, -NRC N 2, -NRSO 2 R, or -N 2; R a is absent, -R, halogen, -haloalkyl, -OR, -SR, -CN, -NO 2, -SO 2 R, -SOR, -C R, -CO 2 R, -C N 2, -NRC R, -NRC N 2, -NRSO 2 R, or -N 2; Ring Y is an optionally substituted pyridyl, pyrazole or thiadiazole; R 2 is -R, halogen, -haloalkyl, -OR, -SR, -CN, -NO 2, -SO 2 R, -SOR, -C R, -CO 2 R, -C N 2, -NRC R, -NRC N 2, -NRSO 2 R, or -N 2; R b is absent, -R, halogen, -haloalkyl, -OR, -SR, -CN, -NO 2, -SO 2 R, -SOR, -C R, -CO 2 R, -C N 2, -NRC R, -NRC N 2, -NRSO 2 R, or -N 2;; each R is independently hydrogen, C 1-6 aliphatic, C 3-10 aryl, a 3-8 membered saturated or partially unsaturated carbocyclic ring, a 3-7 membered heterocylic ring having 1-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur, or a 5-6 membered monocyclic heteroaryl ring having 1-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur; each of which is optionally substituted; or two R groups on the same atom are taken together with the atom to which they are attached to form a C 3-10 aryl, a 3-8 membered saturated or partially unsaturated carbocyclic ring, a 3-7 membered heterocylic ring having 1-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur, or a 5-6 membered monocyclic heteroaryl ring having 1-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur; each of which is optionally substituted; wherein when X is N and A is absent, then R 3 is not H.